Skip to content

Commit

Permalink
Add cascade and param
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton-cornell committed Dec 14, 2023
1 parent 1ea551c commit 5287159
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/sources/write/front-matter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ For example, `https://grafana.com/docs/writers-toolkit/`.

For content reused in Grafana Cloud, prefer the open source documentation as the canonical page.

### Cascade

`cascade` is a map of front matter keys. The values are passed down from the parent to the page descendants.

You can use `cascade` to define variables. For example:

```
cascade:
PRODUCT_VERSION: 10.1
PRODUCT_NAME: Grafana
```

Use the [param](https://grafana.com/docs/writers-toolkit/write/shortcodes#param) shortcode in the topic body text wherever you need to insert the variable.

### Date

`date` describes the initial publish date of the page.
Expand Down
37 changes: 37 additions & 0 deletions docs/sources/write/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,43 @@ In this example, the image's display size is changed to have a maximum width of
{{</* figure src="/static/img/docs/grafana-cloud/k8sPods.png" width="1275" height="738" max-width="500px" class="w-100p" link-class="w-fit mx-auto d-flex flex-direction-column" caption="Pod view in Grafana Kubernetes Monitoring" caption-align="center" */>}}
```


<!-- vale Grafana.Spelling = NO -->

## Param

<!-- vale Grafana.Spelling = YES -->

The `param` shortcode provides build-time variable substitution.

To add a new variable definition:

1. Define a [`cascade` variable](https://grafana.com/docs/writers-toolkit/write/front-matter/#cascade) in the parent topic.
1. Insert the `param` variable where it's required in the parent and child topics.

> **Note:** If you use the `param` shortcode in headings, you must use `%` in place of `<` and `>`. For example: `{{%/* param VARIABLE */%}}`.

### Example

The front matter definition for a product version:

```markdown
cascade:
PRODUCT_VERSION: 10.2
```

The `param` shortcode in the topic body text:

```markdown
Welcome to Grafana {{</* param PRODUCT_VERSION */>}}! Read on to learn about changes to dashboards and visualizations, data sources, security and authentication, and more.
```

The `param` shortcode in a topic heading:

```markdown
## What's new in Grafana {{%/* param PRODUCT_VERSION */%}}.
```

<!-- vale Grafana.Spelling = NO -->

## Relref
Expand Down

0 comments on commit 5287159

Please sign in to comment.