修改slug处理首页网址的逻辑
This commit is contained in:
@@ -18,37 +18,9 @@ const pageFontSizeClass = computed(() => {
|
|||||||
return `text-${selectedFontSize.value}`
|
return `text-${selectedFontSize.value}`
|
||||||
})
|
})
|
||||||
|
|
||||||
// 根据路由参数构建内容路径
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
// URL 解码并验证路径
|
|
||||||
const queryPath = computed(() => {
|
|
||||||
try {
|
|
||||||
return decodeURIComponent(path.value);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('URL decode error:', error);
|
|
||||||
return path.value; // 如果解码失败,返回原始路径
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const { data: page } = await useAsyncData(
|
const { data: page } = await useAsyncData(
|
||||||
`page-${route.path}`, // 使用更具体的 key
|
`page-${route.path}`, // 使用更具体的 key
|
||||||
() => queryCollection('docs').path(queryPath.value).first(),
|
() => queryCollection('docs').path(decodeURI(route.path)).first(),
|
||||||
{
|
{
|
||||||
default: () => null // 提供默认值
|
default: () => null // 提供默认值
|
||||||
}
|
}
|
||||||
|
@@ -107,7 +107,7 @@ wow
|
|||||||
::
|
::
|
||||||
|
|
||||||
|
|
||||||
::button-link{icon="lucide:arrow-up-right" variant="outline" to="/getting-started" target="_blank" size="md"}
|
::button-link{icon="lucide:arrow-up-right" variant="outline" to="/ target="_blank" size="md"}
|
||||||
Get Started
|
Get Started
|
||||||
::
|
::
|
||||||
|
|
||||||
|
169
content/index.md
169
content/index.md
@@ -1,169 +0,0 @@
|
|||||||
---
|
|
||||||
seo:
|
|
||||||
title: Nuxt Docs Template
|
|
||||||
description: Nuxt UI Pro is a collection of premium Vue components built on top
|
|
||||||
of Nuxt UI to create beautiful & responsive Nuxt applications in minutes.
|
|
||||||
---
|
|
||||||
|
|
||||||
::u-page-hero
|
|
||||||
---
|
|
||||||
orientation: horizontal
|
|
||||||
---
|
|
||||||
:::prose-pre
|
|
||||||
---
|
|
||||||
code: npx nuxi init -t github:nuxt-ui-pro/docs
|
|
||||||
filename: Terminal
|
|
||||||
---
|
|
||||||
```bash
|
|
||||||
npx nuxi init -t github:nuxt-ui-pro/docs
|
|
||||||
```
|
|
||||||
:::
|
|
||||||
|
|
||||||
#title
|
|
||||||
Build your docs with Nuxt UI Pro
|
|
||||||
|
|
||||||
#description
|
|
||||||
Nuxt UI Pro is a collection of premium components built on top of Nuxt UI to create beautiful & responsive applications in minutes.
|
|
||||||
|
|
||||||
#links
|
|
||||||
:::u-button
|
|
||||||
---
|
|
||||||
size: xl
|
|
||||||
to: /getting-started
|
|
||||||
trailing-icon: lucide-arrow-right
|
|
||||||
---
|
|
||||||
Get started
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-button
|
|
||||||
---
|
|
||||||
color: neutral
|
|
||||||
icon: simple-icons-github
|
|
||||||
size: xl
|
|
||||||
target: _blank
|
|
||||||
to: https://github.com/nuxt-ui-pro/docs
|
|
||||||
variant: subtle
|
|
||||||
---
|
|
||||||
Use this template
|
|
||||||
:::
|
|
||||||
::
|
|
||||||
|
|
||||||
::u-page-section
|
|
||||||
#title
|
|
||||||
All-in-one documentation template
|
|
||||||
|
|
||||||
#links
|
|
||||||
:::u-button
|
|
||||||
---
|
|
||||||
color: neutral
|
|
||||||
size: lg
|
|
||||||
target: _blank
|
|
||||||
to: https://ui.nuxt.com/getting-started/installation/pro/nuxt
|
|
||||||
trailingIcon: lucide-arrow-right
|
|
||||||
variant: subtle
|
|
||||||
---
|
|
||||||
Discover Nuxt UI Pro v3
|
|
||||||
:::
|
|
||||||
|
|
||||||
#features
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: simple-icons-nuxt
|
|
||||||
target: _blank
|
|
||||||
to: https://nuxt.com
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
Nuxt 3
|
|
||||||
|
|
||||||
#description
|
|
||||||
Powered by Nuxt 3 for optimal performances and SEO.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: simple-icons-markdown
|
|
||||||
target: _blank
|
|
||||||
to: https://content.nuxt.com
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
Markdown
|
|
||||||
|
|
||||||
#description
|
|
||||||
Write your pages with MDC thanks to Nuxt Content.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: lucide-sparkles
|
|
||||||
target: _blank
|
|
||||||
to: https://ui.nuxt.com
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
Nuxt UI v3
|
|
||||||
|
|
||||||
#description
|
|
||||||
Offers a very large set of full customizable components.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: simple-icons-typescript
|
|
||||||
target: _blank
|
|
||||||
to: https://www.typescriptlang.org
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
TypeScript
|
|
||||||
|
|
||||||
#description
|
|
||||||
A fully typed development experience.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: simple-icons-nuxtdotjs
|
|
||||||
target: _blank
|
|
||||||
to: https://content.nuxt.com/docs/studio
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
Nuxt Studio
|
|
||||||
|
|
||||||
#description
|
|
||||||
Supported by Nuxt Studio for fast updates and previews.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::u-page-feature
|
|
||||||
---
|
|
||||||
icon: lucide-search
|
|
||||||
target: _blank
|
|
||||||
to: https://ui.nuxt.com/components/content-search
|
|
||||||
---
|
|
||||||
#title
|
|
||||||
Search
|
|
||||||
|
|
||||||
#description
|
|
||||||
A full-text search modal powered by Fuse.js.
|
|
||||||
:::
|
|
||||||
::
|
|
||||||
|
|
||||||
::u-page-section
|
|
||||||
:::u-page-c-t-a
|
|
||||||
---
|
|
||||||
links:
|
|
||||||
- label: Buy now
|
|
||||||
to: https://ui.nuxt.com/pro/purchase
|
|
||||||
target: _blank
|
|
||||||
icon: lucide-shopping-cart
|
|
||||||
color: neutral
|
|
||||||
- label: License
|
|
||||||
to: https://ui.nuxt.com/getting-started/license
|
|
||||||
trailingIcon: lucide-circle-help
|
|
||||||
target: _blank
|
|
||||||
color: neutral
|
|
||||||
variant: subtle
|
|
||||||
description: Nuxt UI Pro is free in development, but you need a license to use
|
|
||||||
it in production.
|
|
||||||
title: Start with Nuxt UI Pro today!
|
|
||||||
variant: subtle
|
|
||||||
---
|
|
||||||
:::
|
|
||||||
::
|
|
Reference in New Issue
Block a user