natemoo-re / astro-remote

Render remote HTML or Markdown content in Astro with full control over the output
MIT License
177 stars 9 forks source link

fix: `he` breaks vite, replace with `entities` #9

Closed JulianCataldo closed 1 year ago

JulianCataldo commented 1 year ago

When using CodeBlock / CodeSpan.

Stack trace:

TypeError: __vite_ssr_import_5__.encode is not a function
Please report this to https://github.com/markedjs/marked.
    at renderer.code (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/lib/utils.ts:76:60)
    at renderer.<computed> [as code] (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/node_modules/marked/lib/marked.esm.js:2751:41)
    at Parser.parse (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/node_modules/marked/lib/marked.esm.js:2277:32)
    at parse (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/node_modules/marked/lib/marked.esm.js:2211:19)
    at eval (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/node_modules/marked/lib/marked.esm.js:2644:18)
    at Function.marked [as parse] (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/node_modules/marked/lib/marked.esm.js:2659:48)
    at Module.markdown (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/lib/utils.ts:92:54)
    at eval (/.../web-garden/themes/simple-docs/node_modules/.pnpm/astro-remote@0.2.3/node_modules/astro-remote/lib/Markdown.astro:17:47)
    at AstroComponentInstance.Markdown [as factory] (/.../astro-openapi/node_modules/.pnpm/astro@2.1.9/node_modules/astro/dist/runtime/server/astro-component.js:22:12)
    at AstroComponentInstance.init (/.../astro-openapi/node_modules/.pnpm/astro@2.1.9/node_modules/astro/dist/runtime/server/render/astro/instance.js:28:29)

entities is typed, and more updated / speedy.

Need more tests though.

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 7fe62d9230f62ca0597bc43663325e32e5a48f4c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------ | ----- | | astro-remote | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

jasikpark commented 1 year ago

https://www.npmjs.com/package/entities

JulianCataldo commented 1 year ago

Can confirm it works well with this fix in the wild, w. astro@2.1.9:

https://astro-openapi.juliancataldo.com/learn/usage/client

(whole website uses astro-remote for sourcing MD)

Screenshot 2023-04-12 at 16 08 34