Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Build time grows with every render #33 #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/astro-remote/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { transform, __unsafeHTML } from "ultrahtml";
import sanitize from "ultrahtml/transformers/sanitize";
import swap from "ultrahtml/transformers/swap";

import { type MarkedExtension, marked } from "marked";
import { type MarkedExtension, Marked } from "marked";
import markedFootnote from "marked-footnote";
import { markedSmartypants } from "marked-smartypants";

Expand Down Expand Up @@ -109,11 +109,11 @@ export async function markdown(
};
}
}
marked.use(markedSmartypants(), markedFootnote(), ...markedExtenstion, {
const instance = new Marked(markedSmartypants(), markedFootnote(), ...markedExtenstion, {
gfm: true,
renderer,
});
const content = await marked.parse(dedent(input));
const content = await instance.parse(dedent(input));
return transform(content, [
swap(opts.components),
sanitize(opts.sanitize),
Expand Down
1 change: 1 addition & 0 deletions packages/playground/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<li><a href="/test-md-local">Test Local Markdown "< Markdown >"</a></li>
<li><a href="/test-issue7">Test Issue #7</a></li>
<li><a href="/test-issue27">Test Issue #27</a></li>
<li><a href="/test-issue33">Test Issue #33</a></li>
</ul>
<h2>Remote:</h2>
<ul>
Expand Down
22 changes: 22 additions & 0 deletions packages/playground/src/pages/test-issue33.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
import { Markdown } from "astro-remote";

const elements = Array.from(Array(100).keys())
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Test for <a href="https://github.com/natemoo-re/astro-remote/issues/33" target="_blank">Issue #33</a></h1>

<ul>
{elements.map(element => <li><Markdown content={`**Element number ${element}** --> check build time`} /></li>)}
</ul>
</body>
</html>