svelte-preprocess-markdown icon indicating copy to clipboard operation
svelte-preprocess-markdown copied to clipboard

Import and Frontmatter?

Open ryanfiller opened this issue 4 years ago • 1 comments

Apologies if I'm just missing something in the docs, I cannot seem to get this to work.

I have a post that contains frontmtter that I also would like to use a component in. Doing this gets the following error: SyntaxError: import declarations may only appear at top level of a module

---
title: Markdown Post Processing (MDX-ish)
date: 2020-05-04
---
<script>
  import Button from './button.svelte'
</script>

And doing this will render the frontmatter to the page with two <hr/>s

<script>
  import Button from './button.svelte'
</script>
---
title: Markdown Post Processing (MDX-ish)
date: 2020-05-04
---

Is it possible to do both?

ryanfiller avatar May 24 '20 23:05 ryanfiller

Just tested with the default svelte template+svelte-preprocess-markdown. Your first example works great. See this example in attachment. testmd.zip

AlexxNB avatar May 26 '20 18:05 AlexxNB