I have a custom single-page type "homepage", with a separate tab "SEO". There are 2 fields right now: meta_title and meta_description. I'm also using slice machine and that's why I can't understand how to query both metadata and slices in the same time.
According to your documentation,
Querying with the Slice Zone will only return the content of the Slice Zone in your document. Querying the whole document will return the metadata
So let's consider this code snippet in my pages/index.js:
You can see that it contains everything about the slices, so the webpage is rendered accordingly. However, there's no meta data. Documentation says I should use bare client to fetch it, so let's try it:
To sum up: it seems I can either fetch minimal document content with SEO tags but without slices, or a full fledged slice-based document without meta tags. How to query both?
Thanks for your contribution and the proposed solution.
I've done some research regarding this issue, and it seems this issue is related to that you are using the Spread Operators to do Shallow-cloning, and they will not list all properties in your doc object.
Please refer to this document to learn more about Spread Operators
Please let me know if you have any other inquiries,
Fares
Using getStaticProps and the @prismicio/client is the new recommended way of querying docs in Next.js.
We're currently updating all of our documentation to include the latest changes to the kits. This includes the new version of @prismicio/react which has its own <SliceZone> component. This is the one you should use from now on.