@sit-onyx/nuxt-docs 0.8.0-dev-20261009123512 → 0.8.0-dev-20261009132111

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.
@@ -15,17 +15,14 @@ export type UseCollectionOptions<TCollection extends keyof Collections = keyof C
15
15
 
16
16
  /**
17
17
  * Composable for loading the collection data for the current route and locale.
18
- * Will throw an 404 error if the collection item could not be found.
19
- * Sets SEO data with `useSeoMeta()` automatically.
20
18
  */
21
19
  export const useCollection = async <TCollection extends keyof Collections = keyof Collections>(
22
20
  options: UseCollectionOptions<TCollection>,
23
21
  ) => {
24
- const nuxtApp = useNuxtApp();
25
22
  const { locale } = useI18n();
26
23
  const route = useRoute();
27
-
28
24
  const collection = computed(() => toValue(options.collection));
25
+
29
26
  const path = computed(() => {
30
27
  let _path = toValue(options.path);
31
28
  if (_path) return _path;
@@ -39,38 +36,19 @@ export const useCollection = async <TCollection extends keyof Collections = keyo
39
36
  return _path;
40
37
  });
41
38
 
42
- const { data: collectionData } = await useAsyncData(
43
- () => `collection-${collection.value}-${path.value}`,
44
- () => queryCollection(collection.value).path(path.value).first(),
45
- );
46
-
47
- const data = computed<Collections[TCollection] | undefined>(() => {
48
- return collectionData.value as Collections[TCollection];
49
- });
39
+ const key = computed(() => `collection-${collection.value}-${path.value}`);
50
40
 
51
- watch(
52
- data,
53
- async (newValue) => {
54
- // if data is "null", the page content was not found. "undefined" means it is not loaded yet
55
- if (newValue !== null) return;
56
- await nuxtApp.runWithContext(() =>
57
- showError({
58
- message: "Page not found",
59
- statusCode: 404,
60
- fatal: true,
61
- }),
62
- );
41
+ return useAsyncData(
42
+ key,
43
+ async () => {
44
+ const data = await queryCollection(collection.value).path(path.value).first();
45
+ if (data) return data;
46
+ throw createError({ status: 404, message: "Page not found", fatal: true });
47
+ },
48
+ {
49
+ // when multiple parallel requests are made for the same page, "defer" will make sure only the first
50
+ // is executed and the result is shared with all other requests
51
+ dedupe: "defer",
63
52
  },
64
- { immediate: true },
65
53
  );
66
-
67
- // runWithContext is needed due to async usage above
68
- await nuxtApp.runWithContext(() => {
69
- useSeoMeta({
70
- title: () => data.value?.seo.title,
71
- description: () => data.value?.seo.description,
72
- });
73
- });
74
-
75
- return { data };
76
54
  };
@@ -6,10 +6,23 @@ definePageMeta({ layout: false });
6
6
 
7
7
  const { locale } = useI18n();
8
8
 
9
- const { data } = await useCollection({
9
+ const { data, error } = await useCollection({
10
10
  collection: computed(() => `content_${locale.value}` as keyof Collections),
11
11
  });
12
12
 
13
+ watch(
14
+ error,
15
+ () => {
16
+ if (error.value) showError(error.value);
17
+ },
18
+ { immediate: true },
19
+ );
20
+
21
+ useSeoMeta({
22
+ title: () => data.value?.seo.title,
23
+ description: () => data.value?.seo.description,
24
+ });
25
+
13
26
  const layout = computed<keyof NuxtLayouts>(() => {
14
27
  const layout = data.value?.meta.layout;
15
28
  if (layout && typeof layout === "string") return layout as keyof NuxtLayouts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sit-onyx/nuxt-docs",
3
- "version": "0.8.0-dev-20261009123512",
3
+ "version": "0.8.0-dev-20261009132111",
4
4
  "description": "Nuxt layer/template for creating documentations with the onyx design system",
5
5
  "bugs": {
6
6
  "url": "https://github.com/SchwarzIT/onyx/issues"
@@ -32,12 +32,12 @@
32
32
  "@nuxtjs/mdc": "~0.23.2",
33
33
  "@playwright/experimental-ct-vue": "1.62.1",
34
34
  "@playwright/test": "1.62.1",
35
- "@sit-onyx/icons": "^1.13.0-dev-20261009123512",
35
+ "@sit-onyx/icons": "^1.13.0-dev-20261009132111",
36
36
  "@sit-onyx/nuxt": "^1.1.2",
37
37
  "@sit-onyx/shared": "^0.1.0",
38
38
  "nuxt": "4.5.2",
39
39
  "sass-embedded": "1.105.1",
40
- "sit-onyx": "^1.21.1-dev-20261009123512",
40
+ "sit-onyx": "^1.21.1-dev-20261009132111",
41
41
  "typescript": "6.0.3",
42
42
  "vue": "3.5.43"
43
43
  },
@@ -48,10 +48,10 @@
48
48
  "@nuxtjs/color-mode": ">= 4",
49
49
  "@nuxtjs/i18n": ">= 10",
50
50
  "@nuxtjs/mdc": ">= 0.20.2",
51
- "@sit-onyx/icons": "^1.13.0-dev-20261009123512",
51
+ "@sit-onyx/icons": "^1.13.0-dev-20261009132111",
52
52
  "@sit-onyx/nuxt": "^1.1.2",
53
53
  "sass-embedded": ">= 1",
54
- "sit-onyx": "^1.21.1-dev-20261009123512"
54
+ "sit-onyx": "^1.21.1-dev-20261009132111"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=20"