Help needed with Next.js and Sanity integration, getting 404 error and build error
10 replies
Last updated: Feb 2, 2023
A
We're looking into the possibility of trying Sanity at my company. We have content in a few countries, not just localized but different content. There would be 5 + dev content set(s). We really like the usage based pricing model of Sanity, but the dataset limits are a bit concerning. Is it possible to have more?
Feb 2, 2023, 3:36 PM
S
Would consider keeping it all in a common dataset as there usually are some data that can be shared.
Feb 2, 2023, 4:34 PM
S
We’ve created multiple sites like this either using the i18n plugin or just by having every document reference a “site”/“language” document.
Feb 2, 2023, 4:34 PM
A
What would be the authoring flow then? I cannot expect the people editing this to put the country in every document they make. Especially not with references. Would it be possible to hide, and then filter all documents everywhere based on some selector in the navbar for example?
Feb 2, 2023, 4:52 PM
A
We have entirely different teams editing these.
Feb 2, 2023, 4:53 PM
S
Yep! You can create custom desk structure to only show each country and only show specific countries to each user.
The “Site” field is hidden for users and auto populated via initial value templates
🙂
You can then make sure every reference field uses a “filter references” function like this one:
The “Site” field is hidden for users and auto populated via initial value templates
🙂
You can then make sure every reference field uses a “filter references” function like this one:
export const filterInternalLinkBySite = ({ document }) => { if (!document?.sites) { return { filter: "", params: "", } } const siteIds = document?.sites.map((site) => site._ref) return { filter: "(count((sites[]._ref)[@ in $siteIds]) > 0) && _id != $id", params: { siteIds: siteIds, id: document?._id, }, } }
Feb 2, 2023, 6:13 PM
A
Hmm. Then when we I query I'd need to include a filter on everything as well right?
Feb 2, 2023, 6:14 PM
S
Yup, using Next.js as a frontend we have this setup using i18n locales:
Note both these examples have the site field as “sites” since some content might be usable on different sites, such as swedish content in swedish part of finnish page
😉
*[_type == "page" && $locale in sites[]->locale]
Note both these examples have the site field as “sites” since some content might be usable on different sites, such as swedish content in swedish part of finnish page
😉
Feb 2, 2023, 6:19 PM
A
We don't hace anything shared, intentionally.
Feb 2, 2023, 6:23 PM
A
But yeah that might work actually.
Feb 2, 2023, 6:23 PM
S
The great thing is that with this setup you can mix in content that is better to have field level translations or no translations such as Person or Product.
In addition you share the same media library which is usually nice
In addition you share the same media library which is usually nice
Feb 2, 2023, 6:23 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.