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

如何置顶post? #415

Open
JSSU opened this Issue Oct 12, 2015 · 33 comments

Comments

Projects
None yet
@JSSU
Copy link

JSSU commented Oct 12, 2015

有没有办法置顶post?

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

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 18, 2015

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

@JSSU

This comment has been minimized.

Copy link

JSSU commented Oct 20, 2015

好的,谢谢
刚试了,还是没有置顶
2015-10-20 2:38 GMT-04:00 晨光为曦 notifications@github.com:

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

top: true


Reply to this email directly or view it on GitHub
#415 (comment)
.

@AlanCheen

This comment has been minimized.

Copy link

AlanCheen commented Oct 24, 2015

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

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 26, 2015

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

@AlanCheen

This comment has been minimized.

Copy link

AlanCheen commented Oct 26, 2015

好吧 @iissnan 有计划做么

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 26, 2015

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 26, 2015

Label 是 enhancement 的都有计划做

@AlanCheen

This comment has been minimized.

Copy link

AlanCheen commented Oct 26, 2015

@iissnan 好的 等你好消息

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 30, 2015

最新修订( f4a08bf ) 已支持置顶 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 在先。需要注意的是,置顶仅在首页有效。

@JSSU

This comment has been minimized.

Copy link

JSSU commented Oct 30, 2015

谢谢更新: )

2015年10月29日星期四,Vi notifications@github.com 写道:

最新修订( f4a08bf
f4a08bf
) 已支持置顶 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
#415 (comment)
.

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 30, 2015

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

@iissnan iissnan added 4 - Done and removed 2 - Working <= 5 labels Oct 30, 2015

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 30, 2015

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

@imyip

This comment has been minimized.

Copy link

imyip commented Oct 30, 2015

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

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

This comment has been minimized.

Copy link
Owner

iissnan commented Oct 30, 2015

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

@imyip

This comment has been minimized.

Copy link

imyip commented Oct 30, 2015

@iissnan 好的

@netcan

This comment has been minimized.

Copy link

netcan commented Nov 22, 2015

为什么加了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
@netcan

This comment has been minimized.

Copy link

netcan commented Nov 22, 2015

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

@andyli386

This comment has been minimized.

Copy link

andyli386 commented Jan 22, 2016

你好,我是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

@callmewhy

This comment has been minimized.

Copy link

callmewhy commented Jan 25, 2016

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

@kintsuicris

This comment has been minimized.

Copy link

kintsuicris commented Feb 29, 2016

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

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Mar 1, 2016

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

希望 Hexo 能够提供此功能。

@habren

This comment has been minimized.

Copy link

habren commented Mar 6, 2016

@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

@netcan

This comment has been minimized.

Copy link

netcan commented Mar 8, 2016

我这有个通用的置顶方案,需要修改插件。
http://www.netcan666.com/2015/11/22/%E8%A7%A3%E5%86%B3Hexo%E7%BD%AE%E9%A1%B6%E9%97%AE%E9%A2%98/

@habren

This comment has been minimized.

Copy link

habren commented Mar 8, 2016

@iissnan 这个适用于Hexo 3.*

@iissnan

This comment has been minimized.

Copy link
Owner

iissnan commented Mar 9, 2016

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

@Yggdrasilqh

This comment has been minimized.

Copy link

Yggdrasilqh commented Jan 17, 2017

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

@nickylin

This comment has been minimized.

Copy link

nickylin commented Jan 26, 2017

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

@Yggdrasilqh

This comment has been minimized.

Copy link

Yggdrasilqh commented Feb 6, 2017

@netcan

This comment has been minimized.

Copy link

netcan commented Feb 6, 2017

@Yggdrasilqh @nickylin 可以看看我的方案。
#415 (comment)

@asdf2014

This comment has been minimized.

Copy link

asdf2014 commented Apr 9, 2017

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

@asdf2014

This comment has been minimized.

Copy link

asdf2014 commented Apr 9, 2017

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

@asdf2014

This comment has been minimized.

Copy link

asdf2014 commented Apr 9, 2017

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

@ivan-nginx

This comment has been minimized.

Copy link
Collaborator

ivan-nginx commented Apr 19, 2018

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.

Repository owner locked and limited conversation to collaborators Apr 19, 2018

@ivan-nginx ivan-nginx added the v6.x label Apr 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.