We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ad77fe commit 69a0e2eCopy full SHA for 69a0e2e
lib/models/post.js
@@ -49,7 +49,8 @@ module.exports = function(ctx){
49
});
50
51
Post.virtual('permalink').get(function(){
52
- return ctx.config.url + '/' + this.path;
+ var url_for = ctx.extend.helper.get('url_for');
53
+ return ctx.config.url + url_for.call(ctx, this.path);
54
55
56
Post.virtual('full_source').get(function(){
test/scripts/helpers/list_archives.js
@@ -22,12 +22,14 @@ describe('list_archives', function(){
22
}
23
24
before(function(){
25
- return Post.insert([
26
- {source: 'foo', slug: 'foo', date: new Date(2014, 1, 2)},
27
- {source: 'bar', slug: 'bar', date: new Date(2013, 5, 6)},
28
- {source: 'baz', slug: 'baz', date: new Date(2013, 9, 10)},
29
- {source: 'boo', slug: 'boo', date: new Date(2013, 5, 8)}
30
- ]).then(function(){
+ return hexo.init().then(function(){
+ return Post.insert([
+ {source: 'foo', slug: 'foo', date: new Date(2014, 1, 2)},
+ {source: 'bar', slug: 'bar', date: new Date(2013, 5, 6)},
+ {source: 'baz', slug: 'baz', date: new Date(2013, 9, 10)},
+ {source: 'boo', slug: 'boo', date: new Date(2013, 5, 8)}
31
+ ]);
32
+ }).then(function(){
33
resetLocals();
34
35
test/scripts/helpers/list_categories.js
@@ -18,12 +18,14 @@ describe('list_categories', function(){
18
var listCategories = require('../../../lib/plugins/helper/list_categories').bind(ctx);
19
20
21
- {source: 'foo', slug: 'foo'},
- {source: 'bar', slug: 'bar'},
- {source: 'baz', slug: 'baz'},
- {source: 'boo', slug: 'boo'}
- ]).then(function(posts){
+ {source: 'foo', slug: 'foo'},
+ {source: 'bar', slug: 'bar'},
+ {source: 'baz', slug: 'baz'},
+ {source: 'boo', slug: 'boo'}
+ }).then(function(posts){
return Promise.each([
['baz'],
['baz', 'bar'],
test/scripts/helpers/list_posts.js
@@ -18,12 +18,12 @@ describe('list_posts', function(){
hexo.config.permalink = ':title/';
- {source: 'foo', slug: 'foo', title: 'Its', date: 1e8},
- {source: 'bar', slug: 'bar', title: 'Chemistry', date: 1e8 + 1},
- {source: 'baz', slug: 'baz', title: 'Bitch', date: 1e8 - 1}
- return hexo.init();
+ {source: 'foo', slug: 'foo', title: 'Its', date: 1e8},
+ {source: 'bar', slug: 'bar', title: 'Chemistry', date: 1e8 + 1},
+ {source: 'baz', slug: 'baz', title: 'Bitch', date: 1e8 - 1}
}).then(function(){
hexo.locals.invalidate();
ctx.site = hexo.locals.toObject();
test/scripts/helpers/list_tags.js
@@ -18,12 +18,14 @@ describe('list_tags', function(){
var listTags = require('../../../lib/plugins/helper/list_tags').bind(ctx);
// TODO: Warehouse needs to add a mutex lock when writing data to avoid data sync problem
['foo'],
test/scripts/helpers/tagcloud.js
@@ -18,12 +18,14 @@ describe('tagcloud', function(){
var tagcloud = require('../../../lib/plugins/helper/tagcloud').bind(ctx);
['bcd'],
test/scripts/models/post.js
@@ -77,6 +77,15 @@ describe('Post', function(){
77
78
79
it('permalink - virtual', function(){
80
+ hexo.config.root = '/root/';
81
+ return Post.insert({
82
+ source: 'foo.md',
83
+ slug: 'bar'
84
+ }).then(function(data){
85
+ data.permalink.should.eql(hexo.config.url + '/root/' + data.path);
86
+ return Post.removeById(data._id);
87
+ });
88
+ hexo.config.root = '/';
89
return Post.insert({
90
source: 'foo.md',
91
slug: 'bar'
0 commit comments