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

View File

@ -4,6 +4,7 @@ import {
getTextOfRange,
parseDocument,
parseFrontmatter,
renderMarkdown,
} from "@lib/documents.ts";
import { parseIngredient } from "npm:parse-ingredient";
@ -163,8 +164,8 @@ export function parseRecipe(original: string, id: string): Recipe {
id,
meta,
name,
description,
description: description ? renderMarkdown(description) : "",
ingredients,
preparation,
preparation: preparation ? renderMarkdown(preparation) : "",
};
}