Skip to content

Commit

Permalink
Merge pull request #133 from mjsoftking/perf-recent-comments
Browse files Browse the repository at this point in the history
perf: 优化侧边栏最近评论显示邮箱头像
  • Loading branch information
nineya committed Jul 2, 2024
2 parents aa6ebb6 + 8ef6126 commit e2e5c85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ spec:
label: 侧边栏最近评论-展示评论数量
placeholder: 请输入数量数值
value: 5
- $formkit: text
label: 侧边栏最近评论-邮箱头像服务地址
help: '邮箱头像服务地址,支持参考文档自定义部分参数,其中“{hash}”表示邮箱Hash值。'
name: providerMirror
value: "https://cravatar.cn/avatar/{hash}"
validation: required
- $formkit: radio
name: categories_more
label: 侧边栏分类-显示”更多”按钮
Expand Down
14 changes: 10 additions & 4 deletions templates/widget/recent_comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
<div th:unless="${isEmpty}" class="card-content">
<ul class="widget-comment">
<li class="item" th:each="comment : ${comments}">
<div class="user">
<img width="35" height="35" th:unless="${#strings.isEmpty(comment.owner.avatar)}" class="avatar" th:src="${comment.owner.avatar}"
<div class="user"
th:with="
emailHash = ${comment.spec.owner.annotations != null ? comment.spec.owner.annotations['email-hash'] : ''},
userA = ${comment.owner.avatar},
img = ${#strings.isEmpty(userA) && !#strings.isEmpty(emailHash) ? #strings.replace(theme.config.sidebar.providerMirror, '{hash}', emailHash) : userA}">
<img width="35" height="35" th:unless="${#strings.isEmpty(img)}" class="avatar" th:src="${img}"
th:alt="${comment.owner.displayName}">
<div th:if="${#strings.isEmpty(comment.owner.avatar)}" class="no-avatar">
<div th:if="${#strings.isEmpty(img)}" class="no-avatar">
<span class="avatar-info">[[${#strings.substring(comment.owner.displayName, 0, 1)}]]</span>
</div>
<span class="avatar-info">[[${#strings.substring(comment.owner.displayName, 0, 1)}]]</span>
</div>
<div class="info">
Expand All @@ -27,4 +33,4 @@
</li>
</ul>
</div>
</div>
</div>

0 comments on commit e2e5c85

Please sign in to comment.