From 8e00179c9cc370178d5ee80545f159f64fd004ad Mon Sep 17 00:00:00 2001 From: "Kuboczoch (Jakub Pokorski)" Date: Fri, 8 Oct 2021 01:30:05 +0200 Subject: [PATCH] Navigation Link in page navigation #5 --- @types/generated/contentful.d.ts | 28 +++++++++++++++++++++- src/components/elements/PageNavigation.tsx | 25 ++++++++++++------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/@types/generated/contentful.d.ts b/@types/generated/contentful.d.ts index f66efa6..98cec21 100644 --- a/@types/generated/contentful.d.ts +++ b/@types/generated/contentful.d.ts @@ -79,7 +79,7 @@ export interface ILayoutFields { metaTags: IMetaTag[] /** ContentPages */ - contentPages: IContentPage[] + contentPages: (IContentPage | INavigationLink)[] } export interface ILayout extends Entry { @@ -124,6 +124,31 @@ export interface IMetaTag extends Entry { } } +export interface INavigationLinkFields { + /** Title */ + title: string + + /** Slug */ + slug: string +} + +export interface INavigationLink extends Entry { + sys: { + id: string + type: string + createdAt: string + updatedAt: string + locale: string + contentType: { + sys: { + id: 'navigationLink' + linkType: 'ContentType' + type: 'Link' + } + } + } +} + export interface IWarTeamFields { /** Title */ title: string @@ -197,6 +222,7 @@ export type CONTENT_TYPE = | 'coordinatesConfiguration' | 'layout' | 'metaTag' + | 'navigationLink' | 'warTeam' | 'warTeamsPage' diff --git a/src/components/elements/PageNavigation.tsx b/src/components/elements/PageNavigation.tsx index 63932ea..f3e39a4 100644 --- a/src/components/elements/PageNavigation.tsx +++ b/src/components/elements/PageNavigation.tsx @@ -1,11 +1,11 @@ import { css } from '@emotion/css' import React from 'react' import Link from 'next/link' -import { IContentPage } from '../../../@types/generated/contentful' +import { IContentPage, INavigationLink } from '../../../@types/generated/contentful' import NavigationMenu from '../blocks/NavigationMenu' interface IPageNavigation { - contentPages: IContentPage[] + contentPages: (IContentPage | INavigationLink)[] activePage: IContentPage } @@ -19,14 +19,23 @@ const PageNavigation = (props: IPageNavigation) => ( Navigation - {props.contentPages?.map((contentPage, index) => ( + {props.contentPages?.map((link, index) => ( - - {contentPage.fields.title} - + {link.sys.contentType.sys.id === 'contentPage' && ( + + {link.fields.title} + + )} + {link.sys.contentType.sys.id === 'navigationLink' && ( + + + {link.fields.title} + + + )} ))}