@sit-onyx/nuxt-docs 1.0.0-beta.104 → 1.0.0-beta.105
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/components/NavBar.vue +45 -3
- package/app/components/NavItem.vue +13 -1
- package/app/error.vue +3 -1
- package/app/pages/{[...path].vue → [...slug].vue} +13 -3
- package/content.config.ts +3 -3
- package/nuxt.config.ts +7 -1
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { iconCircleContrast } from "@sit-onyx/icons";
|
|
3
|
-
import { extractLinkProps, type ColorSchemeValue } from "sit-onyx";
|
|
2
|
+
import { iconCircleContrast, iconTranslate } from "@sit-onyx/icons";
|
|
3
|
+
import { extractLinkProps, type ColorSchemeValue, type SelectDialogOption } from "sit-onyx";
|
|
4
4
|
|
|
5
5
|
const { onyxDocs } = useAppConfig();
|
|
6
6
|
const router = useRouter();
|
|
@@ -16,10 +16,32 @@ const colorScheme = computed({
|
|
|
16
16
|
colorMode.preference = newValue === "auto" ? "system" : newValue;
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
const { locale, setLocale, locales } = useI18n();
|
|
21
|
+
const localePath = useLocalePath();
|
|
22
|
+
const isLanguageDialogOpen = ref(false);
|
|
23
|
+
|
|
24
|
+
const languageOptions = computed(() => {
|
|
25
|
+
return locales.value.map((locale) => {
|
|
26
|
+
return {
|
|
27
|
+
label: locale.name ?? locale.code,
|
|
28
|
+
value: locale.code,
|
|
29
|
+
} satisfies SelectDialogOption;
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const currentLocaleLabel = computed(() => {
|
|
34
|
+
// using "!" here is safe since splitting a string will always return at least one string in the returned array
|
|
35
|
+
return locale.value.split("-")[0]!.split("_")[0]!.toUpperCase();
|
|
36
|
+
});
|
|
19
37
|
</script>
|
|
20
38
|
|
|
21
39
|
<template>
|
|
22
|
-
<OnyxNavBar
|
|
40
|
+
<OnyxNavBar
|
|
41
|
+
:app-area="{ link: localePath('/') }"
|
|
42
|
+
v-bind="onyxDocs.nav"
|
|
43
|
+
@navigate-back="router.back"
|
|
44
|
+
>
|
|
23
45
|
<NavItem
|
|
24
46
|
v-for="item in onyxDocs.nav?.items"
|
|
25
47
|
:key="extractLinkProps(item.link ?? '').href"
|
|
@@ -27,6 +49,26 @@ const colorScheme = computed({
|
|
|
27
49
|
/>
|
|
28
50
|
|
|
29
51
|
<template #contextArea>
|
|
52
|
+
<template v-if="locales.length > 1">
|
|
53
|
+
<OnyxButton
|
|
54
|
+
:label="currentLocaleLabel"
|
|
55
|
+
:icon="iconTranslate"
|
|
56
|
+
color="neutral"
|
|
57
|
+
mode="plain"
|
|
58
|
+
@click="isLanguageDialogOpen = true"
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
<OnyxSelectDialog
|
|
62
|
+
v-model:open="isLanguageDialogOpen"
|
|
63
|
+
:label="$t('onyx.languageSelect.headline')"
|
|
64
|
+
:model-value="locale"
|
|
65
|
+
:options="languageOptions"
|
|
66
|
+
@update:model-value="setLocale($event)"
|
|
67
|
+
>
|
|
68
|
+
<template #description> {{ $t("onyx.languageSelect.subtitle") }} </template>
|
|
69
|
+
</OnyxSelectDialog>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
30
72
|
<OnyxIconButton
|
|
31
73
|
label="Toggle color scheme"
|
|
32
74
|
:icon="iconCircleContrast"
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import { extractLinkProps } from "sit-onyx";
|
|
2
3
|
import type { NavItem } from "../app.config";
|
|
3
4
|
|
|
4
5
|
const props = defineProps<NavItem>();
|
|
5
6
|
|
|
7
|
+
const localePath = useLocalePath();
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Same as `props` but without the `children` property to prevent console warnings when using `v-bind`.
|
|
8
11
|
*/
|
|
@@ -10,10 +13,19 @@ const navItemProps = computed(() => {
|
|
|
10
13
|
const { children: _, ...rest } = props;
|
|
11
14
|
return rest;
|
|
12
15
|
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Nav item link depending on the current locale / i18n.
|
|
19
|
+
*/
|
|
20
|
+
const localeLink = computed(() => {
|
|
21
|
+
if (!props.link) return;
|
|
22
|
+
const _link = extractLinkProps(props.link);
|
|
23
|
+
return { ..._link, href: localePath(_link.href) };
|
|
24
|
+
});
|
|
13
25
|
</script>
|
|
14
26
|
|
|
15
27
|
<template>
|
|
16
|
-
<OnyxNavItem v-bind="navItemProps">
|
|
28
|
+
<OnyxNavItem v-bind="navItemProps" :link="localeLink">
|
|
17
29
|
<template v-if="props.children?.length" #children>
|
|
18
30
|
<NavItem v-for="child in props.children" :key="child.label" v-bind="child" />
|
|
19
31
|
</template>
|
package/app/error.vue
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { Collections } from "@nuxt/content";
|
|
3
|
+
|
|
2
4
|
const route = useRoute();
|
|
3
|
-
const
|
|
5
|
+
const { locale } = useI18n();
|
|
6
|
+
const slug = computed(() => {
|
|
7
|
+
const value = String(route.params.slug);
|
|
8
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
9
|
+
});
|
|
4
10
|
|
|
5
|
-
const collection = await useAsyncData(
|
|
6
|
-
|
|
11
|
+
const collection = await useAsyncData(
|
|
12
|
+
() => `page-${slug.value}-${locale.value}`,
|
|
13
|
+
() => {
|
|
14
|
+
const collection = `content_${locale.value}` as keyof Collections;
|
|
15
|
+
return queryCollection(collection).path(slug.value).first();
|
|
16
|
+
},
|
|
7
17
|
);
|
|
8
18
|
|
|
9
19
|
watch(
|
package/content.config.ts
CHANGED
|
@@ -3,13 +3,13 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
export default defineContentConfig({
|
|
5
5
|
collections: {
|
|
6
|
-
|
|
6
|
+
content_en: defineCollection({
|
|
7
7
|
type: "page",
|
|
8
8
|
source: [
|
|
9
9
|
// include files from content folder of the extending app
|
|
10
|
-
{ cwd: path.resolve("content"), include: "
|
|
10
|
+
{ cwd: path.resolve("content"), include: "en/**", prefix: "" },
|
|
11
11
|
// include files from playground (mainly needed for this monorepo)
|
|
12
|
-
{ cwd: path.resolve("playground/content"), include: "
|
|
12
|
+
{ cwd: path.resolve("playground/content"), include: "en/**", prefix: "" },
|
|
13
13
|
],
|
|
14
14
|
}),
|
|
15
15
|
},
|
package/nuxt.config.ts
CHANGED
|
@@ -3,9 +3,15 @@ export default defineNuxtConfig({
|
|
|
3
3
|
devtools: { enabled: true },
|
|
4
4
|
compatibilityDate: "2025-01-20",
|
|
5
5
|
typescript: { typeCheck: "build" },
|
|
6
|
-
modules: ["@sit-onyx/nuxt", "@nuxt/content", "@nuxtjs/color-mode", "@nuxt/image"],
|
|
6
|
+
modules: ["@sit-onyx/nuxt", "@nuxt/content", "@nuxtjs/color-mode", "@nuxt/image", "@nuxtjs/i18n"],
|
|
7
7
|
css: ["@fontsource-variable/source-code-pro", "@fontsource-variable/source-sans-3"],
|
|
8
8
|
colorMode: {
|
|
9
9
|
classSuffix: "",
|
|
10
10
|
},
|
|
11
|
+
i18n: {
|
|
12
|
+
defaultLocale: "en",
|
|
13
|
+
// we explicitly don't define any default locales here so the project is fully in charge if defining which locales to use.
|
|
14
|
+
// Otherwise if we would e.g. add en here, the project would always be forced to register en, even if it does not plan to add en translations
|
|
15
|
+
// which could conflict with e.g. "const { locales } = useI18n()" to render a language switch which would always include en then
|
|
16
|
+
},
|
|
11
17
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/nuxt-docs",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.105",
|
|
4
4
|
"description": "Nuxt layer/template for creating documentations with the onyx design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@nuxt/content": ">= 3",
|
|
29
29
|
"@nuxt/image": ">= 1",
|
|
30
30
|
"@nuxtjs/color-mode": ">= 3",
|
|
31
|
+
"@nuxtjs/i18n": ">= 10",
|
|
31
32
|
"sass-embedded": ">= 1",
|
|
32
33
|
"@sit-onyx/icons": "^1.0.0-beta.24",
|
|
33
34
|
"@sit-onyx/nuxt": "^1.0.0-beta.290",
|
|
@@ -46,10 +47,10 @@
|
|
|
46
47
|
"sass-embedded": "1.90.0",
|
|
47
48
|
"typescript": "5.9.2",
|
|
48
49
|
"vue": "3.5.18",
|
|
49
|
-
"@sit-onyx/icons": "^1.0.0-beta.24",
|
|
50
|
-
"@sit-onyx/nuxt": "^1.0.0-beta.290",
|
|
51
50
|
"@sit-onyx/shared": "^1.0.0-beta.4",
|
|
52
|
-
"sit-onyx": "^1.0.0-beta.290"
|
|
51
|
+
"@sit-onyx/nuxt": "^1.0.0-beta.290",
|
|
52
|
+
"sit-onyx": "^1.0.0-beta.290",
|
|
53
|
+
"@sit-onyx/icons": "^1.0.0-beta.24"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
56
|
"dev": "pnpm dev:prepare && nuxi dev playground",
|