Content outside of the SliceZone


These docs rely on Slice Machine, which is in active development and subject to change. Content Relationships are not currently supported with Slices.

Fortunately it's really easy to query content that is outside the SliceZone of your document (i.e. the body), the function useGetStaticProps has already queried this data for you. You simply need to access the data of the props variable, you can see how we’ve done this in the example below where we pass the data of a key text field called title to a H1 tag:

import { Client } from '../prismic'
import SliceZone from 'next-slicezone'
import { useGetStaticProps, useGetStaticPaths } from 'next-slicezone/hooks'

import resolver from '../sm-resolver.js'

const Page = (props) => console.log(props) || 
      <SliceZone {...props} resolver={resolver} />

// Fetch content from prismic
export const getStaticProps = useGetStaticProps({
  client: Client(),
  uid: ({ params }) => params.uid

export const getStaticPaths = useGetStaticPaths({
  client: Client(),
  type: 'page',
  fallback: true,// process.env.NODE_ENV === 'development',
  formatPath: ({ uid }) => ({ params: { uid }})

export default Page