Skip to content

Commit

Permalink
add global modules to 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchuman committed Feb 25, 2025
1 parent 497feda commit 99827b1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/(frontend)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modules from '@/ui/modules'
import { fetchSanityLive } from '@/sanity/lib/fetch'
import { groq } from 'next-sanity'
import { MODULES_QUERY } from '@/sanity/lib/queries'
import Modules from '@/ui/modules'

export default async function NotFound() {
const page = await get404()
Expand All @@ -17,7 +17,14 @@ async function get404() {
return await fetchSanityLive<Sanity.Page>({
query: groq`*[_type == 'page' && metadata.slug.current == '404'][0]{
...,
modules[]{ ${MODULES_QUERY} }
'modules': (
// global modules (before)
*[_type == 'global-module' && path == '*'].before[]{ ${MODULES_QUERY} }
// page modules
+ modules[]{ ${MODULES_QUERY} }
// global modules (after)
+ *[_type == 'global-module' && path == '*'].after[]{ ${MODULES_QUERY} }
)
}`,
})
}

0 comments on commit 99827b1

Please sign in to comment.