1
0
Fork 0

feat(freesewing.dev): ToC and layout changes

This commit is contained in:
Joost De Cock 2022-05-11 16:29:46 +02:00
parent fbbad22dcc
commit 6c41b1d941
17 changed files with 478 additions and 94 deletions

View file

@ -0,0 +1,30 @@
import {toc} from 'mdast-util-toc'
const headings = {
en: 'Table of contents',
fr: 'Table des matières',
nl: 'Inhoudsopgave',
es: 'Tabla de contenido',
de: 'Inhaltsverzeichnis'
}
export default function mdxToc(options = {}) {
return (node) => {
const result = toc(node, { heading: false })
if (result.map) node.children = [
{
type: 'heading',
depth: 4,
children: [{
type: 'text',
value: headings[options.language || 'en']
}]
},
result.map
]
else node.children = []
return
}
}