Skip to content

Commit 6602a7c

Browse files
committed
Create ExternalLink component
1 parent dca400c commit 6602a7c

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

src/components/layout.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Grommet } from "grommet";
44
import type * as React from "react";
55
import "./layout.css";
66
import {
7-
Anchor,
87
Box,
98
Button,
109
Footer,
@@ -15,6 +14,7 @@ import {
1514
grommet,
1615
} from "grommet";
1716
import { Github as GithubIcon } from "grommet-icons";
17+
import { ExternalLink } from "./link";
1818

1919
interface Props {
2020
children: React.ReactNode;
@@ -68,10 +68,8 @@ const AppHeader = () => {
6868
/>
6969
</Box>
7070
<Box align="end">
71-
<Anchor
71+
<ExternalLink
7272
href="https://github.com/browser-actions"
73-
target="_blank"
74-
rel="noopener noreferrer"
7573
label="GitHub"
7674
icon={<GithubIcon />}
7775
/>
@@ -85,22 +83,14 @@ const AppFooter = () => {
8583
<Footer background="dark-1" pad="medium" justify="between">
8684
<Text>
8785
Copyright by{" "}
88-
<Anchor
89-
href="https://github.com/ueokande"
90-
target="_blank"
91-
rel="noopener noreferrer"
92-
>
86+
<ExternalLink href="https://github.com/ueokande">
9387
@ueokande
94-
</Anchor>{" "}
88+
</ExternalLink>{" "}
9589
and all contributors
9690
</Text>
97-
<Anchor
98-
href="https://github.com/browser-actions"
99-
target="_blank"
100-
rel="noopener noreferrer"
101-
>
91+
<ExternalLink href="https://github.com/browser-actions">
10292
GitHub
103-
</Anchor>
93+
</ExternalLink>
10494
</Footer>
10595
);
10696
};

src/components/link.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Anchor, type AnchorProps } from "grommet";
2+
3+
interface Props {
4+
children?: React.ReactNode;
5+
}
6+
7+
export const ExternalLink: React.FC<Props & AnchorProps> = ({
8+
children,
9+
...props
10+
}) => {
11+
return (
12+
<Anchor {...props} target="_blank" rel="noopener noreferrer">
13+
{children}
14+
</Anchor>
15+
);
16+
};

src/templates/action.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "grommet";
1212
import { Actions as ActionsIcon, Github as GithubIcon } from "grommet-icons";
1313
import { Layout } from "../components/layout";
14+
import { ExternalLink } from "../components/link";
1415
import { Seo } from "../components/seo";
1516
import type { ActionType } from "../types";
1617

@@ -30,20 +31,14 @@ const ActionPage: React.FC<PageProps & Props> = ({ pageContext }) => {
3031
<Page kind="narrow" margin={{ vertical: "xlarge" }}>
3132
<PageContent>
3233
<Box direction="row" gap="medium" pad={{ bottom: "medium" }}>
33-
<Anchor
34+
<ExternalLink
3435
href={`https://github.com/marketplace/actions/${name}`}
35-
target="_blank"
36-
rel="noopener noreferrer"
37-
as="a"
3836
label="View action on Marketplace"
3937
icon={<ActionsIcon />}
4038
size="small"
4139
/>
42-
<Anchor
40+
<ExternalLink
4341
href={`https://github.com/browser-actions/${name}`}
44-
target="_blank"
45-
rel="noopener noreferrer"
46-
as="a"
4742
label="View action on GitHub"
4843
icon={<GithubIcon />}
4944
size="small"

0 commit comments

Comments
 (0)