@gluhar/app 2.5.1 → 2.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.5.2](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.1...@gluhar/app@2.5.2) (2025-01-28)
7
+
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - UseSanityPage types ([0a053de](https://github.com/gluharry/gluhar/commit/0a053ded933cec73dd360295b2f629d2c84c4b44))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.5.1](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.0...@gluhar/app@2.5.1) (2025-01-28)
7
18
 
8
19
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
3
  "configKey": "gluhar",
4
- "version": "2.5.1",
4
+ "version": "2.5.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
@@ -14,7 +14,10 @@ type PageTypes<PI extends PageInterfaces> = Record<keyof PI, {
14
14
  export declare const useSanityPage: <PI extends PageInterfaces = {
15
15
  page: Page;
16
16
  }, PT extends PageTypes<PI> = PageTypes<PI>>(types?: PT, slug?: string | string[]) => Promise<{
17
- page: import("vue").Ref<PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null, PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null> | import("vue").Ref<Page | null, Page | null> | undefined;
18
- status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus> | undefined;
17
+ page: import("vue").Ref<PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null, PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null>;
18
+ status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus>;
19
+ } | {
20
+ page: import("vue").Ref<Page | null, Page | null>;
21
+ status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus>;
19
22
  }>;
20
23
  export {};
@@ -10,23 +10,29 @@ export const useSanityPage = async (types, slug) => {
10
10
  const route = useRoute();
11
11
  const s = slug ? slug : route.params.slug;
12
12
  const sl = Array.isArray(s) ? s : [s];
13
- let page, status;
14
13
  if (types && sl.length > 1) {
15
14
  for (const type in types) {
16
15
  const options = types[type];
17
16
  if (sl[0] === options.slug) {
18
- const query = groq`
17
+ const query2 = groq`
19
18
  *[_type == "${type}" && slug.current == "${sl[1]}"]{
20
19
  ${options.query}
21
20
  }[0]
22
21
  `;
23
- const q = await useSanityQueryWithPreview(query);
24
- page = q.data;
25
- status = q.status;
22
+ const { data: page2, status: status2 } = await useSanityQueryWithPreview(query2);
23
+ useHead({
24
+ link: [
25
+ {
26
+ rel: "canonical",
27
+ href: getCanonicalUrl(page2?.value)
28
+ }
29
+ ]
30
+ });
31
+ return { page: page2, status: status2 };
26
32
  }
27
33
  }
28
- } else {
29
- const pageQuery = groq`
34
+ }
35
+ const pageQuery = groq`
30
36
  ...,
31
37
  content[]{
32
38
  ...,
@@ -40,20 +46,15 @@ export const useSanityPage = async (types, slug) => {
40
46
  }
41
47
  }
42
48
  `;
43
- const query = groq`
49
+ const query = groq`
44
50
  *[_type == "page" && slug.current == "${sl[0] ? sl?.join("/") : "/"}"]{
45
51
  ${types?.page?.query ?? pageQuery}
46
52
  }[0]
47
53
  `;
48
- const q = await useSanityQueryWithPreview(query);
49
- if (q.data.value) q.data.value._type = "page";
50
- page = q.data;
51
- status = q.status;
52
- }
54
+ const { data: page, status } = await useSanityQueryWithPreview(query);
55
+ if (page.value) page.value._type = "page";
53
56
  useHead({
54
- link: [
55
- { rel: "canonical", href: getCanonicalUrl(page?.value) }
56
- ]
57
+ link: [{ rel: "canonical", href: getCanonicalUrl(page.value) }]
57
58
  });
58
59
  return { page, status };
59
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Gluhar main package. This combines and configures @gluhar/theme, @gluhar/i18n, @gluhar/sanity and @gluhar/core into one main package. Provides numerous components, composables, utils and types.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -58,5 +58,5 @@
58
58
  "nuxt": "^3.13.1",
59
59
  "vitest": "^2.0.5"
60
60
  },
61
- "gitHead": "03d4d85e4be0a9d1220c16e2c1029c3aefedda01"
61
+ "gitHead": "f19d2e2a0f29905d9258938bd9239ab1c7e4e782"
62
62
  }