Markdown Variables
A transformation is exposed to both Markdown and MDX files which supports processing variables in a Django/Jekyll-style way. The variables available are globally scoped and configured within gatsby-config.js
(via gatsby-remark-variables
).
For example:
JavaScript SDK: 7.74.1
In this case, we expose packages
as an accessor in the package registry which is why there is a packages.version
function available. Additional, we expose a default context variable of page
which contains the frontmatter of the given markdown node. For example, {{@inject page.title }}
.
When a variable call is invalid (or errors), or doesn't match something in the known scope, it will produce an error. If you need to escape an expression you can add a leading \
to the @inject
.
packages
The packages
helper is an instance of PackageRegistry
and exposes several methods.
packages.version
Returns the latest version of the given package.
{{@inject packages.version("sentry.javascript.browser") }}
You may also optionally specify a fallback for if the package isn't found (or there's an upstream error):
{{@inject packages.version("sentry.javascript.browser", "1.0.0") }}
packages.checksum
Returns the checksum of a given file in a package.
{{@inject packages.checksum("sentry.javascript.browser", "bundle.min.js", "sha384") }}
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").