Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions components/AnchoredHeading.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions next.dynamic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { readFileSync } from 'node:fs';
import { VFile } from 'vfile';
import remarkGfm from 'remark-gfm';
import remarkHeadings from '@vcarl/remark-headings';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import { serialize } from 'next-mdx-remote/serialize';
import * as nextLocales from './next.locales.mjs';
import * as nextConstants from './next.constants.mjs';
Expand Down Expand Up @@ -157,6 +159,16 @@ export const getStaticProps = async (source = '', filename = '') => {
const { compiledSource } = await serialize(sourceAsVirtualFile, {
parseFrontmatter: true,
mdxOptions: {
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behaviour: 'append',
properties: { ariaHidden: true, tabIndex: -1, class: 'anchor' },
},
],
],
remarkPlugins: [remarkGfm, remarkHeadings],
format: filename.includes('.mdx') ? 'mdx' : 'md',
},
Expand Down
89 changes: 89 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"prismjs": "~1.29.0",
"react-icons": "~4.10.1",
"react-intl": "~6.4.4",
"rehype-autolink-headings": "~6.1.1",
"rehype-slug": "~5.1.0",
"remark-gfm": "~3.0.1",
"semver": "~7.5.4",
"sharp": "0.32.4",
Expand Down
7 changes: 0 additions & 7 deletions providers/mdxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ import { MDXProvider as BaseMDXProvider } from '@mdx-js/react';
import { MDXRemote } from 'next-mdx-remote';
import HighlightJS from 'highlight.js/lib/core';
import HighlightJavaScript from 'highlight.js/lib/languages/javascript';
import AnchoredHeading from '@/components/AnchoredHeading';
import NodeApiVersionLinks from '@/components/Docs/NodeApiVersionLinks';
import type { FC } from 'react';
import type { MDXComponents } from 'mdx/types';

const mdxComponents: MDXComponents = {
NodeApiVersionLinks: NodeApiVersionLinks,
h1: props => <AnchoredHeading level={1} {...props} />,
h2: props => <AnchoredHeading level={2} {...props} />,
h3: props => <AnchoredHeading level={3} {...props} />,
h4: props => <AnchoredHeading level={4} {...props} />,
h5: props => <AnchoredHeading level={5} {...props} />,
h6: props => <AnchoredHeading level={6} {...props} />,
blockquote: ({ children }) => <div className="highlight-box">{children}</div>,
};

Expand Down