0.1.1 • Published 8 months ago

bun-plugin-markdoc v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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

0.1.1

8 months ago

0.1.0

8 months ago