Skip to content

Commit

Permalink
Merge pull request #91 from datasektionen/subfolders-on-subpages
Browse files Browse the repository at this point in the history
Subfolders on subpages
  • Loading branch information
Benjaneb authored Nov 10, 2024
2 parents bd3f0ba + cc64ea4 commit 238df3f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/Default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ const getPageNav = (nav) => {
};

const parseNav = (items, lang, slug) => (
<ul key={slug}>
<ul key={slug} style={{ marginBottom: "1em" }}>
{items
.sort(comparePages)
.map(item =>
<Fragment key={item.slug}>
<li>
<Link
className={item.active ? 'text-theme-color strong' : ''}
to={addLangToUrl(item.slug, lang)}
>
{item.title}
</Link>
{item.nav
? <h3>{item.title}</h3>
: <Link
className={item.active ? 'text-theme-color strong' : ''}
to={addLangToUrl(item.slug, lang)}
>
{item.title}
</Link>
}
</li>
{item.nav && parseNav(item.nav, item.slug + '/')}
{item.nav && parseNav(item.nav, lang, item.slug + '/')}
</Fragment>
)}
</ul>
Expand Down Expand Up @@ -136,7 +139,7 @@ const taitanRenderer = (location, lang) =>
({ title, body, sidebar, nav, anchors, error }) => {

// This useEffect solution is a workaround to prevent hydration errors when loading the Error page.
// useEffect does not run when doing serverside rendering, so this prevents the error page from
// useEffect does not run when doing serverside rendering, so this prevents the error page from
// rendering serverside. Rendering it serverside caused the page to crash when rendering clientside,
// since the client always tries to render the normal page first, and getting angry that it does not
// match what the server produced. (This is due to error being undefined first due to latecncy).
Expand Down

0 comments on commit 238df3f

Please sign in to comment.