You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
711 B
21 lines
711 B
- const serverURL = theme.waline.serverURL.replace(/\/$/, '') |
|
script. |
|
(() => { |
|
async function loadWaline () { |
|
try { |
|
const eleGroup = document.querySelectorAll('#recent-posts .waline-comment-count') |
|
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-path')) |
|
|
|
const res = await fetch(`!{serverURL}/api/comment?type=count&url=${keyArray}`, { method: 'GET' }) |
|
const result = await res.json() |
|
|
|
result.data.forEach((count, index) => { |
|
eleGroup[index].textContent = count |
|
}) |
|
} catch (err) { |
|
console.error(err) |
|
} |
|
} |
|
|
|
window.pjax ? loadWaline() : window.addEventListener('load', loadWaline) |
|
})()
|
|
|