Merge pull request #91 from AirboZH/main

fix: 分类、Tag、recent-posts的随机图片问题
This commit is contained in:
sunheyi 2023-02-09 20:56:35 +08:00 committed by GitHub
commit da920342d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -33,11 +33,12 @@
<div class="article-sort">
<!-- TODO 按照年份分组 需要 halo 提供归档数据-->
<!--<div class="article-sort-item year">2022</div>-->
<div class="article-sort-item" th:each="post : ${posts.items}">
<div class="article-sort-item" th:each="post : ${posts.items}"
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}">
<img th:alt="${post.spec.title}"
th:src="${#strings.isEmpty(post.spec.cover) ? theme.config.layout.postRandomImg : post.spec.cover}">
th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
</a>
<div class="article-sort-item-info">
<div class="article-sort-item-time"><i class="far fa-calendar-alt"></i>
@ -53,8 +54,7 @@
<div class="article-sort-item-tags">
<a class="article-meta__tags"
th:each="tag : ${post.tags}" th:href="@{${tag.status.permalink}}">
<span class="tags-punctuation">#</span>
[[${tag.spec.displayName}]]
<span class="tags-punctuation">#</span>[[${tag.spec.displayName}]]
</a>
<span class="article-meta__link"></span>
</div>

View File

@ -1,12 +1,14 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="card-widget card-recent-post" th:fragment="recent-posts" th:with="posts = ${postFinder.list(1,theme.config.post.recentPost)}">
<div class="card-widget card-recent-post" th:fragment="recent-posts" th:with='posts = ${postFinder.list(1,theme.config.post.recentPost)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
<div class="item-headline"><i class="iconfont icon-listol"></i><span>最近发布</span></div>
<div class="aside-list">
<!-- 最新文章,用户可以自定义展示数量 -->
<div class="aside-list-item" th:each="post : ${posts}">
<a class="thumbnail" th:href="@{${post.status.permalink}}" th:title="${post.spec.title}">
<img loading="lazy" th:alt="${post.spec.title}" th:src="${#strings.isEmpty(post.spec.cover) ? theme.config.layout.postRandomImg : post.spec.cover}">
<img loading="lazy" th:alt="${post.spec.title}"
th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
</a>
<div class="content">
<a class="title" th:href="@{${post.status.permalink}}" th:text="${post.spec.title}" th:title="${post.spec.title}"></a>

View File

@ -22,10 +22,11 @@
<div class="article-sort-title" th:text="${tag.spec.displayName}"></div>
<div class="article-sort" th:with="postItems=${posts.items}">
<!--<div class="article-sort-item year">2022</div>-->
<div class="article-sort-item" th:each="post : ${postItems}">
<div class="article-sort-item" th:each="post : ${postItems}"
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}">
<img loading="lazy" th:alt="${post.status.excerpt}" th:src="${#strings.isEmpty(post.spec.cover) ? theme.config.layout.postRandomImg : post.spec.cover}">
<img loading="lazy" th:alt="${post.status.excerpt}" th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
</a>
<div class="article-sort-item-info">
<div class="article-sort-item-time"><i class="far fa-calendar-alt"></i>