Skip to content

Commit 2c8f334

Browse files
author
Brijesh Bittu
committed
Add heading id and links
1 parent ca14f4b commit 2c8f334

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"next": "15.1.6",
2323
"react": "^19.0.0",
2424
"react-dom": "^19.0.0",
25+
"rehype-autolink-headings": "^7.1.0",
2526
"rehype-highlight": "^7.0.2",
2627
"rehype-pretty-code": "^0.14.0",
2728
"rehype-slug": "^6.0.0",

docs/src/components/Changelog.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ export async function Changelog() {
88
encoding: 'utf-8',
99
});
1010
await file.close();
11-
content = content.replaceAll(/<!-(.*?)->/gm, '').replaceAll('<--', '');
11+
content = content
12+
// Remove the first line as it doesn't make sense on the page
13+
.replace('# [Versions](https://mui.com/versions/)', '')
14+
.trim()
15+
// Manually remove markdown comments and other fragments that MDX
16+
// doesn't support.
17+
.replaceAll(/<!-(.*?)->/gm, '')
18+
.replaceAll('<--', '');
1219
const MdxContent = await renderMdx(content);
1320
return <MdxContent components={mdxComponents} />;
1421
}

docs/src/mdx-components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const mdxComponents: MDXComponents = {
1212
h1: (props) => (
1313
<React.Fragment>
1414
<Styled.Heading {...props} />
15-
<title>{getChildrenText(props.children)}</title>
15+
<title>{`${getChildrenText(props.children)} · ${process.env.APP_NAME}`}</title>
1616
</React.Fragment>
1717
),
1818
h2: (props) => (

docs/src/utils/mdx.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import remarkGfm from 'remark-gfm';
88
import remarkTypography from 'remark-typography';
99
import rehypePrettyCode, { type Theme } from 'rehype-pretty-code';
1010
import rehypeExtractToc from '@stefanprobst/rehype-extract-toc';
11+
import rehypeSlug from 'rehype-slug';
12+
import rehyeAutolinkHeading from 'rehype-autolink-headings';
1113

1214
import { rehypeSubtitle } from './rehype/rehypeSubtitle';
1315
import { rehypeInlineCode } from './rehype/rehypeInlineCode';
@@ -346,6 +348,8 @@ export async function renderMdx(mdxSource: string) {
346348
remarkPlugins: [remarkGfm, remarkTypography],
347349
rehypePlugins: [
348350
[rehypePrettyCode, prettyCodeOptions],
351+
rehypeSlug,
352+
rehyeAutolinkHeading,
349353
rehypeExtractToc,
350354
rehypeSubtitle,
351355
rehypeInlineCode,

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)