From 6555487b2effbef5f509e19d5a886f5d9b1239ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4ck?= Date: Mon, 4 Sep 2023 13:15:21 +0300 Subject: [PATCH 1/3] Update table of contents styling --- components/TableOfContents.tsx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/TableOfContents.tsx b/components/TableOfContents.tsx index b75a895..f542491 100644 --- a/components/TableOfContents.tsx +++ b/components/TableOfContents.tsx @@ -4,18 +4,23 @@ import { titleToAnchor } from '@utils/helpers' const TableOfContents = ({ sections }: { sections: Section[] }) => { return ( - + <> +

Innehållsförteckning

+ + + {sections.map((section, i) => ( + + + {section.attributes.title} + + + ))} + +
+ ) } From 2395d072719feff6eb8d9f9b4b8c0b330f4cea72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4ck?= Date: Mon, 4 Sep 2023 13:40:39 +0300 Subject: [PATCH 2/3] Improve content page anchor links Trim anchor tags, add scroll margin to section headers --- components/PageSection.tsx | 4 +++- utils/helpers.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/PageSection.tsx b/components/PageSection.tsx index 0fe1485..74ab747 100644 --- a/components/PageSection.tsx +++ b/components/PageSection.tsx @@ -18,7 +18,9 @@ const PageSection = ({ isPrivate, }: PageSectionProps) => (
-

{title}

+

+ {title} +

=> { export const titleToAnchor = (title: string) => { return title + .trim() .replace(/ /g, '-') .replace(/[\/\\^$*+?.()|\[\]{}<>:;"'~,=@`#!%&]/g, '') .toLowerCase() From 0d4e341e0dd82aa7ddb6baf779566895afc7b5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4ck?= Date: Mon, 4 Sep 2023 14:03:23 +0300 Subject: [PATCH 3/3] Show page instead of redirecting unauthorized users --- components/Page.tsx | 54 +++++++++++++++++++++------------- components/Unauthorized.tsx | 18 ++++++++++++ pages/medlem/[privatePage].tsx | 14 ++------- 3 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 components/Unauthorized.tsx diff --git a/components/Page.tsx b/components/Page.tsx index 91602fc..de548a5 100644 --- a/components/Page.tsx +++ b/components/Page.tsx @@ -7,6 +7,7 @@ import { NationLogo } from '@components/footer/Logos' import Footer from '@components/footer' import TableOfContents from '@components/TableOfContents' import PageSection from '@components/PageSection' +import Unauthorized from '@components/Unauthorized' const renderer: marked.RendererObject = { image(href: string | null): string { @@ -24,34 +25,47 @@ type PageProps = { logos: NationLogo[] navbarLinks: NavbarLink[] isPrivate: boolean + unauthorized?: boolean } -const Page: NextPage = ({ page, navbarLinks, logos, isPrivate }) => { +const Page: NextPage = ({ + page, + navbarLinks, + logos, + isPrivate, + unauthorized = false, +}) => { return (
-

{page?.title}

- {page?.content && ( -
+ {unauthorized ? ( + + ) : ( + <> +

{page?.title}

+ {page?.content && ( +
+ )} + {page?.showTableOfContents && ( + + )} + {page?.sections?.data.map((section, i) => ( + + ))} + )} - {page?.showTableOfContents && ( - - )} - {page?.sections?.data.map((section, i) => ( - - ))}