@devite/nuxt-sanity 1.0.1 → 1.0.2
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/SanityComponent.vue +25 -7
- package/dist/runtime/components/{link/External.vue → SanityLinkExternal.vue} +1 -1
- package/dist/runtime/components/{link/Internal.vue → SanityLinkInternal.vue} +1 -1
- package/dist/runtime/components/SanityPage.vue +13 -9
- package/dist/runtime/components/{RichText.vue → SanityRichText.vue} +5 -4
- package/dist/runtime/types/documents/Page.d.ts +10 -0
- package/dist/runtime/types/documents/Page.js +0 -0
- package/dist/runtime/types/objects/SEO.d.ts +9 -0
- package/dist/runtime/types/objects/SEO.js +0 -0
- package/dist/runtime/types/objects/global/GlobalSEO.d.ts +5 -0
- package/dist/runtime/types/objects/global/GlobalSEO.js +0 -0
- package/dist/runtime/types/objects/link/LinkExternal.d.ts +5 -0
- package/dist/runtime/types/objects/link/LinkExternal.js +0 -0
- package/dist/runtime/types/objects/link/LinkInternal.d.ts +4 -0
- package/dist/runtime/types/objects/link/LinkInternal.js +0 -0
- package/dist/runtime/types/richText/RichText.d.ts +2 -0
- package/dist/runtime/types/richText/RichText.js +0 -0
- package/dist/runtime/types/singletons/Home.d.ts +6 -0
- package/dist/runtime/types/singletons/Home.js +0 -0
- package/dist/runtime/types/singletons/NotFound.d.ts +6 -0
- package/dist/runtime/types/singletons/NotFound.js +0 -0
- package/package.json +1 -1
- /package/dist/runtime/components/{ImageAsset.vue → SanityImageAsset.vue} +0 -0
package/dist/module.json
CHANGED
|
@@ -9,12 +9,30 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
|
-
|
|
12
|
+
import type { Component } from '@nuxt/schema'
|
|
13
|
+
import { resolveComponent } from '#imports'
|
|
14
|
+
import { SanityLinkExternal, SanityLinkInternal, SanityRichText } from '#components'
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const props = defineProps<{ data?: object }>()
|
|
17
|
+
|
|
18
|
+
const type = props.data?._type
|
|
19
|
+
let component: Component
|
|
20
|
+
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'linkInternal':
|
|
23
|
+
component = SanityLinkInternal
|
|
24
|
+
break
|
|
25
|
+
case 'linkExternal':
|
|
26
|
+
component = SanityLinkExternal
|
|
27
|
+
break
|
|
28
|
+
default:
|
|
29
|
+
if (props.data?.constructor.name === 'Array' && props.data.every(item => item._type === 'block'))
|
|
30
|
+
component = SanityRichText
|
|
31
|
+
else if (type) {
|
|
32
|
+
const upperCamelCase = type.charAt(0).toUpperCase() + type.slice(1)
|
|
33
|
+
component = resolveComponent('Sanity' + upperCamelCase)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
break
|
|
37
|
+
}
|
|
20
38
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<main v-if="sanityData
|
|
2
|
+
<main v-if="sanityData?.modules?.length > 0">
|
|
3
3
|
<SanityComponent
|
|
4
4
|
v-for="module in sanityData.modules"
|
|
5
5
|
:key="module._key"
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
12
|
+
import { useSanityQuery } from '@nuxtjs/sanity/runtime/composables'
|
|
13
|
+
import { groq } from '@nuxtjs/sanity/runtime/groq'
|
|
14
|
+
import type { Home } from '../types/singletons/Home'
|
|
15
|
+
import type { Page } from '../types/documents/Page'
|
|
16
|
+
import type { NotFound } from '../types/singletons/NotFound'
|
|
17
|
+
import type { GlobalSEO } from '../types/objects/global/GlobalSEO'
|
|
18
|
+
import { useHead, useRoute, useRuntimeConfig, useSeoMeta } from '#app'
|
|
19
|
+
import { computed } from '#imports'
|
|
16
20
|
|
|
17
21
|
const { baseURL } = useRuntimeConfig().public
|
|
18
22
|
|
|
@@ -23,12 +27,12 @@ const { data: sanityData } = await useSanityQuery<Home | Page | NotFound>(groq`*
|
|
|
23
27
|
const seo = computed(() => sanityData.value?.seo)
|
|
24
28
|
const url = computed(() => baseURL + (sanityData.value?.slug || '/'))
|
|
25
29
|
|
|
26
|
-
const { data: globalSEO } = await useSanityQuery<GlobalSEO>(groq`*[_type == 'settings'][0].seo {
|
|
30
|
+
const { data: globalSEO } = await useSanityQuery<GlobalSEO>(groq`*[_type == 'settings'][0].seo { siteName, image }`)
|
|
27
31
|
const image = computed(() => sanityData.value?.image || globalSEO.value?.image)
|
|
28
32
|
|
|
29
33
|
useHead({
|
|
30
34
|
meta: [
|
|
31
|
-
{ name: 'site_name', content: () => globalSEO.value?.
|
|
35
|
+
{ name: 'site_name', content: () => globalSEO.value?.siteName },
|
|
32
36
|
{ name: 'og:image', content: () => image.value?.url },
|
|
33
37
|
{ name: 'og:image:width', content: () => image.value?.metadata.dimensions.width },
|
|
34
38
|
{ name: 'og:image:height', content: () => image.value?.metadata.dimensions.height },
|
|
@@ -47,9 +51,9 @@ useSeoMeta({
|
|
|
47
51
|
robots: () => ((seo.value?.indexable ? '' : 'no') + 'index,follow'),
|
|
48
52
|
title: () => seo.value?.title,
|
|
49
53
|
description: () => seo.value?.description,
|
|
50
|
-
ogTitle: () => seo.value?.
|
|
54
|
+
ogTitle: () => seo.value?.shortTitle,
|
|
51
55
|
ogDescription: () => seo.value?.description,
|
|
52
|
-
twitterTitle: () => seo.value?.
|
|
56
|
+
twitterTitle: () => seo.value?.shortTitle,
|
|
53
57
|
twitterDescription: () => seo.value?.description,
|
|
54
58
|
})
|
|
55
59
|
</script>
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
<script setup lang="ts">
|
|
9
9
|
import { PortableText, type PortableTextComponents } from '@portabletext/vue'
|
|
10
|
-
import type { RichText } from '
|
|
11
|
-
import {
|
|
10
|
+
import type { RichText } from '../types/richText/RichText'
|
|
11
|
+
import { computed, h } from '#imports'
|
|
12
|
+
import { SanityLinkExternal, SanityLinkInternal } from '#components'
|
|
12
13
|
|
|
13
14
|
const { data, placeholders = {} } = defineProps<{ data: RichText, placeholders?: object }>()
|
|
14
15
|
const currentData = computed(() => {
|
|
@@ -47,9 +48,9 @@ function replacePlaceholders(text: string) {
|
|
|
47
48
|
const richTextSerializer: PortableTextComponents = {
|
|
48
49
|
marks: {
|
|
49
50
|
linkExternal: ({ value }, { slots }) =>
|
|
50
|
-
h(
|
|
51
|
+
h(SanityLinkExternal, { data: value }, slots.default),
|
|
51
52
|
linkInternal: ({ value }, { slots }) =>
|
|
52
|
-
h(
|
|
53
|
+
h(SanityLinkInternal, { data: value }, slots.default),
|
|
53
54
|
},
|
|
54
55
|
}
|
|
55
56
|
</script>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|