From 0544951e3dedea076bf6de354e107f548b7e0f6d Mon Sep 17 00:00:00 2001 From: Naomi Calabretta Date: Wed, 8 May 2024 18:16:32 +0200 Subject: [PATCH] extract markdown to its own file --- src/lib/markdown.ts | 12 ++++++++++++ src/modals/MemberEdit.vue | 14 ++------------ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/lib/markdown.ts diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts new file mode 100644 index 0000000..f7a67c4 --- /dev/null +++ b/src/lib/markdown.ts @@ -0,0 +1,12 @@ +import rehypeStringify from 'rehype-stringify'; +import remarkParse from 'remark-parse'; +import remarkRehype from 'remark-rehype'; +import { unified } from 'unified'; + +export function getMarkdownFor(text: string) { + return unified() + .use(remarkParse) + .use(remarkRehype) + .use(rehypeStringify) + .processSync(text).toString() +} \ No newline at end of file diff --git a/src/modals/MemberEdit.vue b/src/modals/MemberEdit.vue index 9460f44..fbca0e1 100644 --- a/src/modals/MemberEdit.vue +++ b/src/modals/MemberEdit.vue @@ -32,10 +32,8 @@ import { getFiles } from "../lib/util/misc"; import { resizeImage } from "../lib/util/image"; import { Ref, inject, ref } from "vue"; - import rehypeStringify from 'rehype-stringify'; - import remarkParse from 'remark-parse'; - import remarkRehype from 'remark-rehype'; - import { unified } from 'unified'; + import { getMarkdownFor } from "../lib/markdown"; + type PartialBy = Omit & Partial>; const props = defineProps<{ @@ -82,14 +80,6 @@ member.value.image = await resizeImage(files[0]); } } - - function getMarkdownFor(text: string){ - return unified() - .use(remarkParse) - .use(remarkRehype) - .use(rehypeStringify) - .processSync(text).toString() - }