File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -114,13 +114,20 @@ function copyImages (src, dest) {
114
114
. pipe ( map ( ( file , enc , next ) => next ( ) ) )
115
115
}
116
116
117
- function relativize ( to , { data } ) {
117
+ function relativize ( to , { data : { root } } ) {
118
118
if ( ! to ) return '#'
119
119
if ( to . charAt ( ) !== '/' ) return to
120
- const from = data . root . page . url
120
+ const from = root . page . url
121
+ if ( ! from ) return ( root . site . path || '' ) + to
122
+ let hash = ''
121
123
const hashIdx = to . indexOf ( '#' )
122
- if ( ~ hashIdx && to . substr ( 0 , hashIdx ) === from ) return to . substr ( hashIdx )
123
- return to . substr ( 1 )
124
+ if ( ~ hashIdx ) {
125
+ hash = to . substr ( hashIdx )
126
+ to = to . substr ( 0 , hashIdx )
127
+ }
128
+ return to === from
129
+ ? hash || ( to . charAt ( to . length - 1 ) === '/' ? './' : path . basename ( to ) )
130
+ : ( path . relative ( path . dirname ( from + '.' ) , to ) || '.' ) + ( to . charAt ( to . length - 1 ) === '/' ? '/' + hash : hash )
124
131
}
125
132
126
133
function resolvePage ( spec , context = { } ) {
You can’t perform that action at this time.
0 commit comments