mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-24 22:15:41 +00:00
Add anchor links to headings
Some checks failed
Build And Publish / BuildAndPublish (push) Failing after 1m50s
Some checks failed
Build And Publish / BuildAndPublish (push) Failing after 1m50s
This commit is contained in:
parent
0d29696705
commit
1715e0c275
@ -1,3 +1,5 @@
|
||||
export function createSlug(title: string) {
|
||||
return title.toLowerCase().replace(/[.,\s]+/g, '-')
|
||||
return title.toLowerCase()
|
||||
.replace(/\?/g, '')
|
||||
.replace(/[.,\s]+/g, '-')
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import type { MDXComponents } from 'mdx/types'
|
||||
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
|
||||
@ -8,6 +9,7 @@ import type { MDXComponents } from 'mdx/types'
|
||||
// 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,
|
||||
|
Loading…
Reference in New Issue
Block a user