@devite/nuxt-sanity 1.3.0 → 1.5.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/README.md +4 -1
- package/dist/module.d.mts +50 -1
- package/dist/module.d.ts +50 -1
- package/dist/module.json +2 -2
- package/dist/runtime/components/SanityLinkExternal.vue +1 -1
- package/dist/runtime/components/SanityLinkInternal.vue +6 -3
- package/dist/runtime/components/SanityPage.vue +1 -4
- package/dist/runtime/components/SanityRichText.vue +2 -2
- package/dist/runtime/utils/projections.d.ts +1 -0
- package/dist/runtime/utils/projections.js +5 -0
- package/dist/runtime/utils/resolveImageAssetById.js +1 -1
- package/dist/runtime/utils/resolveInternalLink.d.ts +4 -0
- package/dist/runtime/utils/resolveInternalLink.js +4 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +12 -12
- package/dist/runtime/types/documents/Page.d.ts +0 -10
- package/dist/runtime/types/documents/Page.js +0 -0
- package/dist/runtime/types/objects/SEO.d.ts +0 -9
- package/dist/runtime/types/objects/SEO.js +0 -0
- package/dist/runtime/types/objects/global/GlobalSEO.d.ts +0 -5
- package/dist/runtime/types/objects/global/GlobalSEO.js +0 -0
- package/dist/runtime/types/objects/link/LinkExternal.d.ts +0 -5
- package/dist/runtime/types/objects/link/LinkExternal.js +0 -0
- package/dist/runtime/types/objects/link/LinkInternal.d.ts +0 -4
- package/dist/runtime/types/objects/link/LinkInternal.js +0 -0
- package/dist/runtime/types/richText/RichText.d.ts +0 -2
- package/dist/runtime/types/richText/RichText.js +0 -0
- package/dist/runtime/types/singletons/Home.d.ts +0 -6
- package/dist/runtime/types/singletons/Home.js +0 -0
- package/dist/runtime/types/singletons/NotFound.d.ts +0 -6
- package/dist/runtime/types/singletons/NotFound.js +0 -0
package/README.md
CHANGED
|
@@ -22,11 +22,14 @@ That's it! You can now use data from Sanity in your Nuxt app ✨
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Install dependencies
|
|
25
|
-
pnpm install && cd playground/cms && pnpm install
|
|
25
|
+
pnpm install && cd playground/cms && pnpm install && cd -
|
|
26
26
|
|
|
27
27
|
# Generate type stubs
|
|
28
28
|
pnpm dev:prepare
|
|
29
29
|
|
|
30
|
+
# Generate module types and build the module
|
|
31
|
+
pnpm prepack
|
|
32
|
+
|
|
30
33
|
# Develop with the playground
|
|
31
34
|
pnpm dev
|
|
32
35
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { Image, Slug, PortableTextBlock } from '@sanity/types';
|
|
3
|
+
|
|
4
|
+
interface SEO {
|
|
5
|
+
_type: 'seo';
|
|
6
|
+
indexable: boolean;
|
|
7
|
+
title: string;
|
|
8
|
+
shortTitle: string;
|
|
9
|
+
description: string;
|
|
10
|
+
image?: Image;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Page {
|
|
14
|
+
_id: string;
|
|
15
|
+
_type: 'page';
|
|
16
|
+
title: string;
|
|
17
|
+
slug: Slug;
|
|
18
|
+
modules: Array<object>;
|
|
19
|
+
seo: SEO;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GlobalSEO {
|
|
23
|
+
siteName: string;
|
|
24
|
+
image: Image;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface LinkExternal {
|
|
28
|
+
_type: 'linkExternal';
|
|
29
|
+
url: string;
|
|
30
|
+
newWindow: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface LinkInternal {
|
|
34
|
+
_type: 'linkInternal';
|
|
35
|
+
slug: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type RichText = PortableTextBlock[];
|
|
39
|
+
|
|
40
|
+
interface Home {
|
|
41
|
+
_type: 'home';
|
|
42
|
+
modules: Array<object>;
|
|
43
|
+
seo: SEO;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface NotFound {
|
|
47
|
+
_type: 'notFound';
|
|
48
|
+
modules: Array<object>;
|
|
49
|
+
seo: SEO;
|
|
50
|
+
}
|
|
2
51
|
|
|
3
52
|
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
|
|
4
53
|
|
|
5
|
-
export { _default as default };
|
|
54
|
+
export { type GlobalSEO, type Home, type LinkExternal, type LinkInternal, type NotFound, type Page, type RichText, type SEO, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { Image, Slug, PortableTextBlock } from '@sanity/types';
|
|
3
|
+
|
|
4
|
+
interface SEO {
|
|
5
|
+
_type: 'seo';
|
|
6
|
+
indexable: boolean;
|
|
7
|
+
title: string;
|
|
8
|
+
shortTitle: string;
|
|
9
|
+
description: string;
|
|
10
|
+
image?: Image;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Page {
|
|
14
|
+
_id: string;
|
|
15
|
+
_type: 'page';
|
|
16
|
+
title: string;
|
|
17
|
+
slug: Slug;
|
|
18
|
+
modules: Array<object>;
|
|
19
|
+
seo: SEO;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GlobalSEO {
|
|
23
|
+
siteName: string;
|
|
24
|
+
image: Image;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface LinkExternal {
|
|
28
|
+
_type: 'linkExternal';
|
|
29
|
+
url: string;
|
|
30
|
+
newWindow: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface LinkInternal {
|
|
34
|
+
_type: 'linkInternal';
|
|
35
|
+
slug: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type RichText = PortableTextBlock[];
|
|
39
|
+
|
|
40
|
+
interface Home {
|
|
41
|
+
_type: 'home';
|
|
42
|
+
modules: Array<object>;
|
|
43
|
+
seo: SEO;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface NotFound {
|
|
47
|
+
_type: 'notFound';
|
|
48
|
+
modules: Array<object>;
|
|
49
|
+
seo: SEO;
|
|
50
|
+
}
|
|
2
51
|
|
|
3
52
|
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
|
|
4
53
|
|
|
5
|
-
export { _default as default };
|
|
54
|
+
export { type GlobalSEO, type Home, type LinkExternal, type LinkInternal, type NotFound, type Page, type RichText, type SEO, _default as default };
|
package/dist/module.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<NuxtLink
|
|
3
|
-
|
|
3
|
+
v-if="resolvedLink"
|
|
4
|
+
:to="resolvedLink.slug"
|
|
4
5
|
>
|
|
5
6
|
<slot />
|
|
6
7
|
</NuxtLink>
|
|
7
8
|
</template>
|
|
8
9
|
|
|
9
10
|
<script setup lang="ts">
|
|
10
|
-
import type { LinkInternal } from '
|
|
11
|
+
import type { LinkInternal } from '@devite/nuxt-sanity'
|
|
12
|
+
import type { Ref } from '#imports'
|
|
11
13
|
|
|
12
|
-
defineProps<{ data: LinkInternal }>()
|
|
14
|
+
const { data } = defineProps<{ data: LinkInternal }>()
|
|
15
|
+
const resolvedLink: Ref<LinkInternal | undefined> | undefined = 'reference' in data ? await resolveInternalLink(data.reference) : data
|
|
13
16
|
</script>
|
|
@@ -13,10 +13,7 @@ import { useSanityQuery } from '@nuxtjs/sanity/runtime/composables/visual-editin
|
|
|
13
13
|
import { groq } from '@nuxtjs/sanity/runtime/groq'
|
|
14
14
|
import type { ComputedRef } from 'vue'
|
|
15
15
|
import type { ImageAsset } from '@sanity/types'
|
|
16
|
-
import type { Home } from '
|
|
17
|
-
import type { Page } from '../types/documents/Page'
|
|
18
|
-
import type { NotFound } from '../types/singletons/NotFound'
|
|
19
|
-
import type { GlobalSEO } from '../types/objects/global/GlobalSEO'
|
|
16
|
+
import type { Home, Page, NotFound, GlobalSEO } from '@devite/nuxt-sanity'
|
|
20
17
|
import { IMAGE_WITHOUT_PREVIEW_PROJECTION } from '../utils/projections'
|
|
21
18
|
import { useHead, useRoute, useRuntimeConfig, useSeoMeta, computed } from '#imports'
|
|
22
19
|
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
<script setup lang="ts">
|
|
9
9
|
import { PortableText, type PortableTextComponents } from '@portabletext/vue'
|
|
10
|
-
import type { RichText } from '
|
|
10
|
+
import type { RichText } from '@devite/nuxt-sanity'
|
|
11
11
|
import { computed, h } from '#imports'
|
|
12
12
|
import { SanityLinkExternal, SanityLinkInternal } from '#components'
|
|
13
13
|
|
|
14
|
-
const { data, placeholders = {} } = defineProps<{ data: RichText, placeholders?: object }>()
|
|
14
|
+
const { data, placeholders = {} as object } = defineProps<{ data: RichText, placeholders?: object }>()
|
|
15
15
|
const currentData = computed(() => {
|
|
16
16
|
return data.map((block) => {
|
|
17
17
|
return {
|
|
@@ -15,3 +15,8 @@ export const IMAGE_WITH_PREVIEW_PROJECTION = groq`{
|
|
|
15
15
|
_type,
|
|
16
16
|
asset-> ${IMAGE_ASSET_PROJECTION}
|
|
17
17
|
}`;
|
|
18
|
+
export const LINK_PROJECTION = groq`{
|
|
19
|
+
'_type': @._type,
|
|
20
|
+
_type == 'linkExternal' => { url, newWindow },
|
|
21
|
+
_type == 'linkInternal' => { 'slug': coalesce(@.reference->slug.current, '/') }
|
|
22
|
+
}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSanityQuery } from "@nuxtjs/sanity/runtime/composables";
|
|
1
|
+
import { useSanityQuery } from "@nuxtjs/sanity/runtime/composables/visual-editing";
|
|
2
2
|
import { IMAGE_ASSET_PROJECTION } from "./projections.js";
|
|
3
3
|
export const resolveImageAssetById = async (id) => {
|
|
4
4
|
return (await useSanityQuery(`*[_type == "sanity.imageAsset" && _id == $assetId][0] ${IMAGE_ASSET_PROJECTION}`, { assetId: id })).data;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { useSanityQuery } from "@nuxtjs/sanity/runtime/composables/visual-editing";
|
|
2
|
+
export const resolveInternalLink = async (reference) => {
|
|
3
|
+
return (await useSanityQuery(`*[_id == $documentId][0] { '_type': 'linkInternal', 'slug': coalesce(slug.current, '/') }`, { documentId: reference._ref })).data;
|
|
4
|
+
};
|
package/dist/types.d.mts
CHANGED
|
@@ -4,4 +4,4 @@ import type { default as Module } from './module.js'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module.js'
|
|
7
|
+
export { type GlobalSEO, type Home, type LinkExternal, type LinkInternal, type NotFound, type Page, type RichText, type SEO, default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import type { default as Module } from './module'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module'
|
|
7
|
+
export { type GlobalSEO, type Home, type LinkExternal, type LinkInternal, type NotFound, type Page, type RichText, type SEO, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devite/nuxt-sanity",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Provides additional helper components and utilities for the Nuxt.js Sanity module",
|
|
5
5
|
"repository": "devite-io/nuxt-sanity",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,26 +22,26 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nuxt/image": "^1.8.
|
|
25
|
+
"@nuxt/image": "^1.8.1",
|
|
26
26
|
"@nuxt/kit": "^3.13.2",
|
|
27
|
-
"@nuxtjs/sanity": "^1.12.
|
|
27
|
+
"@nuxtjs/sanity": "^1.12.2",
|
|
28
28
|
"@portabletext/vue": "^1.0.11",
|
|
29
|
-
"@sanity/client": "^6.
|
|
30
|
-
"@sanity/types": "^3.
|
|
29
|
+
"@sanity/client": "^6.24.1",
|
|
30
|
+
"@sanity/types": "^3.66.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@nuxt
|
|
33
|
+
"@devite/nuxt-sanity": "link:",
|
|
34
34
|
"@nuxt/eslint-config": "^0.5.7",
|
|
35
35
|
"@nuxt/module-builder": "^0.8.4",
|
|
36
36
|
"@nuxt/schema": "^3.13.2",
|
|
37
|
-
"@nuxt/test-utils": "^3.
|
|
38
|
-
"@types/node": "
|
|
37
|
+
"@nuxt/test-utils": "^3.15.1",
|
|
38
|
+
"@types/node": "^22.10.1",
|
|
39
39
|
"changelogen": "^0.5.7",
|
|
40
|
-
"eslint": "^9.
|
|
40
|
+
"eslint": "^9.12.0",
|
|
41
41
|
"nuxt": "^3.13.2",
|
|
42
|
-
"typescript": "
|
|
43
|
-
"vitest": "^2.1.
|
|
44
|
-
"vue-tsc": "^2.1.
|
|
42
|
+
"typescript": "^5.7.2",
|
|
43
|
+
"vitest": "^2.1.8",
|
|
44
|
+
"vue-tsc": "^2.1.10"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "nuxi dev playground",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|