Skip to content

Transform headings with ids to localised ones but with the same id

Notifications You must be signed in to change notification settings

semoal/mdx-localized-headings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MDX/MD Localized Headings Transformation

CI

Inspiration

The inspiration to create this tool is basically that Docusaurus V2, introduces some heading id's to headers.

You can write an id for a heading, in that way it can be localized but the id will keep the same:

## Heading-1 {#heading-1}

They offered a tool to create these ids but what happens when you already have your documentation headings translated? Basically it creates the id based on the translated document, and not in the original.

This tool can pick an original markdown.mdx|md, save their headings ids and add them to the translated ones.

Usage

You can run it through a CLI:

npx mdx-localized-headings ./docs/base.mdx ./docs/translated.mdx

or run it through Node:

npm install mdx-localized-headings
# or use yarn
yarn add --dev mdx-localized-headings
import { transform } from "mdx-localized-headings"

await transform(path1, path2)

Contributing

Tests are implemented with uvu, and we use yarn as package manager:

yarn
yarn test