@devite/nuxt-sanity 2.7.0 → 2.8.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/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { defineNuxtModule, createResolver, addPlugin, addServerHandler, addImpor
|
|
|
3
3
|
import defu from 'defu';
|
|
4
4
|
|
|
5
5
|
const name = "@devite/nuxt-sanity";
|
|
6
|
-
const version = "2.
|
|
6
|
+
const version = "2.8.0";
|
|
7
7
|
|
|
8
8
|
const CONFIG_KEY = "sanity";
|
|
9
9
|
const module = defineNuxtModule({
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
:width="imageAsset.metadata.dimensions.width"
|
|
7
7
|
:height="imageAsset.metadata.dimensions.height"
|
|
8
8
|
:alt="imageAsset.altText as (string | undefined)"
|
|
9
|
-
:placeholder="loading === 'eager' ? undefined : imageAsset.metadata.lqip"
|
|
9
|
+
:placeholder="loading === 'eager' || !lqip ? undefined : imageAsset.metadata.lqip"
|
|
10
10
|
:loading="loading || 'lazy'"
|
|
11
11
|
:format="imageAsset.mimeType === 'image/svg+xml' ? undefined : 'webp'"
|
|
12
12
|
draggable="false"
|
|
@@ -22,13 +22,14 @@ import { resolveImageAssetById } from '../utils/resolveImageAssetById'
|
|
|
22
22
|
const props = defineProps<{
|
|
23
23
|
asset?: ImageAsset | Reference | null
|
|
24
24
|
loading?: 'eager' | 'lazy'
|
|
25
|
+
lqip?: boolean
|
|
25
26
|
}>()
|
|
26
27
|
const imageAsset = ref<ImageAsset | null>(null)
|
|
27
28
|
let unwatchFunc = undefined as (() => void) | undefined
|
|
28
29
|
|
|
29
30
|
async function resolveImageAsset() {
|
|
30
31
|
if (props.asset?._ref) {
|
|
31
|
-
const assetRef = await resolveImageAssetById((props.asset as Reference)._ref)
|
|
32
|
+
const assetRef = await resolveImageAssetById((props.asset as Reference)._ref, props.lqip || false)
|
|
32
33
|
|
|
33
34
|
imageAsset.value = assetRef.value
|
|
34
35
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ImageAsset } from '@sanity/types';
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
|
-
export declare const resolveImageAssetById: (id: string) => Promise<Ref<ImageAsset | null>>;
|
|
3
|
+
export declare const resolveImageAssetById: (id: string, lqip?: boolean) => Promise<Ref<ImageAsset | null>>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMAGE_ASSET_PROJECTION } from "./projections.js";
|
|
2
2
|
import { useSanityQuery } from "#imports";
|
|
3
|
-
export const resolveImageAssetById = async (id) => {
|
|
3
|
+
export const resolveImageAssetById = async (id, lqip) => {
|
|
4
|
+
const projection = lqip ? IMAGE_ASSET_PROJECTION : IMAGE_ASSET_PROJECTION.replace("lqip, ", "");
|
|
4
5
|
return (await useSanityQuery(
|
|
5
|
-
`*[_type == "sanity.imageAsset" && _id == $assetId][0] ${
|
|
6
|
+
`*[_type == "sanity.imageAsset" && _id == $assetId][0] ${projection}`,
|
|
6
7
|
{ assetId: id }
|
|
7
8
|
)).data;
|
|
8
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devite/nuxt-sanity",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Advanced Sanity integration for Nuxt.js.",
|
|
5
5
|
"repository": "devite-io/nuxt-sanity",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@sanity/core-loader": "^1.7.22",
|
|
29
29
|
"@sanity/preview-url-secret": "^2.0.5",
|
|
30
30
|
"@sanity/types": "^3.68.3",
|
|
31
|
-
"@sanity/visual-editing": "^2.11.
|
|
31
|
+
"@sanity/visual-editing": "^2.11.3",
|
|
32
32
|
"defu": "^6.1.4",
|
|
33
33
|
"ofetch": "^1.4.1",
|
|
34
34
|
"ohash": "^1.1.4",
|