@devite/nuxt-sanity 2.5.2 → 2.5.3
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
CHANGED
|
@@ -14,6 +14,29 @@ npx nuxi module add @devite/nuxt-sanity
|
|
|
14
14
|
|
|
15
15
|
That's it! You can now use Sanity with your Nuxt app ✨
|
|
16
16
|
|
|
17
|
+
## Configuration
|
|
18
|
+
|
|
19
|
+
Further configuration can be done in the `nuxt.config.ts` file:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
export default {
|
|
23
|
+
modules: [
|
|
24
|
+
'@devite/nuxt-sanity',
|
|
25
|
+
"@nuxt/image"
|
|
26
|
+
],
|
|
27
|
+
sanity: {
|
|
28
|
+
projectId: 'YOUR_PROJECT_ID',
|
|
29
|
+
dataset: 'YOUR_DATASET',
|
|
30
|
+
...
|
|
31
|
+
},
|
|
32
|
+
runtimeConfig: {
|
|
33
|
+
public: {
|
|
34
|
+
// Required for SanityPage component to set a correct "canonical" url
|
|
35
|
+
baseUrl: "https://www.example.com"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
```
|
|
17
40
|
|
|
18
41
|
## Contribution
|
|
19
42
|
|
|
@@ -49,8 +72,10 @@ That's it! You can now use Sanity with your Nuxt app ✨
|
|
|
49
72
|
</details>
|
|
50
73
|
|
|
51
74
|
<!-- Links -->
|
|
75
|
+
|
|
52
76
|
[nuxt-sanity]: https://github.com/nuxt-modules/sanity
|
|
53
77
|
|
|
54
78
|
<!-- Badges -->
|
|
79
|
+
|
|
55
80
|
[npm-version-src]: https://img.shields.io/npm/v/@devite/nuxt-sanity/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
56
81
|
[npm-version-href]: https://npmjs.com/package/@devite/nuxt-sanity
|
package/dist/module.json
CHANGED
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.5.
|
|
6
|
+
const version = "2.5.3";
|
|
7
7
|
|
|
8
8
|
const CONFIG_KEY = "sanity";
|
|
9
9
|
const module = defineNuxtModule({
|
|
@@ -31,11 +31,11 @@ if (sanityData.value?._type === 'notFound' && import.meta.server) {
|
|
|
31
31
|
setResponseStatus(event, 404)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const { baseURL } = useRuntimeConfig().public
|
|
34
|
+
const { baseURL: baseUrl } = useRuntimeConfig().public
|
|
35
35
|
const seo = computed(() => sanityData.value?.seo)
|
|
36
36
|
const url = computed(
|
|
37
37
|
() =>
|
|
38
|
-
((
|
|
38
|
+
((baseUrl as string) || '')
|
|
39
39
|
+ ((sanityData.value && ('slug' in sanityData.value ? sanityData.value.slug.current : null)) || '/'),
|
|
40
40
|
)
|
|
41
41
|
|
|
@@ -19,5 +19,5 @@ export const IMAGE_WITH_PREVIEW_PROJECTION = groq`{
|
|
|
19
19
|
export const LINK_PROJECTION = groq`{
|
|
20
20
|
'_type': @._type,
|
|
21
21
|
_type == 'linkExternal' => { url, newWindow },
|
|
22
|
-
_type == 'linkInternal' => { 'slug': coalesce(@.reference->slug.current, '
|
|
22
|
+
_type == 'linkInternal' => { 'slug': '/' + coalesce(@.reference->slug.current, '') }
|
|
23
23
|
}`;
|
|
@@ -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, '') }`,
|
|
5
5
|
{ documentId: reference._ref }
|
|
6
6
|
)).data;
|
|
7
7
|
};
|