@devite/nuxt-sanity 1.0.3 → 1.1.1
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/dist/module.json +1 -1
- package/dist/runtime/components/SanityPage.vue +3 -3
- package/dist/runtime/utils/projections.d.ts +3 -2
- package/dist/runtime/utils/projections.js +12 -18
- package/dist/runtime/utils/resolveImageAssetById.d.ts +2 -0
- package/dist/runtime/utils/resolveImageAssetById.js +5 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -17,7 +17,7 @@ import type { Home } from '../types/singletons/Home'
|
|
|
17
17
|
import type { Page } from '../types/documents/Page'
|
|
18
18
|
import type { NotFound } from '../types/singletons/NotFound'
|
|
19
19
|
import type { GlobalSEO } from '../types/objects/global/GlobalSEO'
|
|
20
|
-
import {
|
|
20
|
+
import { IMAGE_WITHOUT_PREVIEW_PROJECTION } from '../utils/projections'
|
|
21
21
|
import { useHead, useRoute, useRuntimeConfig, useSeoMeta } from '#app'
|
|
22
22
|
import { computed } from '#imports'
|
|
23
23
|
|
|
@@ -25,12 +25,12 @@ const { baseURL } = useRuntimeConfig().public
|
|
|
25
25
|
|
|
26
26
|
const path = useRoute().fullPath
|
|
27
27
|
const groqFilter = path === '/' ? '_type == "home"' : `_type == "page" && slug.current == "${path.substring(1)}"`
|
|
28
|
-
const { data: sanityData } = await useSanityQuery<Home | Page | NotFound>(groq`*[(${groqFilter}) || _type == "notFound"][0] { _id, _type, title, modules, seo { _type, indexable, title, shortTitle, description, image ${
|
|
28
|
+
const { data: sanityData } = await useSanityQuery<Home | Page | NotFound>(groq`*[(${groqFilter}) || _type == "notFound"][0] { _id, _type, title, modules, seo { _type, indexable, title, shortTitle, description, image ${IMAGE_WITHOUT_PREVIEW_PROJECTION} } }`)
|
|
29
29
|
|
|
30
30
|
const seo = computed(() => sanityData.value?.seo)
|
|
31
31
|
const url = computed(() => baseURL + (sanityData.value?.slug || '/'))
|
|
32
32
|
|
|
33
|
-
const { data: globalSEO } = await useSanityQuery<GlobalSEO>(groq`*[_type == 'settings'][0].seo { siteName, image ${
|
|
33
|
+
const { data: globalSEO } = await useSanityQuery<GlobalSEO>(groq`*[_type == 'settings'][0].seo { siteName, image ${IMAGE_WITHOUT_PREVIEW_PROJECTION} }`)
|
|
34
34
|
const image: ComputedRef<ImageAsset> = computed(() => sanityData.value?.image?.asset || globalSEO.value?.image?.asset)
|
|
35
35
|
|
|
36
36
|
useHead({
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const IMAGE_ASSET_PROJECTION: any;
|
|
2
|
+
export declare const IMAGE_WITHOUT_PREVIEW_PROJECTION: any;
|
|
3
|
+
export declare const IMAGE_WITH_PREVIEW_PROJECTION: any;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { groq } from "@nuxtjs/sanity/runtime/groq";
|
|
2
|
-
export const
|
|
2
|
+
export const IMAGE_ASSET_PROJECTION = groq`{
|
|
3
3
|
_type,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
mimeType,
|
|
10
|
-
metadata { dimensions }
|
|
11
|
-
}
|
|
4
|
+
_id,
|
|
5
|
+
url,
|
|
6
|
+
altText,
|
|
7
|
+
mimeType,
|
|
8
|
+
metadata { lqip, dimensions }
|
|
12
9
|
}`;
|
|
13
|
-
export const
|
|
10
|
+
export const IMAGE_WITHOUT_PREVIEW_PROJECTION = groq`{
|
|
14
11
|
_type,
|
|
15
|
-
asset-> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
mimeType,
|
|
21
|
-
metadata { lqip, dimensions }
|
|
22
|
-
}
|
|
12
|
+
asset-> ${IMAGE_ASSET_PROJECTION.replace("lqip, ", "")},
|
|
13
|
+
}`;
|
|
14
|
+
export const IMAGE_WITH_PREVIEW_PROJECTION = groq`{
|
|
15
|
+
_type,
|
|
16
|
+
asset-> ${IMAGE_ASSET_PROJECTION}
|
|
23
17
|
}`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useSanityQuery } from "@nuxtjs/sanity/runtime/composables";
|
|
2
|
+
import { IMAGE_ASSET_PROJECTION } from "./projections.js";
|
|
3
|
+
export const resolveImageAssetById = async (id) => {
|
|
4
|
+
return await useSanityQuery(`*[_type == "sanity.imageAsset" && _id == $assetId][0] ${IMAGE_ASSET_PROJECTION}`, { assetId: id });
|
|
5
|
+
};
|
package/package.json
CHANGED