0.1.1 • Published 2 years ago
bun-plugin-markdoc v0.1.1
bun-plugin-markdoc
Markdoc plugin for Bun.
Installation
bun add @markdoc/markdoc bun-plugin-markdocBundler 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 nodeor import as html string:
import overview from './overview.md?html'
console.log(overview) // html stringThe 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