#Loading scripts from content collections?

1 messages · Page 1 of 1 (latest)

balmy stream
#

I have a bunch of blog posts in Markdown with associated JS files that add interactive examples. Each blog post has its own set of JS files; they're not shared between post. I basically treat those JS files as I would images — they're just supporting content that needs to go alongside the text.

Unlike images, though, I don't see a way to have Astro process those scripts. I could put them in the public folder, but then I can't store them together with the post itself. The solution I arrived at was adding a _Scripts.astro file for each post that just has a script tag that imports all the examples, and then including that component in the MDX file. I'd like to avoid that if possible — for one, when Astro generates my RSS feed it doesn't cut out the extra MDX stuff. Any ideas?

cursive gullBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

patent pilot
balmy stream
#

that only works with string literals, so i couldn't have different scripts per blog post 😕

patent pilot
#

Can’t you do <script src={SCRIPTPATH}></script>?