Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit c2554b8

Browse files
committed
fix(docz-core): apply mdast plugins to entries parse too
1 parent 3e453f5 commit c2554b8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/docz-core/src/lib/Entries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class Entries {
7676
}
7777

7878
private async getMap(config: Config): Promise<EntryMap> {
79-
const { src, files: pattern, ignore, plugins } = config
79+
const { src, files: pattern, ignore, plugins, mdPlugins } = config
8080
const arr = Array.isArray(pattern) ? pattern : [pattern]
8181
const toMatch = matchFilesWithSrc(config)
8282

@@ -90,7 +90,7 @@ export class Entries {
9090

9191
const createEntry = async (file: string) => {
9292
try {
93-
const ast = await parseMdx(file)
93+
const ast = await parseMdx(file, mdPlugins)
9494
const entry = new Entry(ast, file, src, config)
9595

9696
if (this.repoEditUrl) entry.setLink(this.repoEditUrl)

core/docz-utils/src/mdast.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ import humanize from 'humanize-string'
1111
import flatten from 'lodash.flatten'
1212
import get from 'lodash.get'
1313

14-
export const parseMdx = (file: string): Promise<string> => {
14+
export const parseMdx = (file: string, plugins: any[]): Promise<string> => {
1515
const raw = vfile.readSync(file, 'utf-8')
1616
const parser = unified()
1717
.use(remark, { type: 'yaml', marker: '-' })
1818
.use(matter)
1919
.use(parseFrontmatter)
2020
.use(slug)
2121

22+
for (const plugin of plugins) {
23+
const [item, opts = {}] = Array.isArray(plugin) ? plugin : [plugin]
24+
parser.use(item, opts)
25+
}
26+
2227
return parser.run(parser.parse(raw))
2328
}
2429

0 commit comments

Comments
 (0)