完成目录架构变更
This commit is contained in:
@@ -19,21 +19,7 @@ const pageFontSizeClass = computed(() => {
|
||||
})
|
||||
|
||||
// 根据路由参数构建内容路径
|
||||
const path = computed(() => {
|
||||
const slug = route.params.slug
|
||||
|
||||
// 处理 slug 参数
|
||||
if (!slug) {
|
||||
return '/' // 如果没有 slug,返回根路径
|
||||
}
|
||||
|
||||
const pathValue = Array.isArray(slug) ? slug.join('/') : slug
|
||||
|
||||
// 确保路径以 / 开头,不以 / 结尾
|
||||
const normalizedPath = `/${pathValue}`.replace(/\/+$/, '') // 使用 /+ 匹配多个连续的斜杠
|
||||
|
||||
return normalizedPath
|
||||
})
|
||||
const path = computed(() => route.path)
|
||||
|
||||
// URL 解码并验证路径
|
||||
const queryPath = computed(() => {
|
||||
@@ -47,7 +33,7 @@ const queryPath = computed(() => {
|
||||
|
||||
const { data: page } = await useAsyncData(
|
||||
`page-${route.path}`, // 使用更具体的 key
|
||||
() => queryCollection('docs').path(queryPath.value).first(),
|
||||
() => queryCollection('docs').path(decodeURIComponent(path.value)).first(),
|
||||
{
|
||||
default: () => null // 提供默认值
|
||||
}
|
Reference in New Issue
Block a user