优化阅读建议
This commit is contained in:
parent
8aaabac809
commit
63a08850f4
|
@ -1,18 +1,20 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
<!-- 阅读建议 -->
|
<!-- 阅读建议 -->
|
||||||
<th:block th:fragment="relatedPosts">
|
<th:block th:fragment="relatedPosts" th:if="${not #lists.isEmpty(post.categories)}" th:with="recommendQuantity = ${theme.config.post.recommendQuantity},
|
||||||
<div class="relatedPosts" th:if="${not #lists.isEmpty(post.categories)}">
|
recommandPosts = ${postFinder.listByCategory(1,recommendQuantity == 'six' ? 7 : recommendQuantity == 'two' ? 3 : 1,post.categories.get(0).metadata.name)},
|
||||||
|
containsTitle = ${#strings.contains(recommandPosts,post.spec.title)}">
|
||||||
|
<div class="relatedPosts" th:if="${recommandPosts.total>1}">
|
||||||
<div class="headline">
|
<div class="headline">
|
||||||
<i class="iconfont icon-robot"></i>
|
<i class="iconfont icon-robot"></i>
|
||||||
<span>阅读建议</span>
|
<span>阅读建议</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- 六篇文章 -->
|
<!-- 六篇文章 -->
|
||||||
<div th:if="${#strings.equals(theme.config.post.recommendQuantity, 'six')}" class="relatedPosts-list"
|
<div th:if="${#strings.equals(recommendQuantity, 'six')}" class="relatedPosts-list">
|
||||||
th:with="recommandPosts = ${postFinder.listByCategory(1, 7, post.categories.get(0).metadata.name)}">
|
|
||||||
<!-- 建议阅读,这里可以自定义文章数量,然后遍历展示 -->
|
<!-- 建议阅读,这里可以自定义文章数量,然后遍历展示 -->
|
||||||
<div th:each="recommandPost :${recommandPosts}"
|
<th:block th:each="recommandPost,iterStat :${recommandPosts}"
|
||||||
th:if="${not #strings.equals(post.spec.title, recommandPost.spec.title)}">
|
th:if="${not #strings.equals(post.spec.title, recommandPost.spec.title)}">
|
||||||
|
<div th:if="${!containsTitle ? iterStat.index <6 : true}">
|
||||||
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
|
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
|
||||||
<img alt="cover" class="cover" loading="lazy" id="preimg"
|
<img alt="cover" class="cover" loading="lazy" id="preimg"
|
||||||
th:src="${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}">
|
th:src="${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}">
|
||||||
|
@ -24,12 +26,13 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
<!-- 两篇文章 -->
|
<!-- 两篇文章 -->
|
||||||
<div th:if="${#strings.equals(theme.config.post.recommendQuantity, 'two')}" class="relatedPosts-list"
|
<div th:if="${#strings.equals(recommendQuantity, 'two')}" class="relatedPosts-list">
|
||||||
th:with="recommandPosts = ${postFinder.listByCategory(1, 3, post.categories.get(0).metadata.name)}">
|
<th:block th:each="recommandPost,iterStat :${recommandPosts}"
|
||||||
<div th:each="recommandPost :${recommandPosts}"
|
|
||||||
th:if="${not #strings.equals(post.spec.title, recommandPost.spec.title)}">
|
th:if="${not #strings.equals(post.spec.title, recommandPost.spec.title)}">
|
||||||
|
<div th:if="${!containsTitle ? iterStat.index <2 : true}">
|
||||||
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
|
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
|
||||||
<img class="cover" alt="cover"
|
<img class="cover" alt="cover"
|
||||||
th:src="${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}">
|
th:src="${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}">
|
||||||
|
@ -40,14 +43,12 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<link th:if="${#strings.equals(recommendQuantity, 'six')}" rel="stylesheet"
|
||||||
<link th:if="${#strings.equals(theme.config.post.recommendQuantity, 'six')}" rel="stylesheet"
|
|
||||||
th:href="${assets_link + '/css/related-posts-six.css' + theme_version}">
|
th:href="${assets_link + '/css/related-posts-six.css' + theme_version}">
|
||||||
<link th:if="${#strings.equals(theme.config.post.recommendQuantity, 'two')}" rel="stylesheet"
|
<link th:if="${#strings.equals(recommendQuantity, 'two')}" rel="stylesheet"
|
||||||
th:href="${assets_link + '/css/related-posts-two.css' + theme_version}">
|
th:href="${assets_link + '/css/related-posts-two.css' + theme_version}">
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue