feat(freesewing.dev): ToC and layout changes
This commit is contained in:
parent
fbbad22dcc
commit
6c41b1d941
17 changed files with 478 additions and 94 deletions
30
packages/freesewing.shared/mdx/mdx-plugin-toc.mjs
Normal file
30
packages/freesewing.shared/mdx/mdx-plugin-toc.mjs
Normal 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue