@gluhar/app 2.5.1 → 2.6.0
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,28 @@
|
|
|
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.6.0](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.2...@gluhar/app@2.6.0) (2025-02-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🚀 Enhancements
|
|
10
|
+
|
|
11
|
+
- SanityImg component ([04d86e2](https://github.com/gluharry/gluhar/commit/04d86e2d55ff03195a92efb1df7bc35c92e3394c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.5.2](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.1...@gluhar/app@2.5.2) (2025-01-28)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### 🩹 Fixes
|
|
21
|
+
|
|
22
|
+
- UseSanityPage types ([0a053de](https://github.com/gluharry/gluhar/commit/0a053ded933cec73dd360295b2f629d2c84c4b44))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [2.5.1](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.0...@gluhar/app@2.5.1) (2025-01-28)
|
|
7
29
|
|
|
8
30
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, installModule, addImportsDir } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
2
|
import defu from 'defu';
|
|
3
3
|
|
|
4
4
|
const module = defineNuxtModule({
|
|
@@ -23,6 +23,7 @@ const module = defineNuxtModule({
|
|
|
23
23
|
await installModule("@gluhar/sanity", sanity);
|
|
24
24
|
}
|
|
25
25
|
addImportsDir(resolve("runtime/composables"));
|
|
26
|
+
addComponentsDir({ path: resolve("runtime/components") });
|
|
26
27
|
addImportsDir(resolve("runtime/utils"));
|
|
27
28
|
addImportsDir(resolve("runtime/stores"));
|
|
28
29
|
nuxt.options.vite = defu(nuxt.options.vite, {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from "#imports";
|
|
3
|
+
import type { SanityImage } from "@gluhar/sanity/types";
|
|
4
|
+
import imageUrlBuilder from "@sanity/image-url";
|
|
5
|
+
import type { ImageFormat } from "@sanity/image-url/lib/types/types";
|
|
6
|
+
import sanityConfig from "~/config/sanity.config";
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
image?: SanityImage;
|
|
11
|
+
by?: "w" | "h";
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
format?: ImageFormat | null;
|
|
15
|
+
}>(),
|
|
16
|
+
{ by: "w" },
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const { l } = useMessages();
|
|
20
|
+
|
|
21
|
+
const builder = imageUrlBuilder(sanityConfig);
|
|
22
|
+
const urlFor = (source: SanityImage) => builder.image(source);
|
|
23
|
+
|
|
24
|
+
const imgRef = ref<HTMLImageElement | null>(null);
|
|
25
|
+
const src = computed(() => {
|
|
26
|
+
const { width, height } = imgRef.value?.getBoundingClientRect() || {
|
|
27
|
+
width: undefined,
|
|
28
|
+
height: undefined,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (!props.image || (!width && !height)) return undefined;
|
|
32
|
+
|
|
33
|
+
let url = urlFor(props.image);
|
|
34
|
+
|
|
35
|
+
if (props.width) url = url.width(props.width);
|
|
36
|
+
else if (width && props.by === "w") url = url.width(Math.ceil(width));
|
|
37
|
+
|
|
38
|
+
if (props.height) url = url.height(props.height);
|
|
39
|
+
else if (height && props.by === "h") url = url.height(Math.ceil(height));
|
|
40
|
+
|
|
41
|
+
url = url.format(props.format ?? "webp");
|
|
42
|
+
url = url.quality(100);
|
|
43
|
+
|
|
44
|
+
// const dpr = window.devicePixelRatio;
|
|
45
|
+
url = url.dpr(1.2);
|
|
46
|
+
|
|
47
|
+
return url.url();
|
|
48
|
+
});
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<img
|
|
53
|
+
class="object-cover"
|
|
54
|
+
:src
|
|
55
|
+
:alt="l(image.caption) || l(image.alt)"
|
|
56
|
+
ref="imgRef"
|
|
57
|
+
v-if="image"
|
|
58
|
+
/>
|
|
59
|
+
</template>
|
|
@@ -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
|
|
18
|
-
status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus
|
|
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
|
|
17
|
+
const query2 = groq`
|
|
19
18
|
*[_type == "${type}" && slug.current == "${sl[1]}"]{
|
|
20
19
|
${options.query}
|
|
21
20
|
}[0]
|
|
22
21
|
`;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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.
|
|
3
|
+
"version": "2.6.0",
|
|
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",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@gluhar/theme": "^2.0.2",
|
|
44
44
|
"@nuxt/kit": "^3.13.1",
|
|
45
45
|
"@pinia/nuxt": "^0.5.4",
|
|
46
|
+
"@sanity/image-url": "^1.1.0",
|
|
46
47
|
"defu": "^6.1.4",
|
|
47
48
|
"pinia": "^2.2.2"
|
|
48
49
|
},
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"nuxt": "^3.13.1",
|
|
59
60
|
"vitest": "^2.0.5"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "48de7c15bdc9a8186cfb49833ff588c2347a2c18"
|
|
62
63
|
}
|