kyle2
(Kyle Johnson)
April 25, 2022, 2:21pm
1
Hi, without being able to add a slicezone that contains multiple fields I'm confused as to how to model the following:
Navigation
Legal (title:"Legal", links: [...])
Terms and Conditions
- title
- href
Privacy Policy
- title
- href
Basically, a header that has multiple groups of links that contain links with a href and title.
So something that could generate:
Legal
Terms
Privacy
Other
Other 1
Other 2
Any help would be appreciated!
kyle2
(Kyle Johnson)
April 25, 2022, 3:55pm
2
The simplest way I've found to achieve this so far is to just have 1 type link category which has a title and a repeatable slice NavLink and rely on tags to denote that these groups of links belong to the header vs footer
strong text
Then link categories are tagged with header / footer
Then finally get the items
export type TNav = { footer: TLinkGroup[]; header: TLinkGroup[] }
export const getNavProps = async function (client: Client, lang: string) {
const links = await client.getByType<TLinkGroup>('link-category', {
lang: lang,
pageSize: 1000,
})
return {
header: links.results.filter((linkGroup) =>
linkGroup.tags.includes('header'),
),
footer: links.results.filter((linkGroup) =>
linkGroup.tags.includes('footer'),
),
}
}
I'd still like to know if there's a much better design than this. Without the ability to have a repeatable set of a group of fields this seems quite limiting.
Pau
April 26, 2022, 8:09pm
4
Hello @kyle2 , take a look at this article we wrote to cover this use case:
Sometimes we need to go a little deeper, and when that happens, a 2 level navigation won't do. This article will show you how to create the content model in your custom types for having a 3 level or greater navigation menu for large websites.
The Custom Type
Create a 'Navigation' Custom Type and add two Slices:
1st Level slice
2nd Level slice
You can copy this JSON into the JSON editor to create the custom type:
{
"Navigation" : {
"body" : {
"type" : "Slices",
"fieldset" :…
Let us know if it's useful for you