diff --git a/lib/plugins/filter/post_permalink.ts b/lib/plugins/filter/post_permalink.ts index 141408d391..d924ecd9a0 100644 --- a/lib/plugins/filter/post_permalink.ts +++ b/lib/plugins/filter/post_permalink.ts @@ -35,6 +35,7 @@ function postPermalinkFilter(this: Hexo, data: PostSchema): string { second: date.format('ss'), i_month: date.format('M'), i_day: date.format('D'), + timestamp: date.format('X'), hash, category: config.default_category }; diff --git a/test/scripts/filters/post_permalink.ts b/test/scripts/filters/post_permalink.ts index dd530ab090..de9583eaa8 100644 --- a/test/scripts/filters/post_permalink.ts +++ b/test/scripts/filters/post_permalink.ts @@ -96,6 +96,22 @@ describe('post_permalink', () => { Post.removeById(post._id); }); + it('timestamp', async () => { + hexo.config.timezone = 'UTC'; + hexo.config.permalink = ':day/:hour/:timestamp/'; + const date = moment('2025-01-09 22:45:14'); + const timestamp = '1736433914'; + const post = await Post.insert({ + source: 'sub/test-timestamp-post.md', + slug: 'test-timestamp-post', + title: 'My New Post', + date: date + }); + postPermalink(post).should.eql(`09/22/${timestamp}/`); + Post.removeById(post._id); + hexo.config.timezone = ''; + }); + it('time is omitted in front-matter', async () => { hexo.config.permalink = ':year/:month/:day/:hour/:minute/:second/:post_title/';