Skip to content

Commit 97e4e69

Browse files
authored
[website] Add URL to GitHub issue link on 404 page (#4344)
1 parent b0e25c2 commit 97e4e69

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use client";
2+
3+
import { Link } from "@navikt/ds-react";
4+
5+
interface Props {
6+
labels: string;
7+
template: "bug-report.md";
8+
title: string;
9+
includeUrlInBody?: boolean;
10+
children: React.ReactNode;
11+
}
12+
13+
export default function GitHubIssueLink({
14+
labels,
15+
template,
16+
title,
17+
includeUrlInBody,
18+
children,
19+
}: Props) {
20+
const url = typeof window === "undefined" ? "" : window.location.href;
21+
22+
const href =
23+
"https://github.com/navikt/aksel/issues/new?" +
24+
`labels=${encodeURIComponent(labels)}` +
25+
`&template=${template}` +
26+
`&title=${encodeURIComponent(title)}` +
27+
`${includeUrlInBody ? `&body=${encodeURIComponent(`URL: ${url}`)}` : ""}`;
28+
29+
return <Link href={href}>{children}</Link>;
30+
}

aksel.nav.no/website/app/not-found.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Footer from "@/app/_ui/footer/Footer";
55
import { Header } from "@/app/_ui/header/Header";
66
import { WebsiteList, WebsiteListItem } from "@/app/_ui/typography/WebsiteList";
77
import { UmamiNotFoundPageLog } from "@/app/_ui/umami/Umami.log";
8+
import GitHubIssueLink from "./_ui/github-issue-link";
89

910
export default function NotFound() {
1011
return (
@@ -37,10 +38,15 @@ export default function NotFound() {
3738
</WebsiteListItem>
3839
</WebsiteList>
3940
</div>
40-
<Link href="https://github.com/navikt/aksel/issues/new?assignees=&labels=bug+%F0%9F%90%9B&projects=&template=bug-report.md&title=[Aksel.nav.no%20-%20404]">
41+
<GitHubIssueLink
42+
labels="bug 🐛"
43+
template="bug-report.md"
44+
title="[Aksel.nav.no - 404]"
45+
includeUrlInBody
46+
>
4147
<BugIcon aria-hidden />
4248
Meld gjerne fra om at lenken ikke virker
43-
</Link>
49+
</GitHubIssueLink>
4450
</VStack>
4551

4652
<div>

0 commit comments

Comments
 (0)