diff --git a/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/content/[contentSlug]/page.tsx b/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/content/[contentSlug]/page.tsx index 4bfc96a3..488b3bac 100644 --- a/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/content/[contentSlug]/page.tsx +++ b/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/content/[contentSlug]/page.tsx @@ -1,19 +1,14 @@ import { createStrapiURL } from '@frameless/vth-frontend/src/util/createStrapiURL'; import { fetchData } from '@frameless/vth-frontend/src/util/fetchData'; -import { - Heading1, - Heading2, - Link, - Paragraph, - UnorderedList, - UnorderedListItem, -} from '@utrecht/component-library-react'; +import { Heading1 } from '@utrecht/component-library-react'; import { Metadata } from 'next'; import React from 'react'; import { useTranslation } from '@/app/i18n'; import { Grid } from '@/components/Grid'; import { Markdown } from '@/components/Markdown'; +import { LinkData, SideNavigation } from '@/components/SideNavigation'; import { GET_CONTENT_BY_SLUG } from '@/query'; +import { SiblingData } from '@/types'; type Params = { params: { @@ -39,31 +34,39 @@ const Thema = async ({ params: { locale, contentSlug } }: Params) => { }); const { title, content, parents } = data.findSlug.data.attributes; + const parentSlug = parents?.data[0]?.attributes?.slug; + const siblingThemas: SiblingData[] = parents?.data[0]?.attributes?.child_themas?.data || []; + const siblingContent: SiblingData[] = parents?.data[0]?.attributes?.child_contents?.data || []; + + const themasLinks = + siblingThemas?.map(({ attributes: { slug, title } }: SiblingData) => ({ + title, + slug, + href: `/themas/${slug}`, + isCurrent: slug === contentSlug, + })) || []; + + const contentLinks = + siblingContent?.map(({ attributes: { slug, title } }: SiblingData) => ({ + title, + slug, + href: `/themas/${parentSlug}/content/${slug}`, + isCurrent: slug === contentSlug, + })) || []; + + const sideNavigationLinks: LinkData[] = [...themasLinks, ...contentLinks]; return (
{title} {content} - Themas - {parents.data[0] ? ( - - {parents.data && - parents.data.map((content: any) => { - const { title, slug: parentSlug } = content.attributes; - return ( - - {title} - - ); - })} - - ) : ( - <> - Geen thema paginas verbonden. - - )}
+ {sideNavigationLinks.length > 0 && ( +
+ +
+ )}
); }; diff --git a/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/page.tsx b/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/page.tsx index 40c63cc4..0d87f69c 100644 --- a/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/page.tsx +++ b/apps/vth-frontend/src/app/[locale]/themas/[themaSlug]/page.tsx @@ -7,8 +7,10 @@ import { useTranslation } from '@/app/i18n'; import { Card } from '@/components/Card'; import { Grid } from '@/components/Grid'; import { Markdown } from '@/components/Markdown'; +import { LinkData, SideNavigation } from '@/components/SideNavigation'; import { GET_THEMA_BY_SLUG } from '@/query'; import { buildImgURL } from '@/util/buildImgURL'; +import { SiblingData } from '@/types'; type Params = { params: { @@ -33,47 +35,75 @@ const Thema = async ({ params: { locale, themaSlug } }: Params) => { variables: { slug: themaSlug, locale: locale }, }); - const { title, content, child_themas, child_contents } = data.findSlug.data.attributes; + const { title, content, parents, child_themas, child_contents } = data.findSlug.data.attributes; + const parentSlug = parents?.data[0]?.attributes?.slug; + const siblingThemas: SiblingData[] = parents?.data[0]?.attributes?.child_themas?.data || []; + const siblingContent: SiblingData[] = parents?.data[0]?.attributes?.child_contents?.data || []; + + const themasLinks = + siblingThemas?.map(({ attributes: { slug, title } }: SiblingData) => ({ + title, + slug, + href: `/themas/${slug}`, + isCurrent: slug === themaSlug, + })) || []; + + const contentLinks = + siblingContent?.map(({ attributes: { slug, title } }: SiblingData) => ({ + title, + slug, + href: `/themas/${parentSlug}/content/${slug}`, + isCurrent: slug === themaSlug, + })) || []; + + const sideNavigationLinks: LinkData[] = [...themasLinks, ...contentLinks]; return ( -
- {title} - {content} -
- - {child_themas.data[0] && - child_themas.data.map((thema: any) => { - const { title, description, slug: childSlug, previewImage: imageData } = thema.attributes; - const imageUrl = imageData?.data?.attributes?.url; - return ( - - ); - })} - {child_contents.data[0] && - child_contents.data && - child_contents.data.map((content: any) => { - const { title, description, slug: contentSlug, previewImage: imageData } = content.attributes; - const imageUrl = imageData?.data?.attributes?.url; - return ( - - ); - })} + +
+ {title} + {content} +
+ + {child_themas.data[0] && + child_themas.data.map((thema: any) => { + const { title, description, slug: childSlug, previewImage: imageData } = thema.attributes; + const imageUrl = imageData?.data?.attributes?.url; + return ( + + ); + })} + {child_contents.data[0] && + child_contents.data && + child_contents.data.map((content: any) => { + const { title, description, slug: contentSlug, previewImage: imageData } = content.attributes; + const imageUrl = imageData?.data?.attributes?.url; + return ( + + ); + })} +
+ {sideNavigationLinks.length > 0 && ( +
+ +
+ )}
); }; diff --git a/apps/vth-frontend/src/components/Grid/index.style.css b/apps/vth-frontend/src/components/Grid/index.style.css index 01eae1b6..a5a1348e 100644 --- a/apps/vth-frontend/src/components/Grid/index.style.css +++ b/apps/vth-frontend/src/components/Grid/index.style.css @@ -8,6 +8,10 @@ padding-block-end: 0; } +.utrecht-grid-mobile-hidden { + display: none; +} + .utrecht-grid--content-padding { padding-block-start: 1rem; padding-inline-end: 1rem; @@ -63,6 +67,10 @@ grid-template-columns: repeat(12, 1fr); } + .utrecht-grid-mobile-hidden { + display: unset; + } + .utrecht-grid__half-width { grid-column: span 6; } diff --git a/apps/vth-frontend/src/components/SideNavigation/index.tsx b/apps/vth-frontend/src/components/SideNavigation/index.tsx new file mode 100644 index 00000000..1bc4a156 --- /dev/null +++ b/apps/vth-frontend/src/components/SideNavigation/index.tsx @@ -0,0 +1,42 @@ +import clsx from 'clsx'; +import Link from 'next/link'; +import React, { FC } from 'react'; + +export type LinkData = { + title: string; + slug: string; + href: string; + isCurrent: boolean; +}; + +export type SideNavigationProps = { + links: LinkData[]; +}; + +export const SideNavigation: FC = (props) => { + const buildNavItem = (slug: string, title: string, href: string, isCurrent: boolean) => { + return ( +
  • + +
    + {title} + +
  • + ); + }; + + return ( + + ); +}; diff --git a/apps/vth-frontend/src/query/index.ts b/apps/vth-frontend/src/query/index.ts index 1933a4f0..71816a69 100644 --- a/apps/vth-frontend/src/query/index.ts +++ b/apps/vth-frontend/src/query/index.ts @@ -62,13 +62,21 @@ query GET_THEMA_BY_SLUG($slug: String) { parents { data { attributes { - title, - slug, - description, - previewImage { + title + slug + child_themas { data { attributes { - url + title + slug + } + } + } + child_contents { + data { + attributes { + title + slug } } } @@ -125,12 +133,21 @@ query GET_CONTENT_BY_SLUG($slug: String) { parents { data { attributes { - title, + title slug - previewImage { + child_themas { data { attributes { - url + title + slug + } + } + } + child_contents { + data { + attributes { + title + slug } } } diff --git a/apps/vth-frontend/src/styles/globals.css b/apps/vth-frontend/src/styles/globals.css index 9ebb61c3..45dafbc7 100644 --- a/apps/vth-frontend/src/styles/globals.css +++ b/apps/vth-frontend/src/styles/globals.css @@ -138,13 +138,16 @@ a { object-fit: cover; } -.utrecht-navigation__toggle-button { - float: right; - position: absolute; -} - .utrecht-navigation { border-block-end-color: var(--utrecht-navigation-border-block-start-color); border-block-end-style: solid; border-block-end-width: var(--utrecht-navigation-border-block-start-width); } + +.utrecht-sidenav { + border-block-end: none; +} + +.utrecht-sidenav__item { + border-block-end: 1px solid var(--utrecht-color-grey-80); +} diff --git a/apps/vth-frontend/src/types/index.ts b/apps/vth-frontend/src/types/index.ts index afc561cc..4873a328 100644 --- a/apps/vth-frontend/src/types/index.ts +++ b/apps/vth-frontend/src/types/index.ts @@ -42,24 +42,9 @@ export interface Timing { request: number; } -export interface SearchResult { - total: number; - hits: Hit[]; - request: Request; - received: Received; - pagination: Pagination; - timing: Timing; -} - -export interface SuggestedResult { - suggestedHits: SuggestedHits; - suggestions: Suggestions; -} - -export type SuggestedHits = { - titleRaw: string; - url: string; -}; -export type Suggestions = { - text: string; +export type SiblingData = { + attributes: { + slug: string; + title: string; + }; };