-
Notifications
You must be signed in to change notification settings - Fork 67k
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (20 loc) · 767 Bytes
/
index.ts
File metadata and controls
26 lines (20 loc) · 767 Bytes
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
import { fastTextOnly } from '@/content-render/unified/text-only'
import { createProcessor, createMarkdownOnlyProcessor } from '@/content-render/unified/processor'
interface RenderOptions {
textOnly?: boolean
}
export async function renderUnified(template: string, context: any, options: RenderOptions = {}) {
const processor = createProcessor(context)
const vFile = await processor.process(template)
let html = vFile.toString()
if (options.textOnly) {
html = fastTextOnly(html)
}
return html.trim()
}
export async function renderMarkdown(template: string, context: any) {
const processor = createMarkdownOnlyProcessor(context)
const vFile = await processor.process(template)
const markdown = vFile.toString()
return markdown.trim()
}