How to pass variable from frontmatter to script in Astro js. Like this:
---
const title = "this is title"
---
some content
<script>
const metatile = title
<script>
How to pass variable from frontmatter to script in Astro js. Like this:
---
const title = "this is title"
---
some content
<script>
const metatile = title
<script>
2
Answers
You can use the
define:vars
directive to pass the value to the client bundle.maybe like this: