diff --git a/src/client/app/mixin.ts b/src/client/app/mixin.ts index fc6fbca7..7d1ddb4d 100644 --- a/src/client/app/mixin.ts +++ b/src/client/app/mixin.ts @@ -1,4 +1,5 @@ import { App } from 'vue' +import { joinPath } from './utils' import { SiteDataRef } from './composables/siteData' import { PageDataRef } from './composables/PageData' import { Content } from './components/Content' @@ -31,7 +32,7 @@ export function mixinGlobalComputed( $page: { get() { - return page + return page.value } }, @@ -51,6 +52,12 @@ export function mixinGlobalComputed( get() { return page.value.description || siteByRoute.value.description } + }, + + $withBase: { + value(path: string) { + return joinPath(site.value.base, path) + } } }) } diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 93a9674e..0509668a 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -1,5 +1,12 @@ export const inBrowser = typeof window !== 'undefined' +/** + * Join two paths by resolving the slash collision. + */ +export function joinPath(base: string, path: string): string { + return `${base}${path}`.replace(/\/+/g, '/') +} + /** * Converts a url path to the corresponding js chunk filename. */ diff --git a/src/client/theme-default/components/Home.vue b/src/client/theme-default/components/Home.vue index 370961f5..819f7787 100644 --- a/src/client/theme-default/components/Home.vue +++ b/src/client/theme-default/components/Home.vue @@ -2,7 +2,7 @@
@@ -39,7 +39,6 @@ diff --git a/src/client/theme-default/components/NavBarLink.vue b/src/client/theme-default/components/NavBarLink.vue index ab59f34b..b1667db7 100644 --- a/src/client/theme-default/components/NavBarLink.vue +++ b/src/client/theme-default/components/NavBarLink.vue @@ -16,8 +16,9 @@ -