@sit-onyx/nuxt-docs 0.3.0 → 0.4.0-dev-20260304095137

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.
@@ -1,4 +1,5 @@
1
1
  <script lang="ts" setup>
2
+ import type { Collections } from "@nuxt/content";
2
3
  import {
3
4
  iconCircleContrast,
4
5
  iconFile,
@@ -25,7 +26,7 @@ watch(isOpen, (open) => {
25
26
  const { data, status } = await useLazyAsyncData(
26
27
  () => `search-sections-${locale.value}`,
27
28
  () => {
28
- const collection = `content_${locale.value}` as const;
29
+ const collection = `content_${locale.value}` as keyof Collections;
29
30
  return queryCollectionSearchSections(collection);
30
31
  },
31
32
  );
@@ -0,0 +1,32 @@
1
+ <script lang="ts" setup>
2
+ import type { TocLink } from "@nuxtjs/mdc";
3
+
4
+ const props = defineProps<{
5
+ /**
6
+ * Table of contents links, e.g. received from `queryCollection()`.
7
+ */
8
+ links: TocLink[];
9
+ }>();
10
+ </script>
11
+
12
+ <template>
13
+ <OnyxUnstableTableOfContents>
14
+ <OnyxUnstableTableOfContentsItem
15
+ v-for="link in props.links"
16
+ :key="link.id"
17
+ :link="`#${link.id}`"
18
+ >
19
+ {{ link.text }}
20
+
21
+ <template v-if="link.children?.length" #children>
22
+ <OnyxUnstableTableOfContentsItem
23
+ v-for="child in link.children"
24
+ :key="child.id"
25
+ :link="`#${child.id}`"
26
+ >
27
+ {{ child.text }}
28
+ </OnyxUnstableTableOfContentsItem>
29
+ </template>
30
+ </OnyxUnstableTableOfContentsItem>
31
+ </OnyxUnstableTableOfContents>
32
+ </template>
@@ -0,0 +1,24 @@
1
+ import type { Collections } from "@nuxt/content";
2
+
3
+ /**
4
+ * Composable for loading the collection content for the current route and locale.
5
+ */
6
+ export const useCollection = () => {
7
+ const route = useRoute();
8
+ const { locale } = useI18n();
9
+
10
+ const slug = computed(() => {
11
+ const path = Array.isArray(route.params.slug)
12
+ ? route.params.slug.join("/")
13
+ : (route.params.slug ?? "");
14
+ return path.startsWith("/") ? path : `/${path}`;
15
+ });
16
+
17
+ return useAsyncData(
18
+ () => `page-${slug.value}-${locale.value}`,
19
+ () => {
20
+ const collection = `content_${locale.value}` as keyof Collections;
21
+ return queryCollection(collection).path(slug.value).first();
22
+ },
23
+ );
24
+ };
@@ -38,6 +38,9 @@ const slots = defineSlots<{
38
38
  }>();
39
39
 
40
40
  const { navigation, previousRootItem } = await useSidebarNavigation();
41
+
42
+ const collection = await useCollection();
43
+ const toc = computed(() => collection.data.value?.body.toc?.links ?? []);
41
44
  </script>
42
45
 
43
46
  <template>
@@ -76,7 +79,13 @@ const { navigation, previousRootItem } = await useSidebarNavigation();
76
79
  </OnyxSidebar>
77
80
  </template>
78
81
 
79
- <slot></slot>
82
+ <div class="content">
83
+ <div>
84
+ <slot></slot>
85
+ </div>
86
+
87
+ <TableOfContents v-if="toc.length" class="content__toc" :links="toc" />
88
+ </div>
80
89
 
81
90
  <template v-if="!!slots.footer" #footer>
82
91
  <slot name="footer"></slot>
@@ -89,9 +98,7 @@ const { navigation, previousRootItem } = await useSidebarNavigation();
89
98
  </template>
90
99
 
91
100
  <style lang="scss" scoped>
92
- .content {
93
- white-space: pre-line;
94
- }
101
+ @use "sit-onyx/breakpoints.scss";
95
102
 
96
103
  .sidebar {
97
104
  &__empty {
@@ -103,4 +110,29 @@ const { navigation, previousRootItem } = await useSidebarNavigation();
103
110
  justify-content: flex-start;
104
111
  }
105
112
  }
113
+
114
+ .content {
115
+ /** Gap between page content and TOC. Equivalent to one grid column + 2 * grid gutter/gap */
116
+ --onyx-content-toc-gap: calc(2 * var(--onyx-grid-gutter) + (100 / var(--onyx-grid-columns)) * 1%);
117
+ display: grid;
118
+ gap: var(--onyx-content-toc-gap);
119
+
120
+ // see: https://storybook.onyx.schwarz/?path=/docs/navigation-tableofcontents--docs
121
+ grid-template-columns: 1fr minmax(8rem, 15rem);
122
+
123
+ &__toc {
124
+ position: sticky;
125
+ top: var(--onyx-grid-margin-vertical);
126
+ height: calc(100vh - var(--onyx-nav-bar-height) - 2 * var(--onyx-grid-margin-vertical));
127
+ }
128
+
129
+ // hide TOC on smaller screens
130
+ @include breakpoints.container(max, md) {
131
+ grid-template-columns: 1fr;
132
+
133
+ .content__toc {
134
+ display: none;
135
+ }
136
+ }
137
+ }
106
138
  </style>
@@ -1,23 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  definePageMeta({ layout: "sidebar" });
3
3
 
4
- const route = useRoute();
5
- const { locale } = useI18n();
6
-
7
- const slug = computed(() => {
8
- const path = Array.isArray(route.params.slug)
9
- ? route.params.slug.join("/")
10
- : (route.params.slug ?? "");
11
- return path.startsWith("/") ? path : `/${path}`;
12
- });
13
-
14
- const collection = await useAsyncData(
15
- () => `page-${slug.value}-${locale.value}`,
16
- () => {
17
- const collection = `content_${locale.value}` as const;
18
- return queryCollection(collection).path(slug.value).first();
19
- },
20
- );
4
+ const collection = await useCollection();
21
5
 
22
6
  watch(
23
7
  () => collection.data.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sit-onyx/nuxt-docs",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-dev-20260304095137",
4
4
  "description": "Nuxt layer/template for creating documentations with the onyx design system",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
@@ -31,9 +31,9 @@
31
31
  "@nuxtjs/i18n": ">= 10",
32
32
  "@nuxtjs/mdc": ">= 0.20.1",
33
33
  "sass-embedded": ">= 1",
34
- "@sit-onyx/icons": "^1.6.0",
34
+ "@sit-onyx/icons": "^1.7.0",
35
35
  "@sit-onyx/nuxt": "^1.0.1",
36
- "sit-onyx": "^1.8.0"
36
+ "sit-onyx": "^1.10.0-dev-20260304095137"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@fontsource-variable/source-code-pro": ">= 5",
@@ -48,11 +48,11 @@
48
48
  "nuxt": "4.3.1",
49
49
  "sass-embedded": "1.97.3",
50
50
  "typescript": "5.9.3",
51
- "vue": "3.5.28",
52
- "@sit-onyx/icons": "^1.6.0",
51
+ "vue": "3.5.29",
53
52
  "@sit-onyx/nuxt": "^1.0.1",
53
+ "sit-onyx": "^1.10.0-dev-20260304095137",
54
54
  "@sit-onyx/shared": "^0.1.0",
55
- "sit-onyx": "^1.8.0"
55
+ "@sit-onyx/icons": "^1.7.0"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "pnpm dev:prepare && nuxi dev playground",