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 bc7ca19 commit a11d7dbCopy full SHA for a11d7db
lib/models/post.js
@@ -47,7 +47,8 @@ module.exports = function(ctx) {
47
});
48
49
Post.virtual('permalink').get(function() {
50
- return ctx.config.url + '/' + this.path;
+ var url_for = ctx.extend.helper.get('url_for');
51
+ return ctx.config.url + url_for.call(ctx, this.path);
52
53
54
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,7 @@ describe('Post', function() {
77
78
79
it('permalink - virtual', function() {
80
+ hexo.config.root = '/';
81
return Post.insert({
82
source: 'foo.md',
83
slug: 'bar'
@@ -86,6 +87,17 @@ describe('Post', function() {
86
87
88
89
90
+ it('permalink_prefix - virtual', function() {
91
+ hexo.config.root = '/root/';
92
+ return Post.insert({
93
+ source: 'foo.md',
94
+ slug: 'bar'
95
+ }).then(function(data) {
96
+ data.permalink.should.eql(hexo.config.url + '/root/' + data.path);
97
+ return Post.removeById(data._id);
98
+ });
99
100
+
101
it('full_source - virtual', function() {
102
103
0 commit comments