diff --git a/apps/web/screens/Organization/SubPage.tsx b/apps/web/screens/Organization/SubPage.tsx index 0db2c57fee70..b9a118306519 100644 --- a/apps/web/screens/Organization/SubPage.tsx +++ b/apps/web/screens/Organization/SubPage.tsx @@ -1,4 +1,3 @@ -import { Locale } from '@island.is/shared/types' import { useRouter } from 'next/router' import { ParsedUrlQuery } from 'querystring' @@ -14,6 +13,7 @@ import { Stack, Text, } from '@island.is/island-ui/core' +import { Locale } from '@island.is/shared/types' import { getThemeConfig, OrganizationWrapper, @@ -60,46 +60,13 @@ export interface SubPageProps { customContentfulIds?: (string | undefined)[] } -const SubPage: Screen = ({ - organizationPage, +const SubPageContent = ({ subpage, namespace, - locale, - customContent, - customBreadcrumbItems, - customContentfulIds, - backLink, -}) => { - const router = useRouter() - const { activeLocale } = useI18n() - + organizationPage, +}: Pick) => { const n = useNamespace(namespace) - const { linkResolver } = useLinkResolver() - - const contentfulIds = customContentfulIds - ? customContentfulIds - : [organizationPage?.id, subpage?.id] - - useContentfulId(...contentfulIds) - - const pathname = new URL(router.asPath, 'https://island.is').pathname - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore make web strict - const navList: NavigationItem[] = organizationPage?.menuLinks.map( - ({ primaryLink, childrenLinks }) => ({ - title: primaryLink?.text, - href: primaryLink?.url, - active: - primaryLink?.url === pathname || - childrenLinks.some((link) => link.url === pathname), - items: childrenLinks.map(({ text, url }) => ({ - title: text, - href: url, - active: url === pathname, - })), - }), - ) - + const { activeLocale } = useI18n() const content = ( <> {subpage?.showTableOfContents && ( @@ -147,45 +114,8 @@ const SubPage: Screen = ({ ) - return ( - + <> @@ -199,62 +129,58 @@ const SubPage: Screen = ({ subpage?.links?.length ? '7/12' : '12/12', ]} > - {customContent ? ( - customContent - ) : ( - <> - - - {subpage?.title} - - - - + + + {subpage?.title} + + + + + {subpage?.signLanguageVideo?.url && ( + + + {subpage.title} + + {content} + {renderSlices( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore make web strict + subpage.slices, + subpage.sliceCustomRenderer, + subpage.sliceExtraText, + namespace, + organizationPage?.slug, + )} + + } /> - {subpage?.signLanguageVideo?.url && ( - - - {subpage.title} - - {content} - {renderSlices( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore make web strict - subpage.slices, - subpage.sliceCustomRenderer, - subpage.sliceExtraText, - namespace, - organizationPage?.slug, - )} - - } - /> - )} - - - )} + )} + + - {!customContent && content} + {content} @@ -277,6 +203,107 @@ const SubPage: Screen = ({ organizationPage.slug, )} + + ) +} + +const SubPage: Screen = ({ + organizationPage, + subpage, + namespace, + locale, + customContent, + customBreadcrumbItems, + customContentfulIds, + backLink, +}) => { + const router = useRouter() + + const n = useNamespace(namespace) + const { linkResolver } = useLinkResolver() + + const contentfulIds = customContentfulIds + ? customContentfulIds + : [organizationPage?.id, subpage?.id] + + useContentfulId(...contentfulIds) + + const pathname = new URL(router.asPath, 'https://island.is').pathname + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore make web strict + const navList: NavigationItem[] = organizationPage?.menuLinks.map( + ({ primaryLink, childrenLinks }) => ({ + title: primaryLink?.text, + href: primaryLink?.url, + active: + primaryLink?.url === pathname || + childrenLinks.some((link) => link.url === pathname), + items: childrenLinks.map(({ text, url }) => ({ + title: text, + href: url, + active: url === pathname, + })), + }), + ) + + return ( + + {customContent ? ( + + + + + {customContent} + + + + + ) : ( + + )} ) }