generated from jackyzha0/quartz
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.ts
More file actions
37 lines (35 loc) · 1.02 KB
/
worker.ts
File metadata and controls
37 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sourceMapSupport from "source-map-support"
sourceMapSupport.install(options)
import cfg from "../quartz.config"
import { BuildCtx, WorkerSerializableBuildCtx } from "./util/ctx"
import { FilePath } from "./util/path"
import {
createFileParser,
createHtmlProcessor,
createMarkdownParser,
createMdProcessor,
} from "./processors/parse"
import { options } from "./util/sourcemap"
import { MarkdownContent, ProcessedContent } from "./plugins/vfile"
// only called from worker thread
export async function parseMarkdown(
partialCtx: WorkerSerializableBuildCtx,
fps: FilePath[],
): Promise<MarkdownContent[]> {
const ctx: BuildCtx = {
...partialCtx,
cfg,
}
return await createFileParser(ctx, fps)(createMdProcessor(ctx))
}
// only called from worker thread
export function processHtml(
partialCtx: WorkerSerializableBuildCtx,
mds: MarkdownContent[],
): Promise<ProcessedContent[]> {
const ctx: BuildCtx = {
...partialCtx,
cfg,
}
return createMarkdownParser(ctx, mds)(createHtmlProcessor(ctx))
}