@devite/nuxt-sanity 1.0.3 → 1.1.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
3
  "configKey": "@devite/nuxt-sanity",
4
- "version": "1.0.3",
4
+ "version": "1.1.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "unknown"
@@ -1,2 +1,3 @@
1
- export declare const PICTURE_PROJECTION: any;
2
- export declare const IMAGE_PROJECTION: any;
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 PICTURE_PROJECTION = groq`{
2
+ export const IMAGE_ASSET_PROJECTION = groq`{
3
3
  _type,
4
- asset-> {
5
- _type,
6
- _id,
7
- url,
8
- altText,
9
- mimeType,
10
- metadata { dimensions }
11
- }
4
+ _id,
5
+ url,
6
+ altText,
7
+ mimeType,
8
+ metadata { lqip, dimensions }
12
9
  }`;
13
- export const IMAGE_PROJECTION = groq`{
10
+ export const IMAGE_WITHOUT_PREVIEW_PROJECTION = groq`{
14
11
  _type,
15
- asset-> {
16
- _type,
17
- _id,
18
- url,
19
- altText,
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,2 @@
1
+ import type { ImageAsset } from '@sanity/types';
2
+ export declare const resolveImageAssetById: (id: string) => Promise<ImageAsset | undefined>;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Optimizes the configuration for @nuxt/sanity and provides additional helper components.",
5
5
  "repository": "devite-io/nuxt-sanity",
6
6
  "license": "MIT",