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:

Copied
JavaScript SDK: 7.107.0

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.

The packages helper is an instance of PackageRegistry and exposes several methods.

Returns the latest version of the given package.

Copied
{{@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):

Copied
{{@inject packages.version("sentry.javascript.browser", "1.0.0") }}

Returns the checksum of a given file in a package.

Copied
{{@inject packages.checksum("sentry.javascript.browser", "bundle.min.js", "sha384") }}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").