hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.63k stars 4.87k forks source link

is_post() always return true when permalink is `:title/` #1206

Closed leesei closed 9 years ago

leesei commented 9 years ago

http://hexo.io/docs/helpers.html#is_post

I believe is_post() should return true only if we are at a page rendered from source.

But if we set

permalink: :title/

then the regex in is_post()(lib/plugins/helper/is.js#L40-58) is /[^\/]+\// which yields true for practically all URLs with trailing / (including /tags/foo).

Is this a bug or by design?

iissnan commented 9 years ago

It should be a bug.

maroun-baydoun commented 9 years ago

Having similar issue. I used the is_post() helper function in my layout to change some styling, but all the generated html files were treated as if is_post() is true, even home page, categories page...

leesei commented 9 years ago

This should be fixed by commit 62f521b.