Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 622ecbe

Browse files
Handle broken links in header and footer (#3663)
Co-authored-by: Nicolas Dorseuil <nicolas@gitbook.io>
1 parent fa1382b commit 622ecbe

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

‎packages/gitbook/src/components/Footer/FooterLinksGroup.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ async function FooterLink(props: { link: CustomizationContentLink; context: GitB
3636
const { link, context } = props;
3737
const resolved = await resolveContentRef(link.to, context);
3838

39-
if (!resolved) {
40-
return null;
41-
}
42-
4339
return (
4440
<Link
45-
href={resolved.href}
41+
href={resolved?.href??'#'}
4642
className={tcls(
4743
'font-normal',
4844
'text-tint',

‎packages/gitbook/src/components/Header/HeaderLink.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function HeaderLink(props: {
5757
);
5858
}
5959

60-
if (!target||!link.to) {
60+
if (!link.to) {
6161
return null;
6262
}
6363

@@ -68,7 +68,7 @@ export async function HeaderLink(props: {
6868
headerPreset={headerPreset}
6969
title={link.title}
7070
isDropdown={false}
71-
href={target.href}
71+
href={target?.href}
7272
/>
7373
);
7474
}
@@ -78,7 +78,7 @@ export type HeaderLinkNavItemProps = {
7878
linkStyle: NonNullable<CustomizationHeaderItem['style']>;
7979
headerPreset: CustomizationHeaderPreset;
8080
title: string;
81-
href: string;
81+
href?: string;
8282
isDropdown: boolean;
8383
} & DropdownButtonProps<HTMLElement>;
8484

@@ -165,7 +165,7 @@ function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
165165
const { linkTarget, headerPreset, title, isDropdown, href, ...rest } = props;
166166
return (
167167
<Link
168-
href={href}
168+
href={href??'#'}
169169
className={getHeaderLinkClassName({ headerPreset })}
170170
insights={{
171171
type: 'link_click',

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /