Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remarkRehypeOptions and rehypeStringifyOptions to provide options to default Markdown processors #203

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-tomatoes-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@contentlayer/core': patch
---

Add remarkRehypeOptions and rehypeStringifyOptions
4 changes: 2 additions & 2 deletions packages/@contentlayer/core/src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export const markdownToHtml = ({
builder.use(options.remarkPlugins)
}

builder.use(remark2rehype)
builder.use(remark2rehype, options?.remarkRehypeOptions)

if (options?.rehypePlugins) {
builder.use(options.rehypePlugins)
}

// rehype to html
builder.use(rehypeStringify as any)
builder.use(rehypeStringify as any, options?.rehypeStringifyOptions)

const res = yield* $(T.tryPromise(() => builder.process(mdString)))

Expand Down
4 changes: 4 additions & 0 deletions packages/@contentlayer/core/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Thunk } from '@contentlayer/utils'
import type { E, HasClock, HasConsole, OT, S, T } from '@contentlayer/utils/effect'
import type { BundleMDXOptions } from 'mdx-bundler/dist/types'
import type { Options as RehypeStringifyOptions } from 'rehype-stringify'
import type { Options as RemarkRehypeOptions } from 'remark-rehype'
import type { LiteralUnion } from 'type-fest'
import type * as unified from 'unified'

Expand All @@ -25,6 +27,8 @@ export type PluginOptions = {
}

export type MarkdownOptions = {
remarkRehypeOptions?: RemarkRehypeOptions,
rehypeStringifyOptions?: RehypeStringifyOptions,
remarkPlugins?: unified.Pluggable[]
rehypePlugins?: unified.Pluggable[]
}
Expand Down