portfolio/mdx-components.tsx
r-freeman 1715e0c275
Some checks failed
Build And Publish / BuildAndPublish (push) Failing after 1m50s
Add anchor links to headings
2024-09-18 17:36:21 +01:00

17 lines
720 B
TypeScript

import type {MDXComponents} from 'mdx/types'
import {createSlug} from './lib/createSlug'
// This file allows you to provide custom React components
// to be used in MDX files. You can import and use any
// React component you want, including components from
// other libraries.
// This file is required to use MDX in `app` directory.
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
h2: ({children}) => <h2>{children}<a className='ml-1' href={`#${createSlug(children)}`}>#</a></h2>,
// Allows customizing built-in components, e.g. to add styling.
// h1: ({ children }) => <h1 style={{ fontSize: "100px" }}>{children}</h1>,
...components,
}
}