astro icon indicating copy to clipboard operation
astro copied to clipboard

Code blocks in MDX render environmental variables

Open ymcheung opened this issue 2 years ago • 0 comments

What version of astro are you using?

1.1.1

Are you using an SSR adapter? If so, which one?

Deno Deploy

What package manager are you using?

pnpm

What operating system are you using?

macOS 12

Describe the Bug

I have some import.meta.env in MDX's code blocks and don't want them to be converted. (Just display import.meta.env.XXXXX)

In dev environment, the output is doing well.

However, import.meta.env.SITE becomes undefined (or the url I defined in astro.config.mjs); import.meta.env.PUBLIC_HOSTNAME becomes (Object.assign(import.meta.env,{HOSTNAME:process.env.HOSTNAME,})).PUBLIC_HOSTNAME in production.

Link to Minimal Reproducible Example

https://codesandbox.io/s/vibrant-chandrasekhar-gbicwd?file=/src/pages/article1.mdx

Participation

  • [ ] I am willing to submit a pull request for this issue.

ymcheung avatar Sep 19 '22 12:09 ymcheung