Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
fix: open demo in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman committed Nov 3, 2023
1 parent 56679ac commit 6354675
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/docs/src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SponsorButton from './SponsorButton';
import type { PaletteMode } from '@mui/material';
import type { ButtonTypeMap } from '@mui/material/Button';
import type { ExtendButtonBase } from '@mui/material/ButtonBase';
import type { DocsGroup, MenuItem, SearchablePage } from '../../interface';
import type { DocsGroup, MenuItem, MenuLink, SearchablePage } from '../../interface';

const StyledAppBar = styled(AppBar)(
({ theme }) => `
Expand Down Expand Up @@ -165,6 +165,7 @@ const Header = ({ mode, docsGroups, searchablePages, toggleColorMode }: HeaderPr
{
title: 'Demo',
url: demoUrl,
target: '_blank',
},
{
title: 'Community',
Expand Down Expand Up @@ -222,14 +223,21 @@ const Header = ({ mode, docsGroups, searchablePages, toggleColorMode }: HeaderPr
</StyledIconsWrapper>
{items.map(item => {
let url = '#';
let target: MenuLink['target'];
if ('url' in item) {
url = item.url;
target = item.target;
} else if (item.groups.length > 0 && item.groups[0].links.length > 0) {
url = item.groups[0].links[0].url;
}

return (
<StyledDesktopLink key={`desktop-${item.title}-${url}`} component={Link} href={url}>
<StyledDesktopLink
key={`desktop-${item.title}-${url}`}
component={Link}
href={url}
target={target}
>
{item.title}
</StyledDesktopLink>
);
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface MenuLink {
readonly url: string;
readonly beta?: boolean;
readonly deprecated?: boolean;
readonly target?: '_blank';
}

export interface MenuLinkSubGroup {
Expand Down

0 comments on commit 6354675

Please sign in to comment.