Skip to content

Commit 74a47ab

Browse files
Barsnesmrosvik
andauthored
docs: Add "edit on github" link to pages (#1388)
Co-authored-by: Marianne Røsvik <marianne.rosvik@digdir.no>
1 parent e6fa1da commit 74a47ab

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client';
2+
import type { HTMLAttributes } from 'react';
3+
import React from 'react';
4+
import Image from 'next/image';
5+
import { Link } from '@digdir/design-system-react';
6+
import { useRouter } from 'next/router';
7+
8+
export const GithubLink = ({ ...rest }: HTMLAttributes<HTMLAnchorElement>) => {
9+
const { asPath } = useRouter();
10+
const href = `https://github.com/digdir/designsystemet/tree/main/apps/storefront/pages${asPath}.mdx`;
11+
12+
return (
13+
<Link
14+
href={href}
15+
target='_blank'
16+
rel='noopener noreferrer'
17+
{...rest}
18+
>
19+
<Image
20+
height={20}
21+
width={20}
22+
alt='github logo'
23+
src='/img/logos/github-logo.svg'
24+
/>
25+
Rediger denne siden på Github
26+
</Link>
27+
);
28+
};
29+
30+
export default GithubLink;

apps/storefront/layouts/MenuPageLayout/MenuPageLayout.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
padding: var(--fds-spacing-4) var(--fds-spacing-7) 0 var(--fds-spacing-7);
5454
}
5555

56+
.githubLink {
57+
margin-top: var(--fds-spacing-6);
58+
}
59+
5660
@media (max-width: 576px) {
5761
.content {
5862
padding: 0;

apps/storefront/layouts/MenuPageLayout/MenuPageLayout.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { useRouter } from 'next/router';
33

4+
import GithubLink from 'components/Link/Github/GithubLink';
5+
46
import { Container, SidebarMenu, MdxContent } from '../../components';
57

68
import classes from './MenuPageLayout.module.css';
@@ -38,6 +40,7 @@ const MenuPageLayout = ({ content, data }: PageLayoutProps) => {
3840
id='content'
3941
>
4042
<MdxContent>{content}</MdxContent>
43+
<GithubLink className={classes.githubLink} />
4144
</div>
4245
</main>
4346
</Container>

apps/storefront/pages/grunnleggende/introduksjon/designprinsipper.mdx

-7
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,3 @@ Eksempel på opplevelser vi ønsker at innbyggerne skal ha i møte med oss:
7474
- Interaction Design Foundation: [Design principles](https://www.interaction-design.org/literature/topics/design-principles)
7575
- Jon Yablonski: [Laws of UX](https://lawsofux.com/)
7676
- Netlife Blogg: [5 prinsipper for god brukeropplevelse](https://www.netlife.com/blogg/5-prinsipper-for-god-brukeropplevelse-ux)
77-
78-
\
79-
\
80-
\
81-
Bidra til denne oversikten i [Github](https://github.com/digdir/designsystemet/tree/main/apps/storefront/pages/god-praksis/brukerinnsikt/designprinsipper).
82-
83-
---

0 commit comments

Comments
 (0)