From 2ee78f1faf5a617d0672b631769869a7d65be7d7 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sat, 30 Dec 2023 13:29:37 +0900 Subject: [PATCH] fix proseA --- components/content/ProseA.vue | 3 ++- pages/docs/[...slug].vue | 4 ++++ types/router.d.ts | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) 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