ssssota / svelte-exmarkdown

Svelte component to render markdown.
https://ssssota.github.io/svelte-exmarkdown
MIT License
189 stars 6 forks source link

How to use remark frontmatter with svelte-exmarkdown #27

Closed projectashik closed 1 year ago

projectashik commented 1 year ago

I'm trying to use the remark frontmatter with the svelte-exmarkdown, but it's not working.

ssssota commented 1 year ago

You can use like this:

<script lang="ts">
  import Markdown from 'svelte-exmarkdown';
  import remarkFrontmatter from 'remark-frontmatter';
  const plugins = [
    { remarkPlugin: [remarkFrontmatter, ['yaml']] },
  ];
  let md = `\
---
title: test
---

# Hello`;
</script>

<textarea bind:value={md} />

<Markdown {md} {plugins} />

However, svelte-exmarkdown can't expose frontmatter data. The above example can only be rendered ignoring Frontmatter. If you want to use frontmatter data, you should use another package such as front-matter together.