Skip to content

Commit 2f482e9

Browse files
committed
Fix links
1 parent d59e6e0 commit 2f482e9

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

web/components/links.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Link from "next/link";
2+
3+
export const CustomLink = ({href, children}: { href?: string; children: React.ReactNode }) => {
4+
if (!href) return <>{children}</>
5+
6+
// If href is internal, use Next.js Link
7+
if (href.startsWith('/')) {
8+
return <Link href={href}>{children}</Link>
9+
}
10+
11+
// For external links, fall back to <a>
12+
return (
13+
<a href={href} target="_blank" rel="noopener noreferrer">
14+
{children}
15+
</a>
16+
)
17+
}

web/components/markdown.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
import {PageBase} from "web/components/page-base";
22
import {Col} from "web/components/layout/col";
33
import ReactMarkdown from "react-markdown";
4-
5-
import Link from "next/link";
64
import {SEO} from "web/components/SEO";
75
import {capitalize} from "lodash";
6+
import {CustomLink} from "web/components/links";
87

98
type Props = {
109
content: string;
1110
filename: string;
1211
};
1312

14-
const MarkdownLink = ({href, children}: { href?: string; children: React.ReactNode }) => {
15-
if (!href) return <>{children}</>
16-
17-
// If href is internal, use Next.js Link
18-
if (href.startsWith('/')) {
19-
return <Link href={href}>{children}</Link>
20-
}
21-
22-
// For external links, fall back to <a>
23-
return (
24-
<a href={href} target="_blank" rel="noopener noreferrer">
25-
{children}
26-
</a>
27-
)
28-
}
29-
30-
export const CompassMarkdown = ({children}: { children: string }) => {
13+
export const CustomMarkdown = ({children}: { children: string }) => {
3114
return <ReactMarkdown
3215
components={{
33-
a: ({node: _node, children, ...props}) => <MarkdownLink {...props}>{children}</MarkdownLink>
16+
a: ({node: _node, children, ...props}) => <CustomLink {...props}>{children}</CustomLink>
3417
}}
3518
>
3619
{children}
@@ -48,7 +31,7 @@ export default function MarkdownPage({content, filename}: Props) {
4831
/>
4932
<Col className="items-center mb-8">
5033
<Col className='w-full rounded px-3 py-4 sm:px-6 space-y-4 custom-link'>
51-
<CompassMarkdown>{content}</CompassMarkdown>
34+
<CustomMarkdown>{content}</CustomMarkdown>
5235
</Col>
5336
</Col>
5437
</PageBase>

web/pages/news.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {PageBase} from "web/components/page-base"
44
import {SEO} from "web/components/SEO"
55
import {Col} from "web/components/layout/col"
66
import {Title} from "web/components/widgets/title"
7-
import Link from "next/link"
87
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator"
98
import {githubRepoSlug} from "common/constants";
10-
import {CompassMarkdown} from "web/components/markdown";
9+
import {CustomMarkdown} from "web/components/markdown";
10+
import {CustomLink} from "web/components/links";
1111

1212
type Release = {
1313
id: number
@@ -66,11 +66,11 @@ export default function WhatsNew() {
6666
</span>
6767
</div>
6868
<div className="mt-4 mb-4 prose prose-neutral dark:prose-invert text-ink-1000">
69-
<CompassMarkdown>
69+
<CustomMarkdown>
7070
{formatPullLinks(release.body || "_No release notes provided._")}
71-
</CompassMarkdown>
71+
</CustomMarkdown>
7272
</div>
73-
<Link href={release.html_url}>View on GitHub</Link>
73+
<CustomLink href={release.html_url}>View on GitHub</CustomLink>
7474
</div>
7575
))}
7676
</Col>

0 commit comments

Comments
 (0)