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: {{ packages.version('sentry.browser.javascript') }}

In this case, we expose packages as an instance of PackageRegistry 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, Markdown Variables.

When a function call is invalid (or errors), or doesn't match something in the known scope, it will simple render it as a literal value instead. So for example:

Copied
setFingerprint('{{ default }}')

Will render as:

Copied
setFingerprint('{{ default }}')

This is because there is no entity scoped to default in the template renderer. Additionally - in this case - we also add the default expression to the exclusion list in our configuration, as it is commonly use in our documentation.

packages

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

packages.version

Returns the latest version of the given package.

Copied
packages.version("sentry.javacript.browser");

You may also optionally specify a fallback for if the package isn't found (or there's an upstream error):

Copied
packages.version("sentry.javacript.browser", "1.0.0");

packages.checksum

Returns the checksum of a given file in a package.

Copied
packages.checksum("sentry.javacript.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!) to suggesting an update ("yeah, this would be better").