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
Passing environment variable to the yaml file header #153
Comments
Actually you can do this when running gray-matter in Node using the JS parser: ---js
{
NODE_ENV: process.env.NODE_ENV
}
--- Alternatively you could supply a custom parser engine: import { javascript } from 'gray-matter/lib/engines.js'
const parsed = matter(str, {
engines: {
'embedded-js': (str, options) => {
// naive implementation but you get the gist
return javascript.parse(str.replace(/\$/g, 'process.env.'), options)
}
}
}) Then use it like so: ---embedded-js
{
NODE_ENV: $NODE_ENV
}
--- |
I would like to do something similar, accessing environment variables on astro docs front matter.
Is this somehow possible using gray-matter? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I would like to pass environment variables to the yaml file header. I tried the following:
None of them worked. Would it be something possible to do?
Thanks!
The text was updated successfully, but these errors were encountered: