@devite/nuxt-sanity 2.8.3 → 2.9.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.d.mts CHANGED
@@ -4,9 +4,9 @@ import { ClientConfig } from '@sanity/client';
4
4
  import { Slug, ImageAsset, PortableTextBlock } from '@sanity/types';
5
5
 
6
6
  type ModuleOptions = ClientConfig & {
7
- projectId: string;
7
+ projectId?: string;
8
8
  /** @default "production" */
9
- dataset: string;
9
+ dataset?: string;
10
10
  /** @default { cachingEnabled: true, cacheBaseUrl: "http://localhost:3000", assetEndpoint: "/_sanity/cache/asset", queryEndpoint: "/_sanity/cache/query", webhookEndpoint: "/_sanity/cache/invalidate" } */
11
11
  minimalClient?: boolean | {
12
12
  cachingEnabled?: boolean;
package/dist/module.d.ts CHANGED
@@ -4,9 +4,9 @@ import { ClientConfig } from '@sanity/client';
4
4
  import { Slug, ImageAsset, PortableTextBlock } from '@sanity/types';
5
5
 
6
6
  type ModuleOptions = ClientConfig & {
7
- projectId: string;
7
+ projectId?: string;
8
8
  /** @default "production" */
9
- dataset: string;
9
+ dataset?: string;
10
10
  /** @default { cachingEnabled: true, cacheBaseUrl: "http://localhost:3000", assetEndpoint: "/_sanity/cache/asset", queryEndpoint: "/_sanity/cache/query", webhookEndpoint: "/_sanity/cache/invalidate" } */
11
11
  minimalClient?: boolean | {
12
12
  cachingEnabled?: boolean;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.8.3",
3
+ "version": "2.9.0",
4
4
  "configKey": "sanity",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
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.8.3";
6
+ const version = "2.9.0";
7
7
 
8
8
  const CONFIG_KEY = "sanity";
9
9
  const module = defineNuxtModule({
@@ -147,8 +147,7 @@ const module = defineNuxtModule({
147
147
  const sharedImports = [
148
148
  // clients
149
149
  { name: "default", as: "SanityClient", from: resolve("runtime/client/SanityClient") },
150
- { name: "default", as: "DefaultSanityClient", from: resolve("runtime/client/DefaultSanityClient") },
151
- { name: "default", as: "MinimalSanityClient", from: resolve("runtime/client/MinimalSanityClient") },
150
+ { name: "SanityClientType", as: "SanityClientType", from: resolve("runtime/client/SanityClient") },
152
151
  // helper methods
153
152
  { name: "groq", from: resolve("runtime/utils/groq") },
154
153
  // projections
@@ -1,7 +1,7 @@
1
1
  import { type ClientPerspective, type QueryParams, type SanityClient as SanityClientType } from '@sanity/client';
2
2
  import type { ModuleOptions } from '@devite/nuxt-sanity';
3
3
  import { type QueryStore } from '@sanity/core-loader';
4
- import SanityClient from './SanityClient.js';
4
+ import { SanityClient } from '#imports';
5
5
  declare class DefaultSanityClient extends SanityClient {
6
6
  readonly client: SanityClientType;
7
7
  queryStore: QueryStore | null;
@@ -2,7 +2,7 @@ import {
2
2
  createClient
3
3
  } from "@sanity/client";
4
4
  import { createQueryStore as createCoreQueryStore } from "@sanity/core-loader";
5
- import SanityClient from "./SanityClient.js";
5
+ import { SanityClient } from "#imports";
6
6
  class DefaultSanityClient extends SanityClient {
7
7
  client;
8
8
  queryStore = null;
@@ -1,6 +1,6 @@
1
1
  import type { ClientPerspective, QueryParams } from '@sanity/client';
2
2
  import type { ModuleOptions } from '@devite/nuxt-sanity';
3
- import SanityClient from './SanityClient.js';
3
+ import { SanityClient } from '#imports';
4
4
  declare class MinimalSanityClient extends SanityClient {
5
5
  private readonly queryPath;
6
6
  private readonly fetchOptions;
@@ -1,5 +1,5 @@
1
1
  import { $fetch } from "ofetch";
2
- import SanityClient from "./SanityClient.js";
2
+ import { SanityClient } from "#imports";
3
3
  const API_HOST = "api.sanity.io";
4
4
  const API_CDN_HOST = "apicdn.sanity.io";
5
5
  class MinimalSanityClient extends SanityClient {
@@ -17,7 +17,7 @@
17
17
  <script setup lang="ts">
18
18
  import type { ImageAsset, Reference } from '@sanity/types'
19
19
  import { ref, watch } from 'vue'
20
- import { resolveImageAssetById } from '../utils/resolveImageAssetById'
20
+ import { resolveImageAssetById } from '#imports'
21
21
 
22
22
  const props = defineProps<{
23
23
  asset?: ImageAsset | Reference | null
@@ -4,7 +4,7 @@
4
4
  :target="data.newWindow ? '_blank' : '_self'"
5
5
  :title="data.linkTitle"
6
6
  :rel="data.relationship"
7
- external
7
+ :external="!data.url.startsWith('/')"
8
8
  >
9
9
  <slot />
10
10
  </NuxtLink>
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <NuxtLink
3
3
  :to="resolvedLink?.slug"
4
- :title="data.linkTitle"
5
- :rel="data.relationship"
4
+ :title="resolvedLink?.linkTitle"
5
+ :rel="resolvedLink?.relationship"
6
6
  >
7
7
  <slot />
8
8
  </NuxtLink>
@@ -12,7 +12,7 @@
12
12
  import type { Reference } from '@sanity/types'
13
13
  import type { LinkInternal } from '@devite/nuxt-sanity'
14
14
  import type { Ref } from 'vue'
15
- import { resolveInternalLink } from '../utils/resolveInternalLink'
15
+ import { resolveInternalLink } from '#imports'
16
16
 
17
17
  const { data } = defineProps<{ data: LinkInternal | { reference: Reference } }>()
18
18
  const resolvedLink: Ref<LinkInternal | null> | LinkInternal = 'reference' in data
@@ -14,9 +14,7 @@ import { computed, type ComputedRef } from 'vue'
14
14
  import type { ImageAsset } from '@sanity/types'
15
15
  import type { GlobalSEO, Home, NotFound, Page } from '@devite/nuxt-sanity'
16
16
  import { setResponseStatus } from 'h3'
17
- import { IMAGE_WITHOUT_PREVIEW_PROJECTION } from '../utils/projections'
18
- import { groq } from '../utils/groq'
19
- import { useHead, useRequestEvent, useRoute, useRuntimeConfig, useSanityQuery, useSeoMeta } from '#imports'
17
+ import { IMAGE_WITHOUT_PREVIEW_PROJECTION, groq, useHead, useRequestEvent, useRoute, useRuntimeConfig, useSanityQuery, useSeoMeta } from '#imports'
20
18
 
21
19
  const path = useRoute().path
22
20
  const groqFilter = path === '/' ? '_type == "home"' : `_type == "page" && slug.current == $slug`
@@ -3,7 +3,6 @@ import { useAsyncData, useLazyAsyncData } from "nuxt/app";
3
3
  import { reactive, ref } from "vue";
4
4
  import defu from "defu";
5
5
  import useSanityClient from "../utils/useSanityClient.js";
6
- import useServerSanityClient from "../server/utils/useSanityClient.js";
7
6
  import { useSanityVisualEditingState } from "./useSanityVisualEditingState.js";
8
7
  import { useRuntimeConfig } from "#imports";
9
8
  export function useLazySanityQuery(query, params = {}, options = {}) {
@@ -31,7 +30,7 @@ export function useSanityQuery(query, _params = {}, options = {}, lazy = false)
31
30
  }
32
31
  const fetchFunc = () => new Promise((resolve) => {
33
32
  (visualEditingEnabled ? import("../utils/visualEditing/fetchSanityData") : import("../utils/default/fetchSanityData")).then(async ({ fetchSanityData }) => {
34
- const client = import.meta.server ? useServerSanityClient(clientType, sanityConfig) : await useSanityClient(visualEditingEnabled, clientType, sanityConfig);
33
+ const client = import.meta.server ? (await import("../server/utils/useSanityClient.js")).default(clientType, sanityConfig) : await useSanityClient(visualEditingEnabled, clientType, sanityConfig);
35
34
  function onDataUpdate(resultData, resultSourceMap, resultEncodeDataAttribute) {
36
35
  if (resultEncodeDataAttribute)
37
36
  encodeDataAttribute.value = resultEncodeDataAttribute;
@@ -1,4 +1,3 @@
1
1
  import type { ModuleOptions } from '@devite/nuxt-sanity';
2
- import type SanityClient from '../../client/SanityClient.js';
3
- import type { SanityClientType } from '../../client/SanityClient.js';
2
+ import type { SanityClient, SanityClientType } from '#imports';
4
3
  export default function useSanityClient(type?: SanityClientType, config?: ModuleOptions): SanityClient;
@@ -1,6 +1,6 @@
1
1
  import defu from "defu";
2
- import DefaultSanityClient from "../../client/DefaultSanityClient.js";
3
2
  import MinimalSanityClient from "../../client/MinimalSanityClient.js";
3
+ import DefaultSanityClient from "../../client/DefaultSanityClient.js";
4
4
  import { useRuntimeConfig } from "#imports";
5
5
  const clients = {};
6
6
  export default function useSanityClient(type, config) {
@@ -1,5 +1,5 @@
1
1
  import type { ClientPerspective, ContentSourceMap, QueryParams } from '@sanity/client';
2
2
  import type { Reactive } from 'vue';
3
3
  import type { EncodeDataAttributeFunction } from '@sanity/core-loader/encode-data-attribute';
4
- import type SanityClient from '../../client/SanityClient.js';
4
+ import type { SanityClient } from '#imports';
5
5
  export declare function fetchSanityData<T>(query: string, params: Reactive<QueryParams> | undefined, client: SanityClient, perspective: ClientPerspective, callback: (data: T | null, sourceMap?: ContentSourceMap, encodeDataAttribute?: EncodeDataAttributeFunction) => void): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { groq } from "./groq.js";
1
+ import { groq } from "#imports";
2
2
  export const IMAGE_ASSET_PROJECTION = groq`{
3
3
  _type,
4
4
  _id,
@@ -17,7 +17,9 @@ export const IMAGE_WITH_PREVIEW_PROJECTION = groq`{
17
17
  asset-> ${IMAGE_ASSET_PROJECTION}
18
18
  }`;
19
19
  export const LINK_PROJECTION = groq`{
20
- '_type': @._type,
20
+ _type,
21
21
  _type == 'linkExternal' => { url, newWindow },
22
- _type == 'linkInternal' => { 'slug': '/' + coalesce(@.reference->slug.current, '') }
22
+ _type == 'linkInternal' => { 'slug': '/' + coalesce(reference->slug.current, '') },
23
+ linkTitle,
24
+ relationship
23
25
  }`;
@@ -1,5 +1,4 @@
1
- import { IMAGE_ASSET_PROJECTION } from "./projections.js";
2
- import { useSanityQuery } from "#imports";
1
+ import { IMAGE_ASSET_PROJECTION, useSanityQuery } from "#imports";
3
2
  export const resolveImageAssetById = async (id, lqip) => {
4
3
  const projection = lqip ? IMAGE_ASSET_PROJECTION : IMAGE_ASSET_PROJECTION.replace("lqip, ", "");
5
4
  return (await useSanityQuery(
@@ -1,7 +1,7 @@
1
1
  import { useSanityQuery } from "#imports";
2
2
  export const resolveInternalLink = async (reference) => {
3
3
  return (await useSanityQuery(
4
- `*[_id == $documentId][0] { '_type': 'linkInternal', 'slug': '/' + coalesce(slug.current, '') }`,
4
+ `*[_id == $documentId][0] { '_type': 'linkInternal', 'slug': '/' + coalesce(slug.current, ''), linkTitle, relationship }`,
5
5
  { documentId: reference._ref }
6
6
  )).data;
7
7
  };
@@ -1,4 +1,3 @@
1
1
  import type { ModuleOptions } from '@devite/nuxt-sanity';
2
- import type SanityClient from '../client/SanityClient.js';
3
- import type { SanityClientType } from '../client/SanityClient.js';
2
+ import type { SanityClientType, SanityClient } from '#imports';
4
3
  export default function useSanityClient(visualEditing: boolean, type: SanityClientType, config: ModuleOptions): Promise<SanityClient>;
@@ -1,5 +1,5 @@
1
1
  import type { ClientPerspective, ContentSourceMap, QueryParams } from '@sanity/client';
2
2
  import type { Reactive } from 'vue';
3
3
  import { type EncodeDataAttributeFunction } from '@sanity/core-loader/encode-data-attribute';
4
- import type SanityClient from '../../client/SanityClient.js';
4
+ import type { SanityClient } from '#imports';
5
5
  export declare function fetchSanityData<T>(query: string, params: Reactive<QueryParams> | undefined, client: SanityClient, perspective: ClientPerspective, callback: (data: T | null, sourceMap?: ContentSourceMap, encodeDataAttribute?: EncodeDataAttributeFunction) => void): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { type Reactive } from 'vue';
2
2
  import type { ContentSourceMap, QueryParams } from '@sanity/client';
3
3
  import type { EncodeDataAttributeFunction } from '@sanity/core-loader/encode-data-attribute';
4
- import type SanityClient from '../../client/SanityClient.js';
4
+ import type { SanityClient } from '#imports';
5
5
  export declare const subscribeToChanges: <T, E>(query: string, params: Reactive<QueryParams> | undefined, client: SanityClient, updateData: (data: T, sourceMap?: ContentSourceMap, encodeDataAttribute?: EncodeDataAttributeFunction) => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.8.3",
3
+ "version": "2.9.0",
4
4
  "description": "Advanced Sanity integration for Nuxt.js.",
5
5
  "repository": "devite-io/nuxt-sanity",
6
6
  "license": "MIT",
@@ -22,38 +22,36 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@nuxt/image": "^1.8.1",
25
+ "@nuxt/image": "^1.9.0",
26
26
  "@portabletext/vue": "^1.0.11",
27
- "@sanity/client": "^6.24.1",
28
- "@sanity/core-loader": "^1.7.23",
29
- "@sanity/preview-url-secret": "^2.0.5",
30
- "@sanity/types": "^3.68.3",
31
- "@sanity/visual-editing": "^2.11.5",
27
+ "@sanity/client": "^6.28.3",
28
+ "@sanity/core-loader": "^1.7.38",
29
+ "@sanity/preview-url-secret": "^2.1.5",
30
+ "@sanity/types": "^3.78.1",
31
+ "@sanity/visual-editing": "^2.13.7",
32
32
  "defu": "^6.1.4",
33
33
  "ofetch": "^1.4.1",
34
34
  "ohash": "^1.1.4",
35
- "unstorage": "^1.14.4"
35
+ "unstorage": "^1.15.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@nuxt/eslint-config": "^0.7.4",
39
- "@nuxt/kit": "^3.15.1",
38
+ "@nuxt/eslint-config": "^0.7.6",
39
+ "@nuxt/kit": "^3.15.4",
40
40
  "@nuxt/module-builder": "^0.8.4",
41
- "@nuxt/schema": "^3.15.1",
42
- "@nuxt/test-utils": "^3.15.1",
41
+ "@nuxt/schema": "^3.15.4",
42
+ "@nuxt/test-utils": "^3.15.4",
43
43
  "@types/node": "latest",
44
44
  "changelogen": "^0.5.7",
45
- "eslint": "^9.17.0",
46
- "h3": "^1.13.0",
47
- "nuxt": "^3.15.1",
48
- "typescript": "~5.6.3",
49
- "vitest": "^2.1.8",
45
+ "eslint": "^9.22.0",
46
+ "h3": "^1.15.1",
47
+ "nuxt": "^3.15.4",
48
+ "typescript": "5.6.3",
49
+ "vite": "6.0.1",
50
+ "vitest": "^2.1.9",
50
51
  "vitest-environment-nuxt": "1.0.1",
51
52
  "vue": "3.5.13",
52
53
  "vue-router": "^4.5.0",
53
- "vue-tsc": "^2.1.6"
54
- },
55
- "overrides": {
56
- "react": "18.3.1"
54
+ "vue-tsc": "^2.2.8"
57
55
  },
58
56
  "resolutions": {
59
57
  "@devite/nuxt-sanity": "link:."
@@ -68,7 +66,7 @@
68
66
  "dev:cms": "cd playground/cms && pnpm dev",
69
67
  "dev:build": "nuxi build playground",
70
68
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
71
- "release": "pnpm lint && pnpm test && pnpm prepack && changelogen --release && pnpm publish --access=public && git push --follow-tags",
69
+ "release": "pnpm lint && pnpm test && pnpm prepack && git push && changelogen --release && pnpm publish --access=public && git push --follow-tags",
72
70
  "lint": "eslint --fix .",
73
71
  "test": "vitest run --passWithNoTests",
74
72
  "test:watch": "vitest watch",