feat: upgrade sidebar, remove header, upgrade search

This commit is contained in:
Justineo
2021-07-19 16:27:38 +08:00
parent a9d349aed1
commit fe6f5376a9
14 changed files with 726 additions and 632 deletions

View File

@@ -8,19 +8,17 @@ export default function attacher () {
return (tree, { path }) => {
let localPath = `/${relative(DOCS_DIR, path)}`
let [, locale] = localPath.match(RE_LOCALE) || []
if (!locale) {
return
}
visit(tree, 'element', node => {
let { tagName, properties, properties: { href } } = node
let { tagName, properties: { href, ...props } } = node
if (tagName !== 'a' || href.match(/^\w+:\/\//)) {
return
}
if (locale && href.indexOf('/') === 0) {
properties.href = `/${locale}${href}`
}
let routePath = locale && href.indexOf('/') === 0 ? `/${locale}${href}` : href
node.tagName = 'nuxt-link'
node.properties = { ...props, to: routePath }
})
}
}