feat: show rating

This commit is contained in:
2023-07-30 19:40:39 +02:00
parent c7279105ca
commit 0632ae05c1
12 changed files with 172 additions and 88 deletions

View File

@@ -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];