@devite/nuxt-sanity 2.4.1 → 2.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "configKey": "sanity",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
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.4.1";
6
+ const version = "2.4.2";
7
7
 
8
8
  const CONFIG_KEY = "sanity";
9
9
  const module = defineNuxtModule({
@@ -12,10 +12,11 @@
12
12
  import { computed, type ComputedRef } from 'vue'
13
13
  import type { ImageAsset } from '@sanity/types'
14
14
  import type { GlobalSEO, Home, NotFound, Page } from '@devite/nuxt-sanity'
15
+ import { setResponseStatus } from 'h3'
15
16
  import { IMAGE_WITHOUT_PREVIEW_PROJECTION } from '../utils/projections'
16
17
  import { useSanityQuery } from '../composables/useSanityQuery'
17
18
  import { groq } from '../utils/groq'
18
- import { useHead, useRoute, useRuntimeConfig, useSeoMeta } from '#imports'
19
+ import { useHead, useRoute, useRuntimeConfig, useSeoMeta, useRequestEvent } from '#imports'
19
20
 
20
21
  const path = useRoute().path
21
22
  const groqFilter = path === '/' ? '_type == "home"' : `_type == "page" && slug.current == $slug`
@@ -24,6 +25,13 @@ const { data: sanityData } = await useSanityQuery<Home | Page | NotFound>(
24
25
  { slug: path.substring(1) },
25
26
  )
26
27
 
28
+ if (sanityData.value?._type === 'notFound' && import.meta.server) {
29
+ const event = useRequestEvent()
30
+
31
+ if (event)
32
+ setResponseStatus(event, 404)
33
+ }
34
+
27
35
  const { baseURL } = useRuntimeConfig().public
28
36
  const seo = computed(() => sanityData.value?.seo)
29
37
  const url = computed(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "Advanced Sanity integration for Nuxt.js.",
5
5
  "repository": "devite-io/nuxt-sanity",
6
6
  "license": "MIT",