Hexo-theme-next: 如何置顶post?

Created on 12 Oct 2015  ·  34Comments  ·  Source: iissnan/hexo-theme-next

有没有办法置顶post?

我目前把日志的时间改成2222.10.10, 有没有什么属性可以在post里申明一下然后不用修改date的办法置顶?

4 - Done Enhancement Template v6.x

Most helpful comment

最新修订( f4a08bffed0 ) 已支持置顶 Post 功能。使用方式是利用 Front-matter,在 Post 里新增 sticky,设定值是数值。值越高,顺序就越靠前;无 sticky 的 Post,其 sticky 值为 0。例如

# Post foo.md
title: foo
sticky: 1

# Post bar.md
title: bar
sticky: 10

这两篇 Post 都将显示在前,并且 bar.md 在先。需要注意的是,置顶仅在首页有效。

All 34 comments

通过 front-matter 结合模板可以做到

好的,谢谢
刚试了,还是没有置顶
2015-10-20 2:38 GMT-04:00 晨光为曦 [email protected]:

我在文章front-matter 中加了,好像可以

top: true


Reply to this email directly or view it on GitHub
https://github.com/iissnan/hexo-theme-next/issues/415#issuecomment-149449075
.

试了 top: true 也不行诶?
是我用错了么...

没用错。我没做 置顶 的功能。。。

好吧 @iissnan 有计划做么

@AlanCheen

Label 是 enhancement 的都有计划做

@iissnan 好的 等你好消息

最新修订( f4a08bffed0 ) 已支持置顶 Post 功能。使用方式是利用 Front-matter,在 Post 里新增 sticky,设定值是数值。值越高,顺序就越靠前;无 sticky 的 Post,其 sticky 值为 0。例如

# Post foo.md
title: foo
sticky: 1

# Post bar.md
title: bar
sticky: 10

这两篇 Post 都将显示在前,并且 bar.md 在先。需要注意的是,置顶仅在首页有效。

谢谢更新: )

2015年10月29日星期四,Vi [email protected] 写道:

最新修订( f4a08bf
https://github.com/iissnan/hexo-theme-next/commit/f4a08bffed0d7dbc0ab8ef643295f5f0c8b75453
) 已支持置顶 Post 功能。使用方式是利用 Front-matter,在 Post 里新增 sticky,设定值是数值。值越高,顺序就越靠前;无
sticky 的 Post,其 sticky 值为 0。例如

Post foo.md

title: foo
sticky: 1

Post bar.md

title: bar
sticky: 10

这两篇 Post 都将显示在前,并且 bar.md 在先。需要注意的是,置顶仅在首页有效。


Reply to this email directly or view it on GitHub
https://github.com/iissnan/hexo-theme-next/issues/415#issuecomment-152378542
.

另外,此功能要求 Hexo 的版本至少是 3.0.0

已知置顶功能会导致一个问题:在文章被修改后,通过 hexo s 本地搭建的 server 无法得到最新的内容,必须重启 server 才能拿到新内容。正在解决中。

首页隐藏文章 在 Post 里新增 show
然后通过hide控制,这样可以加上去吗?

{% if post.show !== 'hide' %}
    {{ post_template.render(post, true) }}
{% endif %}

@imyip 开个新 issue 吧,针对新增的内容,比较容易跟踪。

@iissnan 好的

为什么加了sticky选项还是不能置顶。。

hexo: 3.1.1
os: Linux 3.16.0-38-generic linux x64
http_parser: 2.3
node: 0.12.4
v8: 3.28.71.19
uv: 1.5.0
zlib: 1.2.8
modules: 14
openssl: 1.0.1m

好吧。。原来是next主题才行。。

你好,我是next主题,但是加了sticky还是不能置顶。
hexo: 3.1.1
os: Linux 3.13.0-66-generic linux x64
http_parser: 2.5.0
node: 4.2.4
v8: 4.5.103.35
uv: 1.7.5
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 56.1
modules: 46
openssl: 1.0.2e

同样不能置顶。。问题是似乎偶现,刷新几次然后就置顶了。。。

你好,置顶功能在本地刷新几遍可以出现,但是上传到github上之后,deploy后外网无法看到置顶效果。

我将 “置顶” 功能去掉了,我猜测在开发这个功能时引入的 sticky filter 导致了生成站点时只有一篇文章的 bug(#594, #690 , #656 , #683, #645, #628 )。

希望 Hexo 能够提供此功能。

@iissnan post.swig line 19 (if page.posts.first().sticky >= 0),只有每一篇的sticky大于或等于0才会优先渲染置顶帖。如果最近一篇Post没有设置sticky,且置顶不工作。另外posts_normal = page.posts.find({sticky: 0}),这会造成未设置sticky的Post不会被渲染。如果将无sticky值的post的sticy值默认设置为0,则这两个问题都不存在。但通过搜索发现,源码中并未设置默认值。
所以希望能加入将sticky值设置为0的代码
word around方法是手动将不需要置顶的post的sticy值设置为0

@iissnan 这个适用于Hexo 3.*

@netcan 谢谢。
@habren 我抽空看看

@iissnan 请问在目前的最新版还是不支持置顶吗?我加了sticky: 10后只会在该帖上显示置顶图标,不会置顶(hexo clean ; hexo s后也是)

请问在目前的最新版还是不支持置顶吗

我目前用的是3.2.2版本,好像暂时还不能置顶。但是通过改大时间还是可以实现置顶的。

2017-01-26 18:46 GMT+08:00 nickylin notifications@github.com:

请问在目前的最新版还是不支持置顶吗


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/iissnan/hexo-theme-next/issues/415#issuecomment-275359250,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARZRHfqecf_4d33QBkFPG1S5s-yCjgrUks5rWHmTgaJpZM4GNRtH
.

@Yggdrasilqh @nickylin 可以看看我的方案。
https://github.com/iissnan/hexo-theme-next/issues/415#issuecomment-193756827

@netcan 多篇 会有bug,置顶一篇 的确可以的

@netcan 完美!是因为 Hexo版本过低导致的,目前升级到 3.3.1就没有问题!感谢大神~

要怎么改 才能顺带上 置顶两个字呢,不然乍一看 以为博客 一年多没更新了~~ http://yuzhouwan.com/

NexT is rebased into organization repo.
If you want new feature, fix, or support, create new in NexT v6.x repo (desirable in English).

There is instructions on English or Chinese how to update from v5.1.x to v 6.x

You also may read this for details.

Issue moved here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwwangchn picture jwwangchn  ·  3Comments

chy9002 picture chy9002  ·  3Comments

liyuan989 picture liyuan989  ·  3Comments

aiplay picture aiplay  ·  4Comments

syscca picture syscca  ·  4Comments