fix(thumbnail): 归档页面添加默认封面图

This commit is contained in:
nineya 2023-12-29 17:20:34 +08:00
parent 4b29cf2994
commit ab736ce1d7
3 changed files with 7 additions and 6 deletions

View File

@ -12,9 +12,10 @@
<div class="timeline-title" th:text="${archive.year}"></div>
<div class="timeline">
<th:block th:each="months : ${archive.months}">
<article th:each="post : ${months.posts}" class="media">
<a th:if="${!#strings.isEmpty(post.spec.cover)}" th:href="${post.status.permalink}" class="media-left">
<img class="not-gallery" th:src="${post.spec.cover}" th:alt="${post.spec.title}">
<article th:each="post : ${months.posts}" class="media"
th:with="thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + (#strings.contains(theme.config.post.default_thumbnail, '?') ? '&' : '?') + 'id=' + post.metadata.name : post.spec.cover}">
<a th:if="${!#strings.isEmpty(thumbnail)}" th:href="${post.status.permalink}" class="media-left">
<img class="not-gallery" th:src="${thumbnail}" th:alt="${post.spec.title}">
</a>
<div class="media-content">
<time th:text="${#dates.format(post.spec.publishTime, 'yyyy-MM-dd')}"></time>

View File

@ -1,7 +1,7 @@
<th:block xmlns:th="https://www.thymeleaf.org"
th:fragment="article (post, type)"
th:with="updateInterval = ${T(java.lang.Math).floor((#dates.createNow().getTime()/1000.0 - post.status.lastModifyTime.getEpochSecond())/86400.0).intValue()},
thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail : post.spec.cover}">
thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + (#strings.contains(theme.config.post.default_thumbnail, '?') ? '&' : '?') + 'id=' + post.metadata.name : post.spec.cover}">
<div th:if="${!#strings.isEmpty(thumbnail)}" class="card widget">
<div class="cover-image" th:style="'background-image: url(' + ${thumbnail} + ')'">

View File

@ -1,7 +1,7 @@
<th:block xmlns:th="https://www.thymeleaf.org"
th:fragment="articleList (posts)">
<th:block th:each="post : ${posts}"
th:with="thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + '?id=' + postStat.index : post.spec.cover},
th:with="thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + (#strings.contains(theme.config.post.default_thumbnail, '?') ? '&' : '?') + 'id=' + post.metadata.name : post.spec.cover},
thumbnail_mode = ${(theme.config.post.top_thumbnail_mode == 'grid' || (!post.spec.pinned && theme.config.post.thumbnail_mode == 'grid'))? 'grid' : !#strings.isEmpty(post.metadata.annotations.get('thumbnail_mode'))? post.metadata.annotations.get('thumbnail_mode') : post.spec.pinned ? theme.config.post.top_thumbnail_mode : theme.config.post.thumbnail_mode}">
<div th:if="${!#strings.isEmpty(thumbnail) && thumbnail_mode == 'back'}" class="card widget card-cover">
<a th:href="${post.status.permalink}">
@ -133,7 +133,7 @@
<div th:if="${theme.config.post.top_thumbnail_mode == 'grid' || theme.config.post.thumbnail_mode == 'grid'}"
class="column-main-grid">
<th:block th:each="post : ${posts}"
th:with="thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + '?id=' + postStat.index : post.spec.cover}">
th:with="thumbnail = ${#strings.isEmpty(post.spec.cover) ? #strings.isEmpty(theme.config.post.default_thumbnail) ? '' : theme.config.post.default_thumbnail + (#strings.contains(theme.config.post.default_thumbnail, '?') ? '&' : '?') + 'id=' + post.metadata.name : post.spec.cover}">
<div
th:if="${(theme.config.post.top_thumbnail_mode == 'grid' || (!post.spec.pinned && theme.config.post.thumbnail_mode == 'grid'))}"
class="card widget">