Skip to content

Commit

Permalink
Merge pull request platformsh#3401 from platformsh/version-shortcodes
Browse files Browse the repository at this point in the history
Add versioning shortcodes
  • Loading branch information
gilzow authored Sep 1, 2023
2 parents fd4ff7e + 8ceec2f commit 0270213
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions themes/psh-docs/layouts/shortcodes/version/only.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Markdown passed between shortcode `vendor/inner` will render only if the current version = first passed variable -->
<!-- For example, -->
<!-- vendor/only "1" -->
<!-- platform variable:get -->
<!-- /vendor/only -->
<!-- When the site is built, the `platform` command will appear iff vendor.config.version = 1 in params.yaml -->
{{- $version := .Site.Params.vendor.config.version -}}
{{- if eq $version ( int (.Get 0)) -}}
{{- .Inner | .Page.RenderString -}}
{{- end -}}
18 changes: 18 additions & 0 deletions themes/psh-docs/layouts/shortcodes/version/specific.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Markdown processes 2 versions, rendering only if key matches current version -->
<!-- Key 1: Version 1; the first Inner prior to the dividing character -->
<!-- Key 2: Version 2; the second Inner after the dividing character -->
<!-- For example, -->
<!-- vendor/specific -->
<!-- platform variable:get -->
<!-- (divider: see $splitVersionChar below) -->
<!-- friday variable:get -->
<!-- /vendor/specific -->
{{- $page := .Page -}}
{{- $version := .Site.Params.vendor.config.version -}}
{{- $splitVersionChar := "<--->" -}}
{{- range $k, $v := split .Inner $splitVersionChar -}}
{{- $current := add $k 1 -}}
{{- if eq $current $version -}}
{{- $v | $page.RenderString -}}
{{- end -}}
{{- end -}}

0 comments on commit 0270213

Please sign in to comment.