-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
侧边栏最新文章显示与置顶文章冲突 #671
Comments
有啦,halo的14版本提供了该类api了终于😍 |
回头看看,上次2.14版本会议说的是2.15才出 |
@666ghj 看过了,2.14的文档里面没有相关api,你发来看看:https://docs.halo.run/developer-guide/theme/finder-apis/post |
This issue is stale because it has been open for 30 days with no activity. |
本来说2.15有api的,结果还是没有 |
🥹 |
我看了halo官方的api,我认为可以使用archives(page,size)或archives(page,size,year)来代替现在主题使用的list(page,size)。 list(page,size)的描述是:根据分页参数获取文章列表。 list,这里我理解为首页的文章列表,这里面的排列方式虽然也按时间顺序进行排列,但添加了一个优先级更高的条件,置顶。 archives(page,size)的描述是:根据分页参数获取文章归档列表。 archives(page,size,year)的描述是:根据年份和分页参数获取文章归档列表。 archives,这里我理解为归档的文章列表,这里面的排列方式只按时间进行排序,是不管是否置顶的。 使最新发布列表与归档列表(/archives)相同就行了,如下图所示。 思路仅供参考 |
如果置顶文章和最新文章在相同年份呢,这样还是没法获取实际想要的最新文章列表的 |
场景:有9篇文章,其中测试6{置顶}与置顶是已置顶的文章,其余的是正常文章,如下: 下面是完全复制**archives(page,size)**官方示例进行的修改 <div class="card-widget card-recent-post" th:with='posts = ${postFinder.archives(1,theme.config.sidebar.recentPost)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<div class="item-headline"><i class="haofont hao-icon-eicon_map-2-line1"></i><span>最近发布</span></div>
<div class="aside-list">
<!-- 修改处分界线 -->
<th:block th:with="archives = ${postFinder.archives(1,10)}">
<th:block th:each="archive : ${archives.items}">
<h1 th:text="${archive.year}"></h1>
<ul>
<th:block th:each="month : ${archive.months}">
<li th:each="post : ${month.posts}">
<a th:href="@{${post.status.permalink}}" th:text="${post.spec.title}">
</a>
</li>
</th:block>
</ul>
</th:block>
</th:block>
<!-- 修改处分界线 -->
</div>
</div> 结果: 测试6{置顶}与置顶在文章列表是正常排列的,在最近发布是按时间由近及远排序的,不受测试6{置顶}与置顶的置顶效果影响。(不会写样式,将就着哈!) 下面是未使用archives(page,size)的最近文章:可以看到置顶的优先级最高 |
@chengzhongxue 鱼,来活啦 |
这里是要改成最热门文章,而不是最新文章这样 |
侧边栏的“最新文章” |
下个版本更新 |
是什么版本出现了此问题?
hao版本:1.4.8
halo版本:2.12.4
在线站点地址
http://lovexl.top
发生了什么?
如在线站点地址中展示的,给部分文章添加置顶显示后,侧边栏的最新文章也会被置顶文章占用,从而导致无法显示真正的最新发布的文章
相关日志输出
No response
附加信息
No response
The text was updated successfully, but these errors were encountered: