@devite/nuxt-sanity 1.2.0 → 1.3.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/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
3
  "configKey": "@devite/nuxt-sanity",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
- "unbuild": "unknown"
7
+ "unbuild": "2.0.0"
8
8
  }
9
9
  }
@@ -2,7 +2,8 @@
2
2
  <component
3
3
  :is="component"
4
4
  v-if="data"
5
- :data="data"
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,7 +9,7 @@
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'
@@ -18,15 +18,13 @@ import type { Page } from '../types/documents/Page'
18
18
  import type { NotFound } from '../types/singletons/NotFound'
19
19
  import type { GlobalSEO } from '../types/objects/global/GlobalSEO'
20
20
  import { IMAGE_WITHOUT_PREVIEW_PROJECTION } from '../utils/projections'
21
- import { useHead, useRoute, useRuntimeConfig, useSeoMeta } from '#app'
22
- import { computed } from '#imports'
23
-
24
- const { baseURL } = useRuntimeConfig().public
21
+ import { useHead, useRoute, useRuntimeConfig, useSeoMeta, computed } from '#imports'
25
22
 
26
23
  const path = useRoute().fullPath
27
24
  const groqFilter = path === '/' ? '_type == "home"' : `_type == "page" && slug.current == $slug`
28
25
  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
26
 
27
+ const { baseURL } = useRuntimeConfig().public
30
28
  const seo = computed(() => sanityData.value?.seo)
31
29
  const url = computed(() => baseURL + (sanityData.value?.slug || '/'))
32
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",