改回项目内获取md文档
This commit is contained in:
@@ -67,7 +67,9 @@ const handleLoginRegister = (type: 'login' | 'register') => {
|
||||
</template>
|
||||
|
||||
<template #right>
|
||||
<UContentSearchButton class="lg:hidden" />
|
||||
<ClientOnly>
|
||||
<UContentSearchButton class="lg:hidden" />
|
||||
</ClientOnly>
|
||||
<UColorModeButton />
|
||||
<button
|
||||
class=" p-2 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
||||
|
@@ -5,8 +5,12 @@ const route = useRoute()
|
||||
const toast = useToast()
|
||||
const { copy, copied } = useClipboard()
|
||||
|
||||
const mdcLink = computed(() => `${window?.location?.origin}${decodeURIComponent(route.path)}`)
|
||||
const markdownLink = computed(() => `${window?.location?.origin}/raw${decodeURIComponent(route.path)}.md`)
|
||||
// SSR 安全:不要直接使用 window,改用 useRequestURL().origin
|
||||
const requestURL = useRequestURL()
|
||||
const origin = computed(() => requestURL.origin)
|
||||
|
||||
const mdcLink = computed(() => `${origin.value}${decodeURIComponent(route.path)}`)
|
||||
const markdownLink = computed(() => `${origin.value}/raw${decodeURIComponent(route.path)}.md`)
|
||||
|
||||
const items = [
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ const queryPath = computed(() => {
|
||||
|
||||
const { data: page } = await useAsyncData(
|
||||
`page-${route.path}`, // 使用更具体的 key
|
||||
() => queryCollection('docs').path(decodeURIComponent(path.value)).first(),
|
||||
() => queryCollection('docs').path(queryPath.value).first(),
|
||||
{
|
||||
default: () => null // 提供默认值
|
||||
}
|
||||
@@ -43,8 +43,7 @@ if (!page.value) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: '文档不存在',
|
||||
message: `当前页面不存在,请您检查路径是否正确: ${queryPath.value}`,
|
||||
fatal: true
|
||||
message: `当前页面不存在,请您检查路径是否正确: ${queryPath.value}`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -64,7 +63,10 @@ useSeoMeta({
|
||||
ogDescription: description
|
||||
})
|
||||
|
||||
const headline = computed(() => findPageHeadline(navigation?.value, page.value))
|
||||
const headline = computed(() => {
|
||||
if (!navigation?.value || !page.value) return undefined
|
||||
return findPageHeadline(navigation.value, page.value)
|
||||
})
|
||||
|
||||
defineOgImageComponent('Docs', {
|
||||
headline: headline.value
|
||||
|
Reference in New Issue
Block a user