@contentmap/unified
v1.0.1
Published
remark/rehype renderer for contentmap, for the plugin ecosystem.
Readme
@contentmap/unified
A remark/rehype renderer for contentmap, for when you want the plugin ecosystem.
@contentmap/markdown is the lighter default. Reach for this one when you need remark or rehype plugins — footnotes, math, syntax highlighting, custom directives.
Install
npm i @contentmap/unifiedUse
import { defineConfig, defineCollection } from 'contentmap'
import { unifiedRenderer } from '@contentmap/unified'
import rehypeHighlight from 'rehype-highlight'
import { z } from 'zod'
export default defineConfig({
renderer: unifiedRenderer({ rehypePlugins: [rehypeHighlight] }),
collections: {
posts: defineCollection({
directory: 'content/posts',
include: '**/*.md',
schema: z.object({ title: z.string() }),
transform: async (doc, ctx) => ({ ...doc, html: await ctx.markdown() })
})
}
})Defaults
GitHub Flavored Markdown (remark-gfm) and heading slugs (rehype-slug) are on by default. remarkPlugins and rehypePlugins append to those.
Raw HTML
Raw HTML in markdown is not passed through by default, because doing so on untrusted content is an XSS vector. To allow it, install rehype-raw — an optional peer dependency — and set allowDangerousHtml: true:
unifiedRenderer({ allowDangerousHtml: true })Only do this for content you control.
Links
MIT
