feat: make relative links root absolute option
This commit is contained in:
parent
661b6044fa
commit
edd11cd73f
@ -5,4 +5,10 @@ author: requarks.io
|
|||||||
input: html
|
input: html
|
||||||
output: html
|
output: html
|
||||||
icon: mdi-language-html5
|
icon: mdi-language-html5
|
||||||
props: {}
|
props:
|
||||||
|
absoluteLinks:
|
||||||
|
type: Boolean
|
||||||
|
default: false
|
||||||
|
title: Treat relative links as root absolute
|
||||||
|
hint: For example, a link to foo/bar on page xyz will render as /foo/bar instead of /xyz/foo/bar.
|
||||||
|
order: 1
|
||||||
|
@ -69,7 +69,11 @@ module.exports = {
|
|||||||
if (WIKI.config.lang.namespacing) {
|
if (WIKI.config.lang.namespacing) {
|
||||||
// -> Reformat paths
|
// -> Reformat paths
|
||||||
if (href.indexOf('/') !== 0) {
|
if (href.indexOf('/') !== 0) {
|
||||||
href = (this.page.path === 'home') ? `/${this.page.localeCode}/${href}` : `/${this.page.localeCode}/${this.page.path}/${href}`
|
if (this.config.absoluteLinks) {
|
||||||
|
href = `/${this.page.localeCode}/${href}`
|
||||||
|
} else {
|
||||||
|
href = (this.page.path === 'home') ? `/${this.page.localeCode}/${href}` : `/${this.page.localeCode}/${this.page.path}/${href}`
|
||||||
|
}
|
||||||
} else if (href.charAt(3) !== '/') {
|
} else if (href.charAt(3) !== '/') {
|
||||||
href = `/${this.page.localeCode}${href}`
|
href = `/${this.page.localeCode}${href}`
|
||||||
}
|
}
|
||||||
@ -83,7 +87,11 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
// -> Reformat paths
|
// -> Reformat paths
|
||||||
if (href.indexOf('/') !== 0) {
|
if (href.indexOf('/') !== 0) {
|
||||||
href = (this.page.path === 'home') ? `/${href}` : `/${this.page.path}/${href}`
|
if (this.config.absoluteLinks) {
|
||||||
|
href = `/${href}`
|
||||||
|
} else {
|
||||||
|
href = (this.page.path === 'home') ? `/${href}` : `/${this.page.path}/${href}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user