bun-plugin-markdoc
v0.1.1
Published
[Markdoc](https://markdoc.io/) plugin for Bun.
Downloads
4
Readme
bun-plugin-markdoc
Markdoc plugin for Bun.
Installation
bun add @markdoc/markdoc bun-plugin-markdoc
Bundler usage
import markdoc from 'bun-plugin-markdoc'
Bun.build({
// other config
plugins: [
markdoc()
],
})
In your sources you can now import markdown files:
---
title: What is Markdoc?
---
# {% $markdoc.frontmatter.title %} {% #overview %}
Markdoc is a Markdown-based syntax and toolchain for creating custom documentation sites. Stripe created Markdoc to power [our public docs](http://stripe.com/docs).
{% callout type="check" %}
Markdoc is open-source—check out its [source](http://github.com/markdoc/markdoc) to see how it works.
{% /callout %}
import overview from './overview.md'
console.log(overview) // Tree node
or import as html string:
import overview from './overview.md?html'
console.log(overview) // html string
The contents of the imported markdown file will be inlined into your bundle.
Runtime usage
To use as a runtime plugin, create a file that registers the plugin:
// markdoc.ts
import markdoc from 'bun-plugin-markdoc'
Bun.plugin(markdoc({}));
Then preload it in your bunfig.toml
:
preload = ['./markdoc.ts']
Configuration
The plugin accepts an optional Markdoc.transform config:
import markdoc from 'bun-plugin-markdoc'
Bun.plugin(markdoc({
nodes: {},
tags: {},
}))
License
MIT