diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7edb6fd7b..9685451c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1126,6 +1126,28 @@ The following table shows which children types use which frontmatter properties: | `list_code_example` | ✓ | | | | `list_query_example` | ✓ | | | +### Authentication token link + +Use the `{{% token-link "" "%}}` shortcode to +automatically generate links to token management documentation. The shortcode +accepts two _optional_ arguments: + +- **descriptor**: An optional token descriptor +- **link_append**: An optional path to append to the token management link path, + `///admin/tokens/`. + +```md +{{% token-link "database" "resource/" }} + + +[database token](/influxdb3/enterprise/admin/tokens/resource/) +``` + +InfluxDB 3 Enterprise and InfluxDB 3 Core support different kinds of tokens. +The shortcode has a blacklist of token descriptors for each that will prevent +unsupported descriptors from appearing in the rendered output based on the +current product. + ### Inline icons The `icon` shortcode allows you to inject icons in paragraph text. diff --git a/layouts/shortcodes/token-link.md b/layouts/shortcodes/token-link.md new file mode 100644 index 000000000..3737328ae --- /dev/null +++ b/layouts/shortcodes/token-link.md @@ -0,0 +1,23 @@ + +{{- $productPathData := split .Page.RelPermalink "/" -}} +{{- $product := index $productPathData 1 -}} +{{- $version := index $productPathData 2 -}} +{{- $descriptor := .Get 0 | default "" -}} +{{- $linkAppend := .Get 1 | default "" -}} +{{- $link := print "/" $product "/" $version "/admin/tokens/" -}} +{{- $renderedLink := print $link $linkAppend -}} +{{- $hasDescriptor := ne $descriptor "" -}} +{{- $coreDescriptorBlacklist := slice "resource" "database" -}} +{{- $enterpriseDescriptorBlacklist := slice "operator" -}} +{{- .Store.Set "showDescriptor" $hasDescriptor -}} +{{- if (eq $version "core") -}} + {{- if and $hasDescriptor (in $coreDescriptorBlacklist $descriptor) -}} + {{- .Store.Set "showDescriptor" false -}} + {{- end -}} +{{- else if (eq $version "enterprise") -}} + {{- if and $hasDescriptor (in $enterpriseDescriptorBlacklist $descriptor) -}} + {{- .Store.Set "showDescriptor" false -}} + {{- end -}} +{{- end -}} +{{- $showDescriptor := .Store.Get "showDescriptor" -}} +[{{ if $showDescriptor }}{{ $descriptor }} {{ end }}token]({{ $renderedLink }}) \ No newline at end of file