Skip to content

Commit

Permalink
Merge pull request #1258 from nt3rp/permalink_postname
Browse files Browse the repository at this point in the history
Add new permalink param: `post_title`
  • Loading branch information
tommy351 committed May 7, 2015
2 parents eff1429 + 054b2b4 commit d531c10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/plugins/filter/post_permalink.js
Expand Up @@ -13,6 +13,7 @@ function postPermalinkFilter(data){
id: data.id || data._id,
title: data.slug,
name: pathFn.basename(data.slug),
post_title: util.slugize(data.title, {transform: 1}),
year: data.date.format('YYYY'),
month: data.date.format('MM'),
day: data.date.format('DD'),
Expand Down
15 changes: 15 additions & 0 deletions test/scripts/filters/post_permalink.js
Expand Up @@ -83,4 +83,19 @@ describe('post_permalink', function(){
return Post.removeById(post._id);
});
});

it('post_title', function(){
hexo.config.permalink = ':year/:month/:day/:post_title/';

return Post.insert({
source: 'sub/2015-05-06-my-new-post.md',
slug: '2015-05-06-my-new-post',
title: 'My New Post',
date: moment('2015-05-06')
}).then(function(post){
postPermalink(post).should.eql('2015/05/06/my-new-post/');
hexo.config.permalink = PERMALINK;
return Post.removeById(post._id);
});
});
});

0 comments on commit d531c10

Please sign in to comment.