From 95d6cda15e43198a7e8116ad30561ca280fe2976 Mon Sep 17 00:00:00 2001 From: Link1515 Date: Sun, 10 May 2026 17:36:27 +0800 Subject: [PATCH] refactor: simplify locale content path normalization --- app/composables/useLocaleContent.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/composables/useLocaleContent.ts b/app/composables/useLocaleContent.ts index bd364fa..68bad42 100644 --- a/app/composables/useLocaleContent.ts +++ b/app/composables/useLocaleContent.ts @@ -1,20 +1,13 @@ import type { Collections } from '@nuxt/content' import { withLeadingSlash, withoutTrailingSlash } from 'ufo' -function normalizeContentPath(path: string) { - if (!path || path === '/') { - return '/' - } - - return withoutTrailingSlash(withLeadingSlash(path)) -} - export default async function useLocaleContent( - path: MaybeRefOrGetter, + _path: MaybeRefOrGetter, locale: Ref, defaultLocale: string, ) { - const normalizedPath = computed(() => normalizeContentPath(toValue(path))) + const path = toValue(_path) + const normalizedPath = computed(() => withoutTrailingSlash(withLeadingSlash(path))) const asyncDataKey = `page-${locale.value}-${normalizedPath.value}` const { data: content } = await useAsyncData(asyncDataKey, async () => {