From 380b448c942f8ce393d7cb8d5b9a8e347d28901c Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 6 Dec 2023 14:38:00 +0100 Subject: [PATCH] :zap: Slug bruker staticprops, oppdatert views --- .../god-praksis-page/GodPraksisPage.tsx | 2 +- .../god-praksis-page/articles/ArticleList.tsx | 21 ++++-------- .../layout/god-praksis-page/chips/ChipNav.tsx | 9 +++-- .../layout/god-praksis-page/types.ts | 8 +---- aksel.nav.no/website/pages/gp/[slug].tsx | 28 +-------------- aksel.nav.no/website/pages/gp/index.tsx | 34 ++----------------- 6 files changed, 18 insertions(+), 84 deletions(-) diff --git a/aksel.nav.no/website/components/layout/god-praksis-page/GodPraksisPage.tsx b/aksel.nav.no/website/components/layout/god-praksis-page/GodPraksisPage.tsx index e6f98a722f..31f9e4c39e 100644 --- a/aksel.nav.no/website/components/layout/god-praksis-page/GodPraksisPage.tsx +++ b/aksel.nav.no/website/components/layout/god-praksis-page/GodPraksisPage.tsx @@ -33,7 +33,7 @@ function GodPraksisPage(props: GpEntryPageProps) { /> - + diff --git a/aksel.nav.no/website/components/layout/god-praksis-page/articles/ArticleList.tsx b/aksel.nav.no/website/components/layout/god-praksis-page/articles/ArticleList.tsx index 632f6ed085..3532e039fd 100644 --- a/aksel.nav.no/website/components/layout/god-praksis-page/articles/ArticleList.tsx +++ b/aksel.nav.no/website/components/layout/god-praksis-page/articles/ArticleList.tsx @@ -1,26 +1,19 @@ import ErrorBoundary from "@/error-boundary"; -import { GpArticleViews } from "@/layout/god-praksis-page/types"; +import { GpArticleListT } from "@/layout/god-praksis-page/types"; import ArticleGrid from "./ArticleGrid"; const markRandomAsNew = (articles) => { return [...articles].map((a) => ({ ...a, isNew: Math.random() > 0.5 })); }; -function ArticleList({ views }: GpArticleViews) { - return ( - <> - {views.map((view) => ( - - ))} - - ); +function ArticleList({ articles }: GpArticleListT) { + /* const router = useRouter(); + const innholdstype = decodeURIComponent(router.query.innholdstype); */ + + return ; } -export default function Component(props: GpArticleViews) { +export default function Component(props: GpArticleListT) { return ( diff --git a/aksel.nav.no/website/components/layout/god-praksis-page/chips/ChipNav.tsx b/aksel.nav.no/website/components/layout/god-praksis-page/chips/ChipNav.tsx index a36bf901d9..c073a259aa 100644 --- a/aksel.nav.no/website/components/layout/god-praksis-page/chips/ChipNav.tsx +++ b/aksel.nav.no/website/components/layout/god-praksis-page/chips/ChipNav.tsx @@ -19,8 +19,10 @@ function ChipNav({ type, options }: ChipsNavProps) { function handleSelect(title: string) { query[type] === title - ? replace({ query: omit(query, [type]) }, undefined) - : replace({ query: { ...query, [type]: title } }); + ? replace({ query: omit(query, [type]) }, undefined, { shallow: true }) + : replace({ query: { ...query, [type]: title } }, undefined, { + shallow: true, + }); } return ( @@ -42,8 +44,9 @@ function ChipNav({ type, options }: ChipsNavProps) { checkmark={false} selected={encodeURIComponent(option) === query?.[type]} onClick={() => handleSelect(encodeURIComponent(option))} + className="whitespace-nowrap" > - {option} + {`${option} 4`} ))} diff --git a/aksel.nav.no/website/components/layout/god-praksis-page/types.ts b/aksel.nav.no/website/components/layout/god-praksis-page/types.ts index 800916773d..516d3265e1 100644 --- a/aksel.nav.no/website/components/layout/god-praksis-page/types.ts +++ b/aksel.nav.no/website/components/layout/god-praksis-page/types.ts @@ -33,13 +33,7 @@ export type GpInnholdstypeT = { }[]; }; -export type GpArticleViews = { - views: ({ - title: string; - } & GpArticleListT)[]; -}; - export type GpEntryPageProps = HeroNavT & GpInnholdstypeT & - GpArticleViews & + GpArticleListT & GpTemaT; diff --git a/aksel.nav.no/website/pages/gp/[slug].tsx b/aksel.nav.no/website/pages/gp/[slug].tsx index 35ae854a6d..d554cdfcb3 100644 --- a/aksel.nav.no/website/pages/gp/[slug].tsx +++ b/aksel.nav.no/website/pages/gp/[slug].tsx @@ -74,12 +74,7 @@ export const getStaticProps: GetStaticProps = async ({ return { props: { - views: [ - { - title: "Siste", - articles, - }, - ], + articles, tema, heroNav: heroNav.filter((x) => x.hasRefs), innholdstype: innholdstype.filter((x) => x.hasRefs), @@ -119,27 +114,6 @@ const Wrapper = (props: any) => { params={{ slug: props?.slug, }} - resolvers={[ - { - key: "views", - dataKeys: ["articles"], - cb: (v) => { - return [ - { - title: "Siste", - articles: v[0], - }, - ]; - }, - }, - { - key: "articles", - dataKeys: ["articles"], - cb: () => { - return undefined; - }, - }, - ]} /> ); diff --git a/aksel.nav.no/website/pages/gp/index.tsx b/aksel.nav.no/website/pages/gp/index.tsx index f08c74a865..85020cbaa3 100644 --- a/aksel.nav.no/website/pages/gp/index.tsx +++ b/aksel.nav.no/website/pages/gp/index.tsx @@ -46,12 +46,7 @@ export const getStaticProps: GetStaticProps = async ({ return { props: { tema: null, - views: [ - { - title: "Siste", - articles, - }, - ], + articles, heroNav: heroNav.filter((x) => x.hasRefs), innholdstype: innholdstype.filter((x) => x.hasRefs), preview, @@ -82,32 +77,7 @@ const Wrapper = (props: any) => { if (props?.preview) { return ( }> - { - return [ - { - title: "Siste", - articles: v[0], - }, - ]; - }, - }, - { - key: "articles", - dataKeys: ["articles"], - cb: () => { - return undefined; - }, - }, - ]} - /> + ); }