-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: baseUri and process.env inside components
- Loading branch information
1 parent
2bcc1f4
commit 14ed21e
Showing
8 changed files
with
121 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,54 @@ | ||
import 'server-only'; | ||
|
||
import { type Dictionary } from '@fdk-frontend/dictionaries'; | ||
import { getPaths } from '@fdk-frontend/utils'; | ||
import { Link } from '@digdir/designsystemet-react'; | ||
import styles from './breadcrumbs.module.css'; | ||
import { unstable_noStore as noStore } from 'next/cache'; | ||
|
||
export type BreadcrumbType = { | ||
href: string; | ||
text: string; | ||
}; | ||
|
||
export type BreadcrumbsProps = { | ||
baseURI?: string; | ||
breadcrumbList?: BreadcrumbType[]; | ||
dictionary: Dictionary; | ||
}; | ||
|
||
const Breadcrumbs = async ({ baseURI, breadcrumbList, dictionary }: BreadcrumbsProps) => ( | ||
<div className={styles.container}> | ||
<nav className={styles.breadcrumbs}> | ||
<span> | ||
<Link | ||
className={styles.link} | ||
aria-label={dictionary.homePage} | ||
href={baseURI ?? process.env.FDK_BASE_URI ?? getPaths().root} | ||
> | ||
{dictionary.homePage} | ||
</Link> | ||
{breadcrumbList?.map((breadcrumb, i) => ( | ||
<span key={breadcrumb.href}> | ||
<span className={styles.separator}>{'>'}</span> | ||
{i === breadcrumbList.length - 1 ? ( | ||
<span className={styles.deactiveLink}>{breadcrumb.text}</span> | ||
) : ( | ||
<Link | ||
className={styles.link} | ||
href={breadcrumb.href} | ||
> | ||
{breadcrumb.text} | ||
</Link> | ||
)} | ||
</span> | ||
))} | ||
</span> | ||
</nav> | ||
</div> | ||
); | ||
const Breadcrumbs = async ({ breadcrumbList, dictionary }: BreadcrumbsProps) => { | ||
// Opt-in dynamic rendering | ||
noStore(); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<nav className={styles.breadcrumbs}> | ||
<span> | ||
<Link | ||
className={styles.link} | ||
aria-label={dictionary.homePage} | ||
href={process.env.FDK_BASE_URI ?? '/'} | ||
> | ||
{dictionary.homePage} | ||
</Link> | ||
{breadcrumbList?.map((breadcrumb, i) => ( | ||
<span key={breadcrumb.href}> | ||
<span className={styles.separator}>{'>'}</span> | ||
{i === breadcrumbList.length - 1 ? ( | ||
<span className={styles.deactiveLink}>{breadcrumb.text}</span> | ||
) : ( | ||
<Link | ||
className={styles.link} | ||
href={breadcrumb.href} | ||
> | ||
{breadcrumb.text} | ||
</Link> | ||
)} | ||
</span> | ||
))} | ||
</span> | ||
</nav> | ||
</div> | ||
); | ||
}; | ||
|
||
export { Breadcrumbs }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.