Skip to content

Commit

Permalink
extract markdown to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaomiDEV committed May 8, 2024
1 parent 30f9908 commit 0544951
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 12 additions & 0 deletions src/lib/markdown.ts
Original file line number Diff line number Diff line change
@@ -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()
}
14 changes: 2 additions & 12 deletions src/modals/MemberEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
const props = defineProps<{
Expand Down Expand Up @@ -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()
}
</script>

<template>
Expand Down

0 comments on commit 0544951

Please sign in to comment.