@sit-onyx/nuxt-docs 1.0.0-beta.0 → 1.0.0-beta.2
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.config.ts +6 -2
- package/components/NavBar.vue +2 -6
- package/components/NavItem.vue +22 -0
- package/nuxt.config.ts +1 -0
- package/package.json +15 -6
- package/pages/[...path].vue +14 -2
- package/composables/useCollection.ts +0 -22
package/app.config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { OnyxNavBarProps,
|
|
1
|
+
import type { OnyxNavBarProps, OnyxNavItemProps } from "sit-onyx";
|
|
2
2
|
|
|
3
|
+
// TYPES
|
|
3
4
|
declare module "@nuxt/schema" {
|
|
4
5
|
interface AppConfigInput {
|
|
5
6
|
onyxDocs?: OnyxAppConfig;
|
|
@@ -12,10 +13,13 @@ declare module "@nuxt/schema" {
|
|
|
12
13
|
|
|
13
14
|
export type OnyxAppConfig = {
|
|
14
15
|
nav?: Partial<OnyxNavBarProps> & {
|
|
15
|
-
items?:
|
|
16
|
+
items?: NavItem[];
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
export type NavItem = OnyxNavItemProps & { children?: NavItem[] };
|
|
21
|
+
|
|
22
|
+
// CONFIG
|
|
19
23
|
const defaultAppConfig = {
|
|
20
24
|
nav: {
|
|
21
25
|
appName: "Documentation",
|
package/components/NavBar.vue
CHANGED
|
@@ -20,15 +20,11 @@ const colorScheme = computed({
|
|
|
20
20
|
|
|
21
21
|
<template>
|
|
22
22
|
<OnyxNavBar v-bind="onyxDocs.nav" @navigate-back="router.back">
|
|
23
|
-
<
|
|
23
|
+
<NavItem
|
|
24
24
|
v-for="item in onyxDocs.nav?.items"
|
|
25
25
|
:key="extractLinkProps(item.link ?? '').href"
|
|
26
26
|
v-bind="item"
|
|
27
|
-
|
|
28
|
-
<template v-if="item.children?.length" #children>
|
|
29
|
-
<OnyxNavItem v-for="child in item.children" :key="child.label" v-bind="child" />
|
|
30
|
-
</template>
|
|
31
|
-
</OnyxNavButton>
|
|
27
|
+
/>
|
|
32
28
|
|
|
33
29
|
<template #contextArea>
|
|
34
30
|
<OnyxIconButton
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { NavItem } from "../app.config";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<NavItem>();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Same as `props` but without the `children` property to prevent console warnings when using `v-bind`.
|
|
8
|
+
*/
|
|
9
|
+
const navItemProps = computed(() => {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
const { children, ...rest } = props;
|
|
12
|
+
return rest;
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<OnyxNavItem v-bind="navItemProps">
|
|
18
|
+
<template v-if="props.children?.length" #children>
|
|
19
|
+
<NavItem v-for="child in props.children" :key="child.label" v-bind="child" />
|
|
20
|
+
</template>
|
|
21
|
+
</OnyxNavItem>
|
|
22
|
+
</template>
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/nuxt-docs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.2",
|
|
5
5
|
"description": "Nuxt layer/template for creating documentations with the onyx design system",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.vue",
|
|
24
24
|
"*.json"
|
|
25
25
|
],
|
|
26
|
-
"
|
|
26
|
+
"peerDependencies": {
|
|
27
27
|
"@fontsource-variable/source-code-pro": ">= 5",
|
|
28
28
|
"@fontsource-variable/source-sans-3": ">= 5",
|
|
29
29
|
"@nuxt/content": ">= 3",
|
|
@@ -31,15 +31,24 @@
|
|
|
31
31
|
"@nuxtjs/color-mode": ">= 3",
|
|
32
32
|
"sass-embedded": ">= 1",
|
|
33
33
|
"@sit-onyx/icons": "^1.0.0-beta.14",
|
|
34
|
-
"@sit-onyx/nuxt": "^1.0.0-beta.
|
|
35
|
-
"sit-onyx": "^1.0.0-beta.
|
|
34
|
+
"@sit-onyx/nuxt": "^1.0.0-beta.192",
|
|
35
|
+
"sit-onyx": "^1.0.0-beta.190"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@fontsource-variable/source-code-pro": ">= 5",
|
|
39
|
+
"@fontsource-variable/source-sans-3": ">= 5",
|
|
40
|
+
"@nuxt/content": ">= 3",
|
|
41
|
+
"@nuxt/image": ">= 1",
|
|
38
42
|
"@nuxt/test-utils": "^3.17.2",
|
|
39
|
-
"
|
|
43
|
+
"@nuxtjs/color-mode": ">= 3",
|
|
44
|
+
"nuxt": "^3.16.2",
|
|
45
|
+
"sass-embedded": "1.86.3",
|
|
40
46
|
"typescript": "5.8.3",
|
|
41
47
|
"vue": "3.5.13",
|
|
42
|
-
"@sit-onyx/
|
|
48
|
+
"@sit-onyx/icons": "^1.0.0-beta.14",
|
|
49
|
+
"sit-onyx": "^1.0.0-beta.190",
|
|
50
|
+
"@sit-onyx/shared": "^1.0.0-beta.2",
|
|
51
|
+
"@sit-onyx/nuxt": "^1.0.0-beta.192"
|
|
43
52
|
},
|
|
44
53
|
"scripts": {
|
|
45
54
|
"dev": "nuxi dev .playground",
|
package/pages/[...path].vue
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
const
|
|
2
|
+
const route = useRoute();
|
|
3
|
+
const collection = await useAsyncData(() => queryCollection("content").path(route.path).first());
|
|
4
|
+
|
|
5
|
+
if (!collection.data.value) {
|
|
6
|
+
throw createError({
|
|
7
|
+
message: "Page not found",
|
|
8
|
+
statusCode: 404,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const data = toRef(() => collection.data.value!);
|
|
13
|
+
useSeoMeta({ ...data.value.seo });
|
|
3
14
|
</script>
|
|
4
15
|
|
|
16
|
+
<!-- eslint-disable-next-line vue/no-root-v-if -- the v-if here is theoretically not needed because we throw above it ifs undefined so the user will be redirected to the error page. However, there is still a console warning so we include the v-if here to prevent it. -->
|
|
5
17
|
<template>
|
|
6
|
-
<ContentRenderer :value="data" />
|
|
18
|
+
<ContentRenderer v-if="data" :value="data" />
|
|
7
19
|
</template>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type UseCollectionOptions = {
|
|
2
|
-
collection: Parameters<typeof queryCollection>[0];
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export const useCollection = async (options: UseCollectionOptions) => {
|
|
6
|
-
const route = useRoute();
|
|
7
|
-
const collection = await useAsyncData(() =>
|
|
8
|
-
queryCollection(options.collection).path(route.path).first(),
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
if (!collection.data.value) {
|
|
12
|
-
throw createError({
|
|
13
|
-
message: "Page not found",
|
|
14
|
-
statusCode: 404,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const data = toRef(() => collection.data.value!);
|
|
19
|
-
useSeoMeta({ ...data.value.seo });
|
|
20
|
-
|
|
21
|
-
return { ...collection, data };
|
|
22
|
-
};
|