Svelte in markdown
This feature allows you to write <style>
, <script>
, <script module>
, #if
, #each
, #await
, #snippet
, @render
@html
, @const
, <svelte:xxx>
' in .md files
Basic
Here's a basic example with #if
, #each
, #await
, @html
, @const
- 1: foo
- 2: bar
- 3: zoo
Fail
Loading
Content render with @html
Syntax Restrictions
Always use quotes in markdown files.
-
+
<script>
let count = $state(0)
</script>
<button onclick={() => count++}></button>
<button onclick="{() => count++}"></button>
md
Or you can wrap it with a div
-
+
+
+
<script>
let count = $state(0)
</script>
<button onclick={() => count++}></button>
<div>
<button onclick={() => count++}></button>
</div>
md
A Counter
A counter
Import svelte in md
On this page