Skip to content

Commit

Permalink
Merge pull request #1247 from WolfgangKluge/permalink-name-filter
Browse files Browse the repository at this point in the history
Add `:name` to the list of permalink filters
  • Loading branch information
tommy351 committed May 1, 2015
2 parents 57596a9 + c50d8fe commit 63bacf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/plugins/filter/post_permalink.js
Expand Up @@ -2,6 +2,7 @@

var _ = require('lodash');
var util = require('hexo-util');
var pathFn = require('path');
var Permalink = util.Permalink;
var permalink;

Expand All @@ -11,6 +12,7 @@ function postPermalinkFilter(data){
var meta = {
id: data.id || data._id,
title: data.slug,
name: pathFn.basename(data.slug),
year: data.date.format('YYYY'),
month: data.date.format('MM'),
day: data.date.format('DD'),
Expand Down
13 changes: 13 additions & 0 deletions test/scripts/filters/post_permalink.js
Expand Up @@ -70,4 +70,17 @@ describe('post_permalink', function(){

hexo.config.permalink = PERMALINK;
});

it('name', function(){
hexo.config.permalink = ':title/:name';

return Post.insert({
source: 'sub/bar.md',
slug: 'sub/bar'
}).then(function(post){
postPermalink(post).should.eql('sub/bar/bar');
hexo.config.permalink = PERMALINK;
return Post.removeById(post._id);
});
});
});

0 comments on commit 63bacf2

Please sign in to comment.