diff --git a/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx b/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx index 3aa760e63a..e67a21e10f 100644 --- a/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx +++ b/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx @@ -99,25 +99,26 @@ const ComponentExamples = ({ node }: CodeExamplesProps) => { {node.dir.filer.length > 1 && (
- {node.dir.filer.map((fil) => ( - { - setUnloaded(true); - await router.replace( - `${ - router.asPath.split("#")[0] - }#${node.dir.title.toLowerCase()}demo-${fil.navn}`, - ); - }} - > - {fil.title} - - ))} + {node.dir.filer.map((fil) => { + const id = `${node.dir.title.toLowerCase()}demo-${fil.navn}`; + return ( + { + const newPath = `${router.asPath.split("#")[0]}#${id}`; + if (newPath === router.asPath) return; + setUnloaded(true); + router.replace(newPath); + }} + > + {fil.title} + + ); + })}
)}