Move markdown to molecules

main
trivernis 5 months ago
parent 7a254da0ae
commit 20edd1b562
Signed by: Trivernis
GPG Key ID: 7E6D18B61C8D2F4B

@ -1,13 +0,0 @@
<script lang="ts">
import { marked } from "marked";
type Props = {
markdown: string;
};
const { markdown }: Props = $props();
const markdownHtml = marked(markdown);
</script>
{@html markdownHtml}

@ -1,20 +1,22 @@
<script lang="ts"> <script lang="ts">
import type { Snippet } from "svelte"; import { marked } from "marked";
type Props = { type Props = {
children: Snippet; markdown: string;
}; };
const { children }: Props = $props(); const { markdown }: Props = $props();
const markdownHtml = marked(markdown);
</script> </script>
<div class="paragraph"> <div class="markdown">
{@render children()} {@html markdownHtml}
</div> </div>
<style lang="scss"> <style lang="scss">
@layer component { @layer component {
.paragraph { .markdown {
font-family: var(--font-readable); font-family: var(--font-readable);
hyphens: auto; hyphens: auto;
text-align: justify; text-align: justify;

@ -2,8 +2,7 @@
import type { BlogPostContentEntry } from "$lib/cms/blog"; import type { BlogPostContentEntry } from "$lib/cms/blog";
import "$lib/vars.scss"; import "$lib/vars.scss";
import Box from "../atoms/Box.svelte"; import Box from "../atoms/Box.svelte";
import Markdown from "../atoms/Markdown.svelte"; import Markdown from "../molecules/Markdown.svelte";
import Paragraph from "../atoms/Paragraph.svelte";
import Image from "../molecules/Image.svelte"; import Image from "../molecules/Image.svelte";
type Props = { type Props = {
@ -17,15 +16,11 @@
{#if content.__component === "content.text-markdown"} {#if content.__component === "content.text-markdown"}
{#if content.type === "paragraph"} {#if content.type === "paragraph"}
<Box> <Box>
<Paragraph> <Markdown markdown={content.value} />
<Markdown markdown={content.value} />
</Paragraph>
</Box> </Box>
{:else if content.type === "infobox"} {:else if content.type === "infobox"}
<Box color="cyan" title="Info"> <Box color="cyan" title="Info">
<Paragraph> <Markdown markdown={content.value} />
<Markdown markdown={content.value} />
</Paragraph>
</Box> </Box>
{/if} {/if}
{:else if content.__component === "content.image"} {:else if content.__component === "content.image"}

Loading…
Cancel
Save