Skip to content

Commit 46dad24

Browse files
sandersonCopilot
andauthored
Add 'show-in' and 'hide-in' shortcodes (#5946)
* show-hide-shortcodes * updated variable names * added missing else operator * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d7a2754 commit 46dad24

File tree

3 files changed

+79
-152
lines changed

3 files changed

+79
-152
lines changed

CONTRIBUTING.md

Lines changed: 65 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ append: # Append markdown content to an article (especially powerful with cascad
367367
content: # Content to append to article
368368
metadata: [] # List of metadata messages to include under the page h1
369369
updated_in: # Product and version the referenced feature was updated in (displayed as a unique metadata)
370+
source: # Specify a file to pull page content from (typically in /content/shared/)
370371
```
371372

372373
### Title usage
@@ -494,6 +495,15 @@ cascade:
494495
those frontmatter keys. Frontmatter defined on the page overrides frontmatter
495496
"cascaded" from a parent.
496497

498+
## Use shared content in a page
499+
500+
Use the `source` frontmatter to specify a shared file to use to populate the
501+
page content. Shared files are typically stored in the `/content/shared` directory.
502+
503+
When building shared content, use the `show-in` and `hide-in` shortcodes to show
504+
or hide blocks of content based on the current InfluxDB product/version.
505+
For more information, see [show-in](#show-in) and [hide-in](#hide-in).
506+
497507
## Shortcodes
498508

499509
### Notes and warnings
@@ -529,16 +539,6 @@ Display the short version name (part of the key used in `products.yml`) from the
529539
{{% product-key %}}
530540
```
531541

532-
### Enterprise Content
533-
534-
For sections content that relate specifically to InfluxDB Enterprise, use the `{{% enterprise %}}` shortcode.
535-
536-
```md
537-
{{% enterprise %}}
538-
Insert enterprise-specific markdown content here.
539-
{{% /enterprise %}}
540-
```
541-
542542
#### Enterprise name
543543

544544
The name used to refer to InfluxData's enterprise offering is subject to change.
@@ -565,76 +565,6 @@ InfluxDB Enterprise.
565565
Find more info [here][{{< enterprise-link >}}]
566566
```
567567

568-
### InfluxDB Cloud Content
569-
570-
For sections of content that relate specifically to InfluxDB Cloud, use the `{{% cloud %}}` shortcode.
571-
572-
```md
573-
{{% cloud %}}
574-
Insert cloud-specific markdown content here.
575-
{{% /cloud %}}
576-
```
577-
578-
#### InfluxDB Cloud name
579-
580-
The name used to refer to InfluxData's cloud offering is subject to change.
581-
To facilitate easy updates in the future, use the `cloud-name` short-code when
582-
referencing the cloud product.
583-
This shortcode accepts a `"short"` parameter which uses the "short-name".
584-
585-
```
586-
This is content that references {{< cloud-name >}}.
587-
This is content that references {{< cloud-name "short" >}}.
588-
```
589-
590-
Product names are stored in `data/products.yml`.
591-
592-
#### InfluxDB Cloud link
593-
594-
References to InfluxDB Cloud are often accompanied with a link to a page where
595-
visitors can get more information.
596-
This link is subject to change.
597-
Use the `cloud-link` shortcode when including links to more information about
598-
InfluxDB Cloud.
599-
600-
```
601-
Find more info [here][{{< cloud-link >}}]
602-
```
603-
604-
### Latest links
605-
606-
Each of the InfluxData projects have different "latest" versions.
607-
Use the `{{< latest >}}` shortcode to populate link paths with the latest version
608-
for the specified project.
609-
610-
```md
611-
[Link to latest Telegraf](/{{< latest "telegraf" >}}/path/to/doc/)
612-
```
613-
614-
To constrain the latest link to a major version, include a second argument with
615-
the major version:
616-
617-
```md
618-
[Link to latest InfluxDB 1.x](/{{< latest "influxdb" "v1" >}}/path/to/doc/)]
619-
```
620-
621-
`{{< latest "telegraf" >}}` is replaced with `telegraf/v1.15` (or whatever the latest version is).
622-
`{{< latest "influxdb" "v1" >}}` is replaced with `influxdb/v1.8` (or whatever the latest v1.x version is).
623-
624-
Use the following for project names:
625-
626-
- influxdb
627-
- telegraf
628-
- chronograf
629-
- kapacitor
630-
- enterprise_influxdb
631-
632-
**Note**: Include a leading slash before the latest shortcode and a trailing slash after in all link paths:
633-
634-
```md
635-
/{{< latest "telegraf" >}}/
636-
```
637-
638568
### Latest patch version
639569

640570
Use the `{{< latest-patch >}}` shortcode to add the latest patch version of a product.
@@ -1501,7 +1431,53 @@ This is necessary to get the first sentence/paragraph to render correctly.
15011431
{{% /cloud-only %}}
15021432
```
15031433

1504-
#### All-Caps
1434+
### Show or hide content blocks in shared content
1435+
1436+
The `source` frontmatter lets you source page content from another file and is
1437+
used to share content across InfluxDB products. Within the shared content, you
1438+
can use the `show-in` and `hide-in` shortcodes to conditionally show or hide
1439+
content blocks based on the InfluxDB "version." Valid "versions" include:
1440+
1441+
- v2
1442+
- cloud
1443+
- cloud-serverless
1444+
- cloud-dedicated
1445+
- clustered
1446+
- core
1447+
- enterprise
1448+
1449+
#### show-in
1450+
1451+
The `show-in` shortcode accepts a comma-delimited string of InfluxDB "versions"
1452+
to show the content block in. The version is the second level of the page
1453+
path--for example: `/influxdb/<version>/...`.
1454+
1455+
```md
1456+
{{% show-in "core,enterprise" %}}
1457+
1458+
This content will appear in pages in the InfluxDB 3 Core and InfluxDB 3 Enterprise
1459+
documentation, but not any other InfluxDB documentation this content is shared in.
1460+
1461+
{{% /show-in %}}
1462+
```
1463+
1464+
#### hide-in
1465+
1466+
The `hide-in` shortcode accepts a comma-delimited string of InfluxDB "versions"
1467+
to hide the content block in. The version is the second level of the page
1468+
path--for example: `/influxdb/<version>/...`.
1469+
1470+
```md
1471+
{{% hide-in "core,enterprise" %}}
1472+
1473+
This content will not appear in pages in the InfluxDB 3 Core and InfluxDB 3
1474+
Enterprise documentation, but will in all other InfluxDB documentation this
1475+
content is shared in.
1476+
1477+
{{% /hide-in %}}
1478+
```
1479+
1480+
### All-Caps
15051481

15061482
Clockface v3 introduces many buttons with text formatted as all-caps.
15071483
Use the `{{< caps >}}` shortcode to format text to match those buttons.
@@ -1510,7 +1486,7 @@ Use the `{{< caps >}}` shortcode to format text to match those buttons.
15101486
Click {{< caps >}}Add Data{{< /caps >}}
15111487
```
15121488

1513-
#### Code callouts
1489+
### Code callouts
15141490

15151491
Use the `{{< code-callout >}}` shortcode to highlight and emphasize a specific
15161492
piece of code (for example, a variable, placeholder, or value) in a code block.
@@ -1527,7 +1503,7 @@ http://localhost:8086/orgs/03a2bbf46249a000/...
15271503
{{< /code-callout >}}
15281504
````
15291505

1530-
#### InfluxDB University banners
1506+
### InfluxDB University banners
15311507

15321508
Use the `{{< influxdbu >}}` shortcode to add an InfluxDB University banner that
15331509
points to the InfluxDB University site or a specific course.
@@ -1546,15 +1522,15 @@ the content of the banner.
15461522
the course" link="https://university.influxdata.com/" >}}
15471523
```
15481524

1549-
##### Course templates
1525+
#### Course templates
15501526

15511527
Use one of the following course templates:
15521528

15531529
- influxdb-101
15541530
- telegraf-102
15551531
- flux-103
15561532

1557-
##### Custom banner content
1533+
#### Custom banner content
15581534

15591535
Use the following shortcode parameters to customize the content of the InfluxDB
15601536
University banner:
@@ -1650,81 +1626,18 @@ Supported argument values:
16501626

16511627
- oss
16521628
- cloud
1653-
- cloud-tsm
16541629
- cloud-serverless
1655-
- serverless
16561630
- cloud-dedicated
1657-
- dedicated
16581631
- clustered
1632+
- core
1633+
- enterprise
16591634

16601635
```
1661-
{{< host/influxdb >}}
1636+
{{< influxdb/host >}}
16621637

1663-
{{< host/influxdb "serverless" >}}
1638+
{{< influxdb/host "serverless" >}}
16641639
```
16651640

1666-
## New Versions of InfluxDB
1667-
1668-
Version bumps occur regularly in the documentation.
1669-
Each minor version has its own directory with unique content.
1670-
Patch versions within a minor version are updated in place.
1671-
1672-
To add a new minor version, go through the steps below.
1673-
_This example assumes v2.0 is the most recent version and v2.1 is the new version._
1674-
1675-
1. Ensure your `master` branch is up to date:
1676-
1677-
```sh
1678-
git checkout master
1679-
git pull
1680-
```
1681-
1682-
2. Create a new branch for the new minor version:
1683-
1684-
```sh
1685-
git checkout -b influxdb-2.1
1686-
```
1687-
1688-
3. Duplicate the most recent version's content directory:
1689-
1690-
```sh
1691-
# From the root of the project
1692-
cp content/influxdb/v2.0 content/influxdb/v2.1
1693-
```
1694-
1695-
4. Find and replace all instances of the old version number with the new version
1696-
**(only within the new version directory)**.
1697-
Be sure to find and replace both the following forms of the version number:
1698-
1699-
```
1700-
v2.0 -> v2.1
1701-
v2_0 -> v2_1
1702-
```
1703-
1704-
5. Add the new product and version tag taxonomy to the `config.toml` in the root of the project.
1705-
1706-
```toml
1707-
[taxonomies]
1708-
"influxdb/v2.0/tag" = "influxdb/v2.0/tags"
1709-
"influxdb/v2.1/tag" = "influxdb/v2.1/tags"
1710-
```
1711-
1712-
6. Update the `latest_version` in `data/products.yml`:
1713-
1714-
```yaml
1715-
latest_version: v2.1
1716-
```
1717-
1718-
7. Copy the InfluxDB `swagger.yml` specific to the new version into the
1719-
`/api-docs/v<version-number>/` directory.
1720-
1721-
8. Commit the changes and push the new branch to GitHub.
1722-
1723-
These changes lay the foundation for the new version.
1724-
All other changes specific to the new version should be merged into this branch.
1725-
Once the necessary changes are in place and the new version is released,
1726-
merge the new branch into `master`.
1727-
17281641
## InfluxDB API documentation
17291642

17301643
InfluxData uses [Redoc](https://github.com/Redocly/redoc) to generate the full

layouts/shortcodes/hide-in.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- $productPathData := split .Page.RelPermalink "/" -}}
2+
{{- $productVersion := index $productPathData 2 -}}
3+
{{- $defaultHideInString := "v2,cloud,cloud-serverless,cloud-dedicated,clustered,core,enterprise" -}}
4+
{{- $hideInString := .Get 0 | default $defaultHideInString }}
5+
{{- $hideInList := split $hideInString "," -}}
6+
{{- $hide := in $hideInList $productVersion -}}
7+
{{ if $hide }}{{ else }}{{ .Inner }}{{ end }}

layouts/shortcodes/show-in.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- $productPathData := split .Page.RelPermalink "/" -}}
2+
{{- $productVersion := index $productPathData 2 -}}
3+
{{- $defaultShowInString := "v2,cloud,cloud-serverless,cloud-dedicated,clustered,core,enterprise" -}}
4+
{{- $showInString := .Get 0 | default $defaultShowInString }}
5+
{{- $showInList := split $showInString "," -}}
6+
{{- $show := in $showInList $productVersion -}}
7+
{{ if $show }}{{ .Inner }}{{ end }}

0 commit comments

Comments
 (0)