0.0.2 • Published 2 years ago

mdit-plg-double-bracket-link v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mdit-plg-double-bracket-link

NPM version

Parse [[path/to/page]] into html in markdown-it!

Inspired by the combination usage between vite and Obsidian.

Twin plugin: mdit-plg-double-bracket-media

Probably for my personal blog...

Usage

pnpm i mdit-plg-double-bracket-link -D
// use this plugin in markdown-it
import DoubleBracketLink from 'mdit-plg-double-bracket-link'

md.use(DoubleBracketLink, {
  /**
   * (Optional) remove the prefix in the double brackets.
   * It will parse ![[pages/path/to/file|target link]] into
   * <a href="/path/to/file">target link</a>
   */
  removePrefix: 'pages/',
  /**
   * (Optional) after removing the provided prefix,
   * param `addPrefix` will be added to the front of url.
   *
   * For example, if the params are `{ removePrefix: 'pages/', addPrefix: 'src/' }`,
   * then it will parse ![[pages/path/to/file|target link]] into
   * <a href="/src/path/to/file">target link</a>
   */
  addPrefix: '',

  /**
   * (Optional) Add suffix to uri
   */
  uriSuffix: '.html'
})

License

MIT License © 2022 widcardw