@devite/nuxt-sanity 1.2.0 → 1.4.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/README.md +4 -1
- package/dist/module.d.mts +50 -1
- package/dist/module.d.ts +50 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/SanityComponent.vue +7 -3
- package/dist/runtime/components/SanityLinkExternal.vue +1 -1
- package/dist/runtime/components/SanityLinkInternal.vue +1 -1
- package/dist/runtime/components/SanityPage.vue +4 -9
- package/dist/runtime/components/SanityRichText.vue +2 -2
- package/dist/runtime/utils/resolveImageAssetById.d.ts +1 -1
- package/dist/runtime/utils/resolveImageAssetById.js +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +10 -9
- 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
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
<component
|
|
3
3
|
:is="component"
|
|
4
4
|
v-if="data"
|
|
5
|
-
|
|
5
|
+
ref="componentRef"
|
|
6
|
+
v-bind="{ ...$props, ...$attrs }"
|
|
6
7
|
>
|
|
7
8
|
<slot />
|
|
8
9
|
</component>
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
|
|
11
12
|
<script setup lang="ts">
|
|
12
13
|
import type { Component } from '@nuxt/schema'
|
|
13
|
-
import { computed, resolveComponent } from '#imports'
|
|
14
|
+
import { computed, ref, resolveComponent } from '#imports'
|
|
14
15
|
import { SanityLinkExternal, SanityLinkInternal, SanityRichText } from '#components'
|
|
15
16
|
|
|
16
17
|
const { data } = defineProps<{ data?: object }>()
|
|
@@ -24,7 +25,7 @@ const component = computed<Component>(() => {
|
|
|
24
25
|
case 'linkExternal':
|
|
25
26
|
return SanityLinkExternal
|
|
26
27
|
default:
|
|
27
|
-
if (data?.constructor.name === 'Array' && data.every(item => item._type === 'block'))
|
|
28
|
+
if (data?.constructor.name === 'Array' && data.every((item) => item._type === 'block'))
|
|
28
29
|
return SanityRichText
|
|
29
30
|
else if (type) {
|
|
30
31
|
const upperCamelCase = type.charAt(0).toUpperCase() + type.slice(1)
|
|
@@ -35,4 +36,7 @@ const component = computed<Component>(() => {
|
|
|
35
36
|
|
|
36
37
|
return null
|
|
37
38
|
})
|
|
39
|
+
|
|
40
|
+
const componentRef = ref<Component>()
|
|
41
|
+
defineExpose({ componentRef })
|
|
38
42
|
</script>
|
|
@@ -9,24 +9,19 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
|
-
import { useSanityQuery } from '@nuxtjs/sanity/runtime/composables'
|
|
12
|
+
import { useSanityQuery } from '@nuxtjs/sanity/runtime/composables/visual-editing'
|
|
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
|
-
import { useHead, useRoute, useRuntimeConfig, useSeoMeta } from '#
|
|
22
|
-
import { computed } from '#imports'
|
|
23
|
-
|
|
24
|
-
const { baseURL } = useRuntimeConfig().public
|
|
18
|
+
import { useHead, useRoute, useRuntimeConfig, useSeoMeta, computed } from '#imports'
|
|
25
19
|
|
|
26
20
|
const path = useRoute().fullPath
|
|
27
21
|
const groqFilter = path === '/' ? '_type == "home"' : `_type == "page" && slug.current == $slug`
|
|
28
22
|
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} } }`, { slug: path.substring(1) })
|
|
29
23
|
|
|
24
|
+
const { baseURL } = useRuntimeConfig().public
|
|
30
25
|
const seo = computed(() => sanityData.value?.seo)
|
|
31
26
|
const url = computed(() => baseURL + (sanityData.value?.slug || '/'))
|
|
32
27
|
|
|
@@ -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 {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ImageAsset } from '@sanity/types';
|
|
2
2
|
import type { Ref } from '#imports';
|
|
3
|
-
export declare const resolveImageAssetById: (id: string) => Promise<Ref<ImageAsset |
|
|
3
|
+
export declare const resolveImageAssetById: (id: string) => Promise<Ref<ImageAsset | null>>;
|
|
@@ -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;
|
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.4.0",
|
|
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,25 +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.22.
|
|
30
|
-
"@sanity/types": "^3.
|
|
29
|
+
"@sanity/client": "^6.22.1",
|
|
30
|
+
"@sanity/types": "^3.60.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@nuxt
|
|
33
|
+
"@devite/nuxt-sanity": "link:",
|
|
34
|
+
"@nuxt/devtools": "^1.6.0",
|
|
34
35
|
"@nuxt/eslint-config": "^0.5.7",
|
|
35
36
|
"@nuxt/module-builder": "^0.8.4",
|
|
36
37
|
"@nuxt/schema": "^3.13.2",
|
|
37
|
-
"@nuxt/test-utils": "^3.14.
|
|
38
|
+
"@nuxt/test-utils": "^3.14.3",
|
|
38
39
|
"@types/node": "latest",
|
|
39
40
|
"changelogen": "^0.5.7",
|
|
40
|
-
"eslint": "^9.
|
|
41
|
+
"eslint": "^9.12.0",
|
|
41
42
|
"nuxt": "^3.13.2",
|
|
42
43
|
"typescript": "latest",
|
|
43
|
-
"vitest": "^2.1.
|
|
44
|
+
"vitest": "^2.1.2",
|
|
44
45
|
"vue-tsc": "^2.1.6"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|