Linloir 9f5a885f4b
All checks were successful
Deploy Pages / Generate-Pages (push) Successful in 38s
feat: upload butterfly theme
2024-10-10 00:06:54 +08:00

31 lines
1013 B
Plaintext

- const { host, siteId } = theme.remark42
script.
window.addEventListener('load', () => {
const keyName = 'remark42-newest-comments'
const { changeContent, generateHtml, run } = window.newestComments
const getComment = ele => {
fetch('!{host}/api/v1/last/!{theme.aside.card_newest_comments.limit}?site=!{siteId}')
.then(response => response.json())
.then(data => {
const remark42 = data.map(e => {
return {
'avatar': e.user.picture,
'content': changeContent(e.text),
'nick': e.user.name,
'url': e.locator.url,
'date': e.time,
}
})
btf.saveToLocal.set(keyName, JSON.stringify(remark42), !{theme.aside.card_newest_comments.storage}/(60*24))
generateHtml(remark42, ele)
}).catch(e => {
console.error(e)
ele.textContent= "!{_p('aside.card_newest_comments.error')}"
})
}
run(keyName, getComment)
})