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

### 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" */>}}
```


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

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have exclamations in examples since they are discouraged by the style guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this direct from the published docs :-) I'll remove it here.

```

The `param` shortcode in a topic heading:

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

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

## Relref
Expand Down
Loading