mirror of https://github.com/istio/istio.io.git
Improve boilerplates so they can now contain shortcodes (#3019)
This commit is contained in:
parent
95c5e619e7
commit
1ca2020e42
|
|
@ -540,6 +540,7 @@ Keycloak
|
|||
OpenID
|
||||
Istioctl
|
||||
Boilerplates
|
||||
boilerplates
|
||||
|
||||
- search.md
|
||||
searchresults
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
This is some boilerplate *markdown* _text_.
|
||||
|
||||
|
|
@ -450,8 +450,8 @@ which results in:
|
|||
|
||||
{{< boilerplate example >}}
|
||||
|
||||
You supply the name of a boilerplate file to insert at the current location. Boilerplates are
|
||||
located in language-specific subdirectories of the `boilerplates` directory. Boilerplates are just
|
||||
You supply the name of a boilerplate file to insert at the current location. Available boilerplates are
|
||||
located in the `boilerplates` directory. Boilerplates are just
|
||||
normal markdown files.
|
||||
|
||||
## Using tabs
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
This is some boilerplate *markdown* _text_.
|
||||
|
||||
{{< text plain >}}
|
||||
A sample nested text block.
|
||||
{{< /text >}}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
headless: true
|
||||
---
|
||||
|
|
@ -1,4 +1,26 @@
|
|||
{{- /* Inserts a boilerplate markdown file into the document. See https://preliminary.istio.io/about/contribute/writing-a-new-topic/#embedding-boilerplate-text for details */ -}}
|
||||
{{- $path := printf "boilerplates/%s/%s.md" .Site.Language.Lang (.Get 0) -}}
|
||||
{{- $markdown := readFile $path -}}
|
||||
{{- markdownify $markdown }}
|
||||
{{/* This will try to find a resource in the "boilerplates" top-level content directory */}}
|
||||
{{- $name := .Get 0 -}}
|
||||
{{- $position := .Position }}
|
||||
{{- if $name -}}
|
||||
{{- $bundle := $.Site.GetPage "page" "boilerplates" -}}
|
||||
{{- with $bundle -}}
|
||||
{{- $pattern := printf "%s*" $name -}}
|
||||
{{- $resource := $bundle.Resources.GetMatch $pattern -}}
|
||||
{{- with $resource -}}
|
||||
{{- .Content | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{/* It is not a resource in the top-level boilerplates directory. Try to find the page relative to the current page instead. */}}
|
||||
{{- $path := path.Join $.Page.Dir $name -}}
|
||||
{{- $page := $.Page.Site.GetPage "page" $path -}}
|
||||
{{- with $page }}
|
||||
{{ .Content }}
|
||||
{{- else -}}
|
||||
{{ errorf "Could not find %s (%s)." $pattern $position }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{ errorf "'boilerplates' direcory was not found (%s)" $position }}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- errorf "Missing name in boilerplate (%s)" $position -}}
|
||||
{{- end -}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue