@devite/nuxt-sanity 1.4.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/dist/module.json +1 -1
- package/dist/runtime/components/SanityLinkInternal.vue +5 -2
- package/dist/runtime/utils/projections.d.ts +1 -0
- package/dist/runtime/utils/projections.js +5 -0
- package/dist/runtime/utils/resolveImageAssetById.d.ts +1 -1
- package/dist/runtime/utils/resolveInternalLink.d.ts +4 -0
- package/dist/runtime/utils/resolveInternalLink.js +4 -0
- package/package.json +8 -9
package/dist/module.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<NuxtLink
|
|
3
|
-
|
|
3
|
+
v-if="resolvedLink"
|
|
4
|
+
:to="resolvedLink.slug"
|
|
4
5
|
>
|
|
5
6
|
<slot />
|
|
6
7
|
</NuxtLink>
|
|
@@ -8,6 +9,8 @@
|
|
|
8
9
|
|
|
9
10
|
<script setup lang="ts">
|
|
10
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>
|
|
@@ -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,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 | undefined>>;
|
|
@@ -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/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",
|
|
@@ -26,23 +26,22 @@
|
|
|
26
26
|
"@nuxt/kit": "^3.13.2",
|
|
27
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
33
|
"@devite/nuxt-sanity": "link:",
|
|
34
|
-
"@nuxt/devtools": "^1.6.0",
|
|
35
34
|
"@nuxt/eslint-config": "^0.5.7",
|
|
36
35
|
"@nuxt/module-builder": "^0.8.4",
|
|
37
36
|
"@nuxt/schema": "^3.13.2",
|
|
38
|
-
"@nuxt/test-utils": "^3.
|
|
39
|
-
"@types/node": "
|
|
37
|
+
"@nuxt/test-utils": "^3.15.1",
|
|
38
|
+
"@types/node": "^22.10.1",
|
|
40
39
|
"changelogen": "^0.5.7",
|
|
41
40
|
"eslint": "^9.12.0",
|
|
42
41
|
"nuxt": "^3.13.2",
|
|
43
|
-
"typescript": "
|
|
44
|
-
"vitest": "^2.1.
|
|
45
|
-
"vue-tsc": "^2.1.
|
|
42
|
+
"typescript": "^5.7.2",
|
|
43
|
+
"vitest": "^2.1.8",
|
|
44
|
+
"vue-tsc": "^2.1.10"
|
|
46
45
|
},
|
|
47
46
|
"scripts": {
|
|
48
47
|
"dev": "nuxi dev playground",
|