修复最近评论中出现友链评论的报错问题

This commit is contained in:
stonewu 2023-08-11 00:26:38 +08:00
parent 137f2331d0
commit ee34c6fb02
2 changed files with 16 additions and 10 deletions

View File

@ -5,13 +5,16 @@
<div class="item-headline"><i class="iconfont icon-comment-dots"></i><span>最新评论</span></div> <div class="item-headline"><i class="iconfont icon-comment-dots"></i><span>最新评论</span></div>
<div class="aside-list" id="newcomm"> <div class="aside-list" id="newcomm">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }"> <th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}" th:if="${iterStat.index < 5}"> <div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 20)}"
<a class="thumbnail" th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" data-pjax-state=""> th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) : null}"
th:if="${iterStat.index < theme.config.sidebar.newcommentnumber}">
<span th:text="${commentIndex}"></span>
<a class="thumbnail" th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" data-pjax-state="">
<img loading="lazy" alt="头像" th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}" data-ll-status="loading" class="entered loading"> <img loading="lazy" alt="头像" th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}" data-ll-status="loading" class="entered loading">
</a> </a>
<div class="content" > <div class="content" >
<a class="comment" style="display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;" <a class="comment" style="display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;"
th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" th:text="${comment.spec.content}" data-pjax-state=""> th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" th:text="${comment.spec.content}" data-pjax-state="">
</a> </a>
<div class="name"> <div class="name">

View File

@ -16,14 +16,17 @@
</div> </div>
<div class="aside-list"> <div class="aside-list">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }"> <th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}" th:if="${iterStat.index < 4}"> <!-- BUG由于当前的列出所有评论API无过滤功能非文章页的评论无法查询到页面信息所以非文章评论跳转至首页-->
<a th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" class="thumbnail" data-pjax-state=""> <div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 20)}"
th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) : null}"
th:if="${iterStat.index < 6}" >
<a th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" class="thumbnail" data-pjax-state="">
<img th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}" <img th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}"
th:alt="${comment.owner.displayName}" data-ll-status="loaded" class="entered loaded"> th:alt="${comment.owner.displayName}" data-ll-status="loaded" class="entered loaded">
<div class="name"><span>stonewu</span></div> <div class="name"><span>stonewu</span></div>
</a> </a>
<div class="content"> <div class="content">
<a class="comment" th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" data-pjax-state="" th:text="${comment.spec.content}"></a> <a class="comment" th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" data-pjax-state="" th:text="${comment.spec.content}"></a>
<time th:datetime="${#dates.format(comment.metadata.creationTimestamp, 'yyyy-MM-dd HH:mm:ss')}"></time> <time th:datetime="${#dates.format(comment.metadata.creationTimestamp, 'yyyy-MM-dd HH:mm:ss')}"></time>
</div> </div>
</div> </div>