docus 5.2.3 → 5.3.0
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.
- package/app/app.config.ts +4 -0
- package/app/app.vue +6 -5
- package/app/components/LanguageSelect.vue +1 -0
- package/app/composables/useDocusI18n.ts +5 -3
- package/app/error.vue +8 -5
- package/app/plugins/i18n.ts +25 -3
- package/app/types/index.d.ts +3 -0
- package/i18n/locales/bg.json +22 -0
- package/i18n/locales/ro.json +22 -0
- package/nuxt.config.ts +4 -0
- package/package.json +8 -8
package/app/app.config.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export default defineAppConfig({
|
|
2
|
+
docus: {
|
|
3
|
+
locale: 'en',
|
|
4
|
+
},
|
|
2
5
|
ui: {
|
|
3
6
|
colors: {
|
|
4
7
|
primary: 'emerald',
|
|
@@ -6,6 +9,7 @@ export default defineAppConfig({
|
|
|
6
9
|
},
|
|
7
10
|
commandPalette: {
|
|
8
11
|
slots: {
|
|
12
|
+
item: 'items-center',
|
|
9
13
|
input: '[&_.iconify]:size-4 [&_.iconify]:mx-0.5',
|
|
10
14
|
itemLeadingIcon: 'size-4 mx-0.5',
|
|
11
15
|
},
|
package/app/app.vue
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { PageCollections } from '@nuxt/content'
|
|
2
|
+
import type { ContentNavigationItem, PageCollections } from '@nuxt/content'
|
|
3
3
|
import * as nuxtUiLocales from '@nuxt/ui/locale'
|
|
4
4
|
|
|
5
5
|
const { seo } = useAppConfig()
|
|
6
6
|
const site = useSiteConfig()
|
|
7
7
|
const { locale, locales, isEnabled, switchLocalePath } = useDocusI18n()
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const nuxtUiLocale = computed(() => nuxtUiLocales[locale.value as keyof typeof nuxtUiLocales] || nuxtUiLocales.en)
|
|
10
|
+
const lang = computed(() => nuxtUiLocale.value.code)
|
|
11
|
+
const dir = computed(() => nuxtUiLocale.value.dir)
|
|
11
12
|
const collectionName = computed(() => isEnabled.value ? `docs_${locale.value}` : 'docs')
|
|
12
13
|
|
|
13
14
|
useHead({
|
|
@@ -43,7 +44,7 @@ if (isEnabled.value) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
const { data: navigation } = await useAsyncData(() => `navigation_${collectionName.value}`, () => queryCollectionNavigation(collectionName.value as keyof PageCollections), {
|
|
46
|
-
transform: (data) => {
|
|
47
|
+
transform: (data: ContentNavigationItem[]) => {
|
|
47
48
|
const rootResult = data.find(item => item.path === '/docs')?.children || data || []
|
|
48
49
|
|
|
49
50
|
return rootResult.find(item => item.path === `/${locale.value}`)?.children || rootResult
|
|
@@ -58,7 +59,7 @@ provide('navigation', navigation)
|
|
|
58
59
|
</script>
|
|
59
60
|
|
|
60
61
|
<template>
|
|
61
|
-
<UApp :locale="
|
|
62
|
+
<UApp :locale="nuxtUiLocale">
|
|
62
63
|
<NuxtLoadingIndicator color="var(--ui-primary)" />
|
|
63
64
|
|
|
64
65
|
<AppHeader v-if="$route.meta.header !== false" />
|
|
@@ -28,6 +28,7 @@ function getEmojiFlag(locale: string): string {
|
|
|
28
28
|
uk: 'ua', // Ukrainian -> Ukraine
|
|
29
29
|
ur: 'pk', // Urdu -> Pakistan
|
|
30
30
|
vi: 'vn', // Vietnamese -> Vietnam
|
|
31
|
+
es: 'es', // Spanish -> Spain
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const baseLanguage = locale.split('-')[0]?.toLowerCase() || locale
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { LocaleObject } from '@nuxtjs/i18n'
|
|
2
|
-
import en from '../../i18n/locales/en.json'
|
|
3
2
|
|
|
4
3
|
export const useDocusI18n = () => {
|
|
5
4
|
const config = useRuntimeConfig().public
|
|
6
5
|
const isEnabled = ref(!!config.i18n)
|
|
7
6
|
|
|
8
7
|
if (!isEnabled.value) {
|
|
8
|
+
const locale = useNuxtApp().$locale as string
|
|
9
|
+
const localeMessages = useNuxtApp().$localeMessages as Record<string, unknown>
|
|
10
|
+
|
|
9
11
|
return {
|
|
10
12
|
isEnabled,
|
|
11
|
-
locale: ref(
|
|
13
|
+
locale: ref(locale),
|
|
12
14
|
locales: [],
|
|
13
15
|
localePath: (path: string) => path,
|
|
14
16
|
switchLocalePath: () => {},
|
|
15
17
|
t: (key: string): string => {
|
|
16
18
|
const path = key.split('.')
|
|
17
|
-
return path.reduce((acc: unknown, curr) => (acc as Record<string, unknown>)?.[curr],
|
|
19
|
+
return path.reduce((acc: unknown, curr) => (acc as Record<string, unknown>)?.[curr], localeMessages) as string
|
|
18
20
|
},
|
|
19
21
|
}
|
|
20
22
|
}
|
package/app/error.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { NuxtError } from '#app'
|
|
3
|
-
import type { PageCollections } from '@nuxt/content'
|
|
3
|
+
import type { ContentNavigationItem, PageCollections } from '@nuxt/content'
|
|
4
4
|
import * as nuxtUiLocales from '@nuxt/ui/locale'
|
|
5
5
|
|
|
6
6
|
const props = defineProps<{
|
|
@@ -9,8 +9,10 @@ const props = defineProps<{
|
|
|
9
9
|
|
|
10
10
|
const { locale, locales, isEnabled, t, switchLocalePath } = useDocusI18n()
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const nuxtUiLocale = computed(() => nuxtUiLocales[locale.value as keyof typeof nuxtUiLocales] || nuxtUiLocales.en)
|
|
13
|
+
const lang = computed(() => nuxtUiLocale.value.code)
|
|
14
|
+
const dir = computed(() => nuxtUiLocale.value.dir)
|
|
15
|
+
|
|
14
16
|
useHead({
|
|
15
17
|
htmlAttrs: {
|
|
16
18
|
lang,
|
|
@@ -22,6 +24,7 @@ const localizedError = computed(() => {
|
|
|
22
24
|
return {
|
|
23
25
|
...props.error,
|
|
24
26
|
statusMessage: t('common.error.title'),
|
|
27
|
+
message: t('common.error.description'),
|
|
25
28
|
}
|
|
26
29
|
})
|
|
27
30
|
|
|
@@ -44,7 +47,7 @@ if (isEnabled.value) {
|
|
|
44
47
|
const collectionName = computed(() => isEnabled.value ? `docs_${locale.value}` : 'docs')
|
|
45
48
|
|
|
46
49
|
const { data: navigation } = await useAsyncData(`navigation_${collectionName.value}`, () => queryCollectionNavigation(collectionName.value as keyof PageCollections), {
|
|
47
|
-
transform: (data) => {
|
|
50
|
+
transform: (data: ContentNavigationItem[]) => {
|
|
48
51
|
const rootResult = data.find(item => item.path === '/docs')?.children || data || []
|
|
49
52
|
|
|
50
53
|
return rootResult.find(item => item.path === `/${locale.value}`)?.children || rootResult
|
|
@@ -59,7 +62,7 @@ provide('navigation', navigation)
|
|
|
59
62
|
</script>
|
|
60
63
|
|
|
61
64
|
<template>
|
|
62
|
-
<UApp>
|
|
65
|
+
<UApp :locale="nuxtUiLocale">
|
|
63
66
|
<AppHeader />
|
|
64
67
|
|
|
65
68
|
<UError :error="localizedError" />
|
package/app/plugins/i18n.ts
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import en from '../../i18n/locales/en.json'
|
|
2
|
+
import type { RouteLocationNormalized } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
export default defineNuxtPlugin(async () => {
|
|
2
5
|
const nuxtApp = useNuxtApp()
|
|
3
6
|
|
|
4
7
|
const i18nConfig = nuxtApp.$config.public.i18n
|
|
8
|
+
|
|
9
|
+
// If i18n is not enabled, fetch and provide the configured locale in app config
|
|
5
10
|
if (!i18nConfig) {
|
|
6
|
-
|
|
11
|
+
let locale = 'en'
|
|
12
|
+
let resolvedMessages: Record<string, unknown> = en
|
|
13
|
+
|
|
14
|
+
const appConfig = useAppConfig()
|
|
15
|
+
const configuredLocale = appConfig.docus.locale
|
|
16
|
+
if (configuredLocale !== 'en') {
|
|
17
|
+
const localeMessages = await import(`../../i18n/locales/${configuredLocale}.json`)
|
|
18
|
+
if (!localeMessages) {
|
|
19
|
+
console.warn(`[Docus] Missing locale file for "${configuredLocale}". Falling back to "en".`)
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
locale = configuredLocale
|
|
23
|
+
resolvedMessages = localeMessages
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
nuxtApp.provide('locale', locale)
|
|
28
|
+
nuxtApp.provide('localeMessages', resolvedMessages)
|
|
7
29
|
}
|
|
8
30
|
|
|
9
|
-
addRouteMiddleware((to) => {
|
|
31
|
+
addRouteMiddleware((to: RouteLocationNormalized) => {
|
|
10
32
|
if (to.path === '/') {
|
|
11
33
|
const cookieLocale = useCookie('i18n_redirected').value || i18nConfig.defaultLocale || 'en'
|
|
12
34
|
|
package/app/types/index.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"or": "или",
|
|
4
|
+
"error": {
|
|
5
|
+
"title": "Страницата не е намерена",
|
|
6
|
+
"description": "Съжаляваме, но тази страница не може да бъде намерена."
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"docs": {
|
|
10
|
+
"copy": {
|
|
11
|
+
"page": "Копиране на Markdown кода на страницата",
|
|
12
|
+
"link": "Копиране на връзка към Markdown файла на страницата",
|
|
13
|
+
"view": "Отваряне на Markdown файла на страницата",
|
|
14
|
+
"gpt": "Отваряне в ChatGPT",
|
|
15
|
+
"claude": "Отваряне в Claude"
|
|
16
|
+
},
|
|
17
|
+
"links": "Общност",
|
|
18
|
+
"toc": "На тази страница",
|
|
19
|
+
"report": "Докладване на проблем",
|
|
20
|
+
"edit": "Редактиране на тази страница"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"or": "sau",
|
|
4
|
+
"error": {
|
|
5
|
+
"title": "Pagina nu a fost găsită",
|
|
6
|
+
"description": "Ne pare rău, dar această pagină nu a putut fi găsită."
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"docs": {
|
|
10
|
+
"copy": {
|
|
11
|
+
"page": "Copiază pagina",
|
|
12
|
+
"link": "Copiază pagina în Markdown",
|
|
13
|
+
"view": "Vezi ca Markdown",
|
|
14
|
+
"gpt": "Deschide în ChatGPT",
|
|
15
|
+
"claude": "Deschide în Claude"
|
|
16
|
+
},
|
|
17
|
+
"links": "Comunitate",
|
|
18
|
+
"toc": "Pe această pagină",
|
|
19
|
+
"report": "Raportează o problemă",
|
|
20
|
+
"edit": "Editează această pagină"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docus",
|
|
3
3
|
"description": "Nuxt layer for Docus documentation theme",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
7
7
|
"repository": {
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@iconify-json/lucide": "^1.2.
|
|
26
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
27
|
-
"@iconify-json/vscode-icons": "^1.2.
|
|
28
|
-
"@nuxt/content": "
|
|
29
|
-
"@nuxt/image": "^
|
|
25
|
+
"@iconify-json/lucide": "^1.2.75",
|
|
26
|
+
"@iconify-json/simple-icons": "^1.2.60",
|
|
27
|
+
"@iconify-json/vscode-icons": "^1.2.36",
|
|
28
|
+
"@nuxt/content": "^3.8.2",
|
|
29
|
+
"@nuxt/image": "^2.0.0",
|
|
30
30
|
"@nuxt/kit": "^4.2.1",
|
|
31
|
-
"@nuxt/ui": "^4.1
|
|
31
|
+
"@nuxt/ui": "^4.2.1",
|
|
32
32
|
"@nuxtjs/i18n": "^10.2.1",
|
|
33
|
-
"@nuxtjs/mdc": "^0.18.
|
|
33
|
+
"@nuxtjs/mdc": "^0.18.4",
|
|
34
34
|
"@nuxtjs/robots": "^5.5.6",
|
|
35
35
|
"@vueuse/core": "^13.9.0",
|
|
36
36
|
"defu": "^6.1.4",
|