diff --git a/components/content/ProseA.vue b/components/content/ProseA.vue index df4c3cf7..e45cae96 100644 --- a/components/content/ProseA.vue +++ b/components/content/ProseA.vue @@ -7,6 +7,7 @@ import { isLocalPath, sanitizeInternalPath } from '@/assets/js/misc'; const runtimeConfig = useRuntimeConfig(); const rootDomain = parseURL(runtimeConfig.public.baseUrl); const { resolve } = useRouter(); +const route = useRoute(); const localePath = useGLocalePath(); const props = defineProps({ @@ -28,7 +29,7 @@ const url = parseURL(realHref.value); if (isLocalPath(realHref.value)) { // 相対パスの場合(trailing slashがあるので1つくり下げる) - if (isRelative(realHref.value)) { + if (isRelative(realHref.value) && route.meta.__isDocsIndexPage !== true) { realHref.value = joinURL('../', realHref.value.replace(/^\.\//, '')); } diff --git a/pages/docs/[...slug].vue b/pages/docs/[...slug].vue index 48060b2f..adb7416c 100644 --- a/pages/docs/[...slug].vue +++ b/pages/docs/[...slug].vue @@ -70,6 +70,10 @@ if (!data.value) { throw createError({ statusCode: 404, statusMessage: 'page not found', fatal: true }); } +if (data.value._path && /index\.[a-z]+$/.test(data.value._path)) { + route.meta.__isDocsIndexPage = true; +} + route.meta.title = data.value?.title; if (data.value.description) { route.meta.description = data.value.description; diff --git a/types/router.d.ts b/types/router.d.ts index 7d8b3026..093bad8f 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -17,5 +17,8 @@ declare module 'vue-router' { }; customClass?: string; }; + + /** @private */ + __isDocsIndexPage?: boolean; } } \ No newline at end of file