File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ module.exports = function(ctx) {
58
58
var self = _ . assign ( { } , ctx . extend . helper . list ( ) , ctx ) ;
59
59
var config = ctx . config ;
60
60
var partial_url = self . url_for ( this . path ) ;
61
+ if ( config . relative_link ) partial_url = '/' + partial_url ;
61
62
return config . url + _ . replace ( partial_url , config . root , '/' ) ;
62
63
} ) ;
63
64
Original file line number Diff line number Diff line change @@ -83,6 +83,18 @@ describe('Post', () => {
83
83
} ) ;
84
84
} ) ;
85
85
86
+ it ( 'permalink - virtual - when set relative_link' , ( ) => {
87
+ hexo . config . root = '/' ;
88
+ hexo . config . relative_link = true ;
89
+ return Post . insert ( {
90
+ source : 'foo.md' ,
91
+ slug : 'bar'
92
+ } ) . then ( data => {
93
+ data . permalink . should . eql ( hexo . config . url + '/' + data . path ) ;
94
+ return Post . removeById ( data . _id ) ;
95
+ } ) ;
96
+ } ) ;
97
+
86
98
it ( 'permalink_root_prefix - virtual' , ( ) => {
87
99
hexo . config . url = 'http://yoursite.com/root' ;
88
100
hexo . config . root = '/root/' ;
@@ -95,6 +107,19 @@ describe('Post', () => {
95
107
} ) ;
96
108
} ) ;
97
109
110
+ it ( 'permalink_root_prefix - virtual - when set relative_link' , ( ) => {
111
+ hexo . config . url = 'http://yoursite.com/root' ;
112
+ hexo . config . root = '/root/' ;
113
+ hexo . config . relative_link = true ;
114
+ return Post . insert ( {
115
+ source : 'foo.md' ,
116
+ slug : 'bar'
117
+ } ) . then ( data => {
118
+ data . permalink . should . eql ( hexo . config . url + '/' + data . path ) ;
119
+ return Post . removeById ( data . _id ) ;
120
+ } ) ;
121
+ } ) ;
122
+
98
123
it ( 'full_source - virtual' , ( ) => Post . insert ( {
99
124
source : 'foo.md' ,
100
125
slug : 'bar'
You can’t perform that action at this time.
0 commit comments