docus 4.0.0-beta.13 → 4.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,6 @@ const { copy, copied } = useClipboard()
|
|
|
7
7
|
const { t } = useDocusI18n()
|
|
8
8
|
|
|
9
9
|
const markdownLink = computed(() => `${window?.location?.origin}/raw${route.path}.md`)
|
|
10
|
-
|
|
11
10
|
const items = [
|
|
12
11
|
{
|
|
13
12
|
label: 'Copy Markdown link',
|
|
@@ -41,6 +40,11 @@ const items = [
|
|
|
41
40
|
to: `https://claude.ai/new?q=${encodeURIComponent(`Read ${markdownLink.value} so I can ask questions about it.`)}`,
|
|
42
41
|
},
|
|
43
42
|
]
|
|
43
|
+
|
|
44
|
+
async function copyPage() {
|
|
45
|
+
const page = await $fetch<string>(`/raw${route.path}.md`)
|
|
46
|
+
copy(page)
|
|
47
|
+
}
|
|
44
48
|
</script>
|
|
45
49
|
|
|
46
50
|
<template>
|
|
@@ -53,7 +57,7 @@ const items = [
|
|
|
53
57
|
:ui="{
|
|
54
58
|
leadingIcon: [copied ? 'text-primary' : 'text-neutral', 'size-3.5'],
|
|
55
59
|
}"
|
|
56
|
-
@click="
|
|
60
|
+
@click="copyPage"
|
|
57
61
|
/>
|
|
58
62
|
|
|
59
63
|
<UDropdownMenu
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { withLeadingSlash } from 'ufo'
|
|
2
2
|
import { stringify } from 'minimark/stringify'
|
|
3
3
|
import { queryCollection } from '@nuxt/content/nitro'
|
|
4
|
+
import type { Collections } from '@nuxt/content'
|
|
4
5
|
|
|
5
6
|
export default eventHandler(async (event) => {
|
|
6
7
|
const slug = getRouterParams(event)['slug.md']
|
|
@@ -9,7 +10,26 @@ export default eventHandler(async (event) => {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const path = withLeadingSlash(slug.replace('.md', ''))
|
|
12
|
-
const
|
|
13
|
+
const config = useRuntimeConfig(event).public
|
|
14
|
+
|
|
15
|
+
let collectionName = 'docs'
|
|
16
|
+
if (config.i18n?.locales) {
|
|
17
|
+
const pathSegments = path.split('/').filter(Boolean)
|
|
18
|
+
const firstSegment = pathSegments[0]
|
|
19
|
+
|
|
20
|
+
const availableLocales = config.i18n.locales.map((locale: string | { code: string }) =>
|
|
21
|
+
typeof locale === 'string' ? locale : locale.code,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
if (firstSegment && availableLocales.includes(firstSegment)) {
|
|
25
|
+
collectionName = `docs_${firstSegment}`
|
|
26
|
+
}
|
|
27
|
+
else if (config.i18n.defaultLocale) {
|
|
28
|
+
collectionName = `docs_${config.i18n.defaultLocale}`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const page = await queryCollection(event, collectionName as keyof Collections).path(path).first()
|
|
13
33
|
if (!page) {
|
|
14
34
|
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
|
|
15
35
|
}
|