Skip to content
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

Add cascade and param info to Front Matter and Shortcodes topics #404

Merged
merged 8 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 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,24 @@ 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:

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

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

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.
clayton-cornell marked this conversation as resolved.
Show resolved Hide resolved

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

### Date

`date` describes the initial publish date of the page.
Expand Down
32 changes: 32 additions & 0 deletions docs/sources/write/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,38 @@ In this example, the image's display size is changed to have a maximum width of

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

## Param

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:

```yaml
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 */%}}.
```

## Relref

<!-- vale Grafana.Spelling = YES -->
Expand Down
Loading