in toURL test for anchor links and if so prepend the currentPath to the generated path. fixes #142
This commit is contained in:
parent
e70327ab2b
commit
5af174bd20
1 changed files with 3 additions and 0 deletions
|
|
@ -66,11 +66,14 @@ export function parse (path = window.location.href) {
|
||||||
* @param {object} qs query params
|
* @param {object} qs query params
|
||||||
*/
|
*/
|
||||||
export function toURL (path, params) {
|
export function toURL (path, params) {
|
||||||
|
const inline = path[0] === '#';
|
||||||
const route = parse(replaceSlug(path))
|
const route = parse(replaceSlug(path))
|
||||||
|
|
||||||
route.query = merge({}, route.query, params)
|
route.query = merge({}, route.query, params)
|
||||||
path = route.path + stringifyQuery(route.query)
|
path = route.path + stringifyQuery(route.query)
|
||||||
path = path.replace(/\.md(\?)|\.md$/, '$1')
|
path = path.replace(/\.md(\?)|\.md$/, '$1')
|
||||||
|
|
||||||
|
if (inline) path = currentPath + path;
|
||||||
|
|
||||||
return cleanPath('#/' + path)
|
return cleanPath('#/' + path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue