halo-theme-hao/templates/modules/widgets/aside/comments.html

42 lines
1.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!-- 归档 -->
<div class="card-widget card-recent-post" th:fragment="comments">
<div class="item-headline"><i class="iconfont icon-comment-dots"></i><span>最新评论</span></div>
<div class="aside-list" id="newcomm">
</div>
</div>
<script th:src="@{/assets/libs/twikoo/twikoo.all.min.js}"></script>
<script th:if="${theme.config.comments.twikoo && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.envId)}">
twikoo.getRecentComments({
envId: [[${ theme.config.comments.envId }]], // 环境 ID
// region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai如果您的环境地域不是上海需传此参数
pageSize: [[${theme.config.comments.newcommentnumber}]], // 获取多少条默认10最大100
includeReply: false // 是否包括最新回复默认false
}).then(function (res) {
let commenthtml = '';
res.forEach((items)=>{
commenthtml += `<div class="aside-list-item">
<a class="thumbnail" href="${items.url}">
<img loading="lazy" alt="dasda" src="${items.avatar}">
</a>
<div class="content">
<a class="comment" style="display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;" href="${items.url}" title="test">
${items.commentText}
</a>
<div class="name">
<span>${items.nick} / </span>
<time datetime="${items.created}">${items.relativeTime}</time>
</div>
</div>
</div>`
});
document.querySelector('#newcomm').innerHTML = commenthtml;
}).catch(function (err) {
// 发生错误
console.error(err);
});
</script>
</html>