Skip to content

Commit

Permalink
Frontmatter containing $1 is correctly substituted
Browse files Browse the repository at this point in the history
Without this change, the script itself would be inserted into the metadata string

Before:
```svelte
<script·context="module">
export const metadata = {"price":"<script·context="module">0"};
const {·price·} = metadata;
</script>
```

After:
<script context="module">
export const metadata = {"price":"$10"};
const { price } = metadata;
</script>
  • Loading branch information
pensono authored and pngwn committed Jun 4, 2024
1 parent d7b3164 commit a6fc18e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mdsvex/src/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export function transform_hast({
// @ts-ignore
_module[0].value = _module[0].value.replace(
RE_MODULE_SCRIPT,
`$1${newline}\t${fm}`
(match: string) => `${match}${newline}\t${fm}`
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
price: '$10'
---
<script context="module">
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script context="module">
export const metadata = {"price":"$10"};
const { price } = metadata;
</script>

0 comments on commit a6fc18e

Please sign in to comment.