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

Commit c4733ca

Browse files
committed
docs: add beta flag in nav and page header
1 parent 386a096 commit c4733ca

File tree

7 files changed

+54
-6
lines changed

7 files changed

+54
-6
lines changed

packages/docs/next.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ let config = {
1818
redirects: async () => {
1919
return redirects;
2020
},
21+
images: {
22+
remotePatterns: [
23+
{
24+
protocol: 'https',
25+
hostname: 'img.shields.io',
26+
port: '',
27+
pathname: '/badge/**',
28+
},
29+
],
30+
},
2131
}
2232

2333
if (process.env.NODE_ENV === 'production') {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Image from 'next/image';
2+
3+
const BetaImage = () => {
4+
return (
5+
<Image
6+
src="https://img.shields.io/badge/-Beta%20Feature-blue"
7+
alt="Beta Feature. Use at your own risk"
8+
title="Beta Feature. Use at your own risk"
9+
width={81}
10+
height={20}
11+
/>
12+
);
13+
};
14+
15+
export default BetaImage;

packages/docs/src/components/docs/DocsLeftNavGroup.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import Collapse from '@mui/material/Collapse';
33
import List from '@mui/material/List';
44
import ListItemButton from '@mui/material/ListItemButton';
55
import ListItemText from '@mui/material/ListItemText';
6-
import { useTheme } from '@mui/material/styles';
6+
import { styled, useTheme } from '@mui/material/styles';
77
import Link from 'next/link';
88
import { useRouter } from 'next/router';
99
import { useState } from 'react';
1010

11+
import BetaImage from './BetaImage';
12+
1113
import type { DocsGroupLink } from '../../interface';
1214

15+
const StyledListItemPrimary = styled('div')`
16+
display: flex;
17+
align-items: center;
18+
gap: 8px;
19+
`;
20+
1321
export interface DocsLeftNavGroupProps {
1422
name: string;
1523
links: DocsGroupLink[];
@@ -54,7 +62,12 @@ const DocsLeftNavGroup = ({ name, links }: DocsLeftNavGroupProps) => {
5462
color: selected ? theme.palette.primary.main : theme.palette.text.secondary,
5563
fontWeight: selected ? 600 : 400,
5664
}}
57-
primary={link.title}
65+
primary={
66+
<StyledListItemPrimary>
67+
{link.title}
68+
{link.beta ? <BetaImage /> : null}
69+
</StyledListItemPrimary>
70+
}
5871
/>
5972
</ListItemButton>
6073
);

packages/docs/src/components/docs/components/headers/Header1.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Header1 = ({ children }: Header1Props) => {
1414
const anchor = useAnchor(textContent);
1515

1616
return (
17-
<Typography variant="h1" id={anchor}>
17+
<Typography variant="h1" id={anchor} sx={{ display: 'flex', gap: '8px', alignItems: 'center' }}>
1818
{children}
1919
</Typography>
2020
);

packages/docs/src/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface DocsData {
7474
readonly title: string;
7575
readonly weight: number;
7676
readonly slug: string;
77+
readonly beta?: boolean;
7778
}
7879

7980
export interface DocsPageHeading {
@@ -92,6 +93,7 @@ export interface DocsPage {
9293
export interface DocsGroupLink {
9394
readonly title: string;
9495
readonly slug: string;
96+
readonly beta: boolean;
9597
}
9698

9799
export interface DocsGroup {

packages/docs/src/lib/docs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export function fetchDocsContent(): [DocsPage[], DocsGroup[]] {
136136
acc[doc.data.group].push({
137137
title: doc.data.title,
138138
slug: doc.data.slug,
139+
beta: doc.data.beta ?? false,
139140
});
140141
return acc;
141142
}, {} as Record<string, DocsGroupLink[]>);

packages/docs/src/pages/docs/[doc].tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MDXRemote } from 'next-mdx-remote';
44
import { serialize } from 'next-mdx-remote/serialize';
55
import remarkGfm from 'remark-gfm';
66

7+
import BetaImage from '../../components/docs/BetaImage';
78
import Anchor from '../../components/docs/components/Anchor';
89
import Blockquote from '../../components/docs/components/Blockquote';
910
import CodeTabs from '../../components/docs/components/CodeTabs';
@@ -76,7 +77,8 @@ interface DocsProps {
7677
searchablePages: SearchablePage[];
7778
title: string;
7879
slug: string;
79-
description?: string;
80+
beta: boolean;
81+
description: string;
8082
source: MDXRemoteSerializeResult;
8183
}
8284

@@ -85,8 +87,9 @@ const Docs = ({
8587
searchablePages,
8688
title,
8789
slug,
88-
description = '',
90+
description,
8991
source,
92+
beta,
9093
}: DocsProps) => {
9194
const theme = useTheme();
9295

@@ -103,7 +106,10 @@ const Docs = ({
103106
<StyledDocsView className={theme.palette.mode}>
104107
<StyledDocsContentWrapper>
105108
<DocsContent>
106-
<Header1>{title}</Header1>
109+
<Header1>
110+
{title}
111+
{beta ? <BetaImage /> : null}
112+
</Header1>
107113
<MDXRemote
108114
{...source}
109115
components={{
@@ -172,6 +178,7 @@ export const getStaticProps: GetStaticProps = async ({ params }): Promise<{ prop
172178
searchablePages: getSearchablePages(),
173179
title: data.title,
174180
slug: data.slug,
181+
beta: data.beta ?? false,
175182
description: '',
176183
source,
177184
},

0 commit comments

Comments
 (0)