feat: show rating
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { unified } from "npm:unified";
|
||||
import remarkParse from "npm:remark-parse";
|
||||
import remarkFrontmatter from "https://esm.sh/remark-frontmatter@4";
|
||||
import remarkRehype from "https://esm.sh/remark-rehype";
|
||||
import rehypeSanitize from "https://esm.sh/rehype-sanitize";
|
||||
import rehypeStringify from "https://esm.sh/rehype-stringify";
|
||||
import { parse } from "https://deno.land/std@0.194.0/yaml/mod.ts";
|
||||
import * as cache from "@lib/cache/documents.ts";
|
||||
|
||||
@@ -53,6 +56,17 @@ export function parseDocument(doc: string) {
|
||||
.parse(doc);
|
||||
}
|
||||
|
||||
export function renderMarkdown(doc: string) {
|
||||
const out = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkRehype)
|
||||
.use(rehypeSanitize)
|
||||
.use(rehypeStringify)
|
||||
.processSync(doc);
|
||||
|
||||
return String(out);
|
||||
}
|
||||
|
||||
export type ParsedDocument = ReturnType<typeof parseDocument>;
|
||||
export type DocumentChild = ParsedDocument["children"][number];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user