@sit-onyx/nuxt-docs 1.0.0-beta.124 → 1.0.0-beta.125
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/SidebarItem.vue +68 -0
- package/app/components/content/ProseH1.vue +6 -0
- package/app/components/content/ProseH2.vue +7 -0
- package/app/components/content/ProseH3.vue +7 -0
- package/app/components/content/ProseH4.vue +7 -0
- package/app/components/content/ProseH5.vue +7 -0
- package/app/components/content/ProseH6.vue +7 -0
- package/app/components/content/ProseOl.vue +18 -0
- package/app/components/content/ProseUl.vue +18 -0
- package/app/layouts/default.vue +10 -1
- package/app/layouts/sidebar.vue +144 -0
- package/app/pages/[...slug].vue +7 -4
- package/package.json +4 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ContentNavigationItem } from "@nuxt/content";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
item: ContentNavigationItem;
|
|
6
|
+
}>();
|
|
7
|
+
|
|
8
|
+
const localePath = useLocalePath();
|
|
9
|
+
|
|
10
|
+
const isAccordionOpen = ref(true);
|
|
11
|
+
|
|
12
|
+
const children = computed(() => {
|
|
13
|
+
// filter out children that are directories
|
|
14
|
+
return props.item.children?.filter((child) => child.page !== false);
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<OnyxSidebarItem v-if="!children" class="sidebar-item" :link="localePath(props.item.path)">
|
|
20
|
+
{{ props.item.title }}
|
|
21
|
+
</OnyxSidebarItem>
|
|
22
|
+
|
|
23
|
+
<OnyxAccordion
|
|
24
|
+
v-else
|
|
25
|
+
:model-value="isAccordionOpen ? [localePath(item.path)] : undefined"
|
|
26
|
+
class="sidebar-accordion"
|
|
27
|
+
type="nested-large"
|
|
28
|
+
@update:model-value="isAccordionOpen = !isAccordionOpen"
|
|
29
|
+
>
|
|
30
|
+
<OnyxAccordionItem :value="localePath(item.path)">
|
|
31
|
+
<template #header>{{ props.item.title }}</template>
|
|
32
|
+
|
|
33
|
+
<div class="sidebar-item__children">
|
|
34
|
+
<OnyxSidebarItem
|
|
35
|
+
v-for="child in children"
|
|
36
|
+
:key="localePath(child.path)"
|
|
37
|
+
:link="localePath(child.path)"
|
|
38
|
+
>
|
|
39
|
+
{{ child.title }}
|
|
40
|
+
</OnyxSidebarItem>
|
|
41
|
+
</div>
|
|
42
|
+
</OnyxAccordionItem>
|
|
43
|
+
</OnyxAccordion>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<style lang="scss" scoped>
|
|
47
|
+
.sidebar-item {
|
|
48
|
+
margin: var(--onyx-density-2xs) var(--onyx-density-xs);
|
|
49
|
+
|
|
50
|
+
&:first-of-type {
|
|
51
|
+
margin-top: var(--onyx-density-xs);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__children {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: var(--onyx-density-2xs);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sidebar-accordion {
|
|
62
|
+
> .onyx-accordion-item {
|
|
63
|
+
:deep(> .onyx-accordion-item__panel) {
|
|
64
|
+
padding-top: 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
defineSlots<{
|
|
3
|
+
default(): unknown;
|
|
4
|
+
}>();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<ol>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</ol>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style lang="scss" scoped>
|
|
14
|
+
ol {
|
|
15
|
+
margin-top: var(--onyx-density-xs);
|
|
16
|
+
margin-bottom: var(--onyx-density-xs);
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
defineSlots<{
|
|
3
|
+
default(): unknown;
|
|
4
|
+
}>();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<ul>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</ul>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style lang="scss" scoped>
|
|
14
|
+
ul {
|
|
15
|
+
margin-top: var(--onyx-density-xs);
|
|
16
|
+
margin-bottom: var(--onyx-density-xs);
|
|
17
|
+
}
|
|
18
|
+
</style>
|
package/app/layouts/default.vue
CHANGED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ContentNavigationItem } from "@nuxt/content";
|
|
3
|
+
import { iconSearch } from "@sit-onyx/icons";
|
|
4
|
+
import { normalizedIncludes, type OnyxPageLayoutProps, type OnyxSidebarProps } from "sit-onyx";
|
|
5
|
+
|
|
6
|
+
const props = defineProps<
|
|
7
|
+
OnyxPageLayoutProps & {
|
|
8
|
+
sidebar?: OnyxSidebarProps;
|
|
9
|
+
}
|
|
10
|
+
>();
|
|
11
|
+
|
|
12
|
+
const slots = defineSlots<{
|
|
13
|
+
/**
|
|
14
|
+
* Main page content.
|
|
15
|
+
*/
|
|
16
|
+
default(): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Page footer content.
|
|
19
|
+
*/
|
|
20
|
+
footer?(): unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Optional right sidebar.
|
|
23
|
+
*/
|
|
24
|
+
sidebarRight?(): unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Optionally override the main sidebar body content.
|
|
27
|
+
*/
|
|
28
|
+
sidebarBody?(props: { items: ContentNavigationItem[] }): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Optionally override the sidebar header content.
|
|
31
|
+
*/
|
|
32
|
+
sidebarHeader?(): unknown;
|
|
33
|
+
/**
|
|
34
|
+
* Sidebar footer content.
|
|
35
|
+
*/
|
|
36
|
+
sidebarFooter?(): unknown;
|
|
37
|
+
}>();
|
|
38
|
+
|
|
39
|
+
const { locale } = useI18n();
|
|
40
|
+
const localePath = useLocalePath();
|
|
41
|
+
|
|
42
|
+
const navigation = await useAsyncData(
|
|
43
|
+
() => `navigation-${locale.value}`,
|
|
44
|
+
() => {
|
|
45
|
+
const collection = `content_${locale.value}` as const;
|
|
46
|
+
return queryCollectionNavigation(collection);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const searchTerm = ref("");
|
|
51
|
+
|
|
52
|
+
const allSidebarItems = computed(() => navigation.data.value ?? []);
|
|
53
|
+
|
|
54
|
+
const filterItem = (
|
|
55
|
+
item: ContentNavigationItem,
|
|
56
|
+
search: string,
|
|
57
|
+
): ContentNavigationItem | undefined => {
|
|
58
|
+
if (!item.children) {
|
|
59
|
+
return normalizedIncludes(item.title, search) ? item : undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const children = item.children
|
|
63
|
+
.map((child) => filterItem(child, search))
|
|
64
|
+
.filter((child) => child != undefined);
|
|
65
|
+
|
|
66
|
+
if (!children.length) return undefined;
|
|
67
|
+
return { ...item, children };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const filteredSidebarItems = computed(() => {
|
|
71
|
+
if (!searchTerm.value) return allSidebarItems.value;
|
|
72
|
+
|
|
73
|
+
const items = allSidebarItems.value
|
|
74
|
+
.map((item) => filterItem(item, searchTerm.value))
|
|
75
|
+
.filter((item) => item != undefined);
|
|
76
|
+
|
|
77
|
+
return items;
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<OnyxPageLayout v-bind="props">
|
|
83
|
+
<template #sidebar>
|
|
84
|
+
<OnyxSidebar
|
|
85
|
+
class="sidebar"
|
|
86
|
+
v-bind="props.sidebar"
|
|
87
|
+
:label="$t('onyx.navigation.navigationHeadline')"
|
|
88
|
+
>
|
|
89
|
+
<template #header>
|
|
90
|
+
<slot name="sidebarHeader">
|
|
91
|
+
<OnyxInput
|
|
92
|
+
v-model="searchTerm"
|
|
93
|
+
:label="$t('onyx.select.searchPlaceholder')"
|
|
94
|
+
hide-label
|
|
95
|
+
:placeholder="$t('onyx.select.searchPlaceholder')"
|
|
96
|
+
>
|
|
97
|
+
<template #leading>
|
|
98
|
+
<OnyxIcon :icon="iconSearch" />
|
|
99
|
+
</template>
|
|
100
|
+
</OnyxInput>
|
|
101
|
+
</slot>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<slot name="sidebarBody" :items="filteredSidebarItems">
|
|
105
|
+
<SidebarItem
|
|
106
|
+
v-for="item in filteredSidebarItems"
|
|
107
|
+
:key="localePath(item.path)"
|
|
108
|
+
:item="item"
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
<OnyxEmpty v-if="!filteredSidebarItems.length" class="sidebar__empty">
|
|
112
|
+
{{ $t("onyx.select.empty") }}
|
|
113
|
+
</OnyxEmpty>
|
|
114
|
+
</slot>
|
|
115
|
+
|
|
116
|
+
<template v-if="!!slots.sidebarFooter" #footer>
|
|
117
|
+
<slot name="sidebarFooter"></slot>
|
|
118
|
+
</template>
|
|
119
|
+
</OnyxSidebar>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<slot></slot>
|
|
123
|
+
|
|
124
|
+
<template v-if="!!slots.footer" #footer>
|
|
125
|
+
<slot name="footer"></slot>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<template v-if="!!slots.sidebarRight" #sidebarRight>
|
|
129
|
+
<slot name="sidebarRight"></slot>
|
|
130
|
+
</template>
|
|
131
|
+
</OnyxPageLayout>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<style lang="scss" scoped>
|
|
135
|
+
.content {
|
|
136
|
+
white-space: pre-line;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.sidebar {
|
|
140
|
+
&__empty {
|
|
141
|
+
max-width: 100%;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</style>
|
package/app/pages/[...slug].vue
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
definePageMeta({ layout: "sidebar" });
|
|
3
3
|
|
|
4
4
|
const route = useRoute();
|
|
5
5
|
const { locale } = useI18n();
|
|
6
|
+
|
|
6
7
|
const slug = computed(() => {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const path = Array.isArray(route.params.slug)
|
|
9
|
+
? route.params.slug.join("/")
|
|
10
|
+
: (route.params.slug ?? "");
|
|
11
|
+
return path.startsWith("/") ? path : `/${path}`;
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
const collection = await useAsyncData(
|
|
12
15
|
() => `page-${slug.value}-${locale.value}`,
|
|
13
16
|
() => {
|
|
14
|
-
const collection = `content_${locale.value}` as
|
|
17
|
+
const collection = `content_${locale.value}` as const;
|
|
15
18
|
return queryCollection(collection).path(slug.value).first();
|
|
16
19
|
},
|
|
17
20
|
);
|
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.125",
|
|
4
4
|
"description": "Nuxt layer/template for creating documentations with the onyx design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"sass-embedded": ">= 1",
|
|
33
33
|
"@sit-onyx/icons": "^1.0.0-beta.26",
|
|
34
34
|
"@sit-onyx/nuxt": "^1.0.0-beta.308",
|
|
35
|
-
"sit-onyx": "^1.0.0-beta.
|
|
35
|
+
"sit-onyx": "^1.0.0-beta.322"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@fontsource-variable/source-code-pro": ">= 5",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"vue": "3.5.20",
|
|
50
50
|
"@sit-onyx/icons": "^1.0.0-beta.26",
|
|
51
51
|
"@sit-onyx/nuxt": "^1.0.0-beta.308",
|
|
52
|
-
"
|
|
53
|
-
"sit-onyx": "^1.0.0-beta.
|
|
52
|
+
"sit-onyx": "^1.0.0-beta.322",
|
|
53
|
+
"@sit-onyx/shared": "^1.0.0-beta.4"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"dev": "pnpm dev:prepare && nuxi dev playground",
|