diff --git a/layouts/partials/shortcodes/attachments.html b/layouts/partials/shortcodes/attachments.html new file mode 100644 index 0000000000..8ad62c5e17 --- /dev/null +++ b/layouts/partials/shortcodes/attachments.html @@ -0,0 +1,50 @@ +{{- $context := .context }} +{{- $content := .content }} +{{- $style := .style | default "transparent" }} +{{- $title := .title | default ($style | T) | default ("Attachments-label" | T) }} +{{- $icon := .icon | default "" }} +{{- if and (not $icon) (eq (len $icon) 0) }} + {{- $icon = "paperclip" }} + {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} + {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} + {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} + {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} +{{- end }} +{{- $icon = trim $icon " " }} +{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} +{{- end }} +{{- $sort := .sort | default "asc" }} +{{- $pattern := .pattern | default "" }} +{{- with $context }} +
+
{{ if $icon }} {{ end }}{{ $title }}
+ + {{- $content }} +
+{{- end }} diff --git a/layouts/partials/shortcodes/button.html b/layouts/partials/shortcodes/button.html new file mode 100644 index 0000000000..7ac4f646eb --- /dev/null +++ b/layouts/partials/shortcodes/button.html @@ -0,0 +1,30 @@ +{{- $context := .context }} +{{- $content := .content }} +{{- $href := .href }} +{{- $style := .style | default "transparent" }} +{{- $title := .title | default ($content) | default ($style | T) }} +{{- $icon := .icon | default "" }} +{{- if and (not $icon) (eq (len $icon) 0) }} + {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} + {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} + {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} + {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} +{{- end }} +{{- $icon = trim $icon " " }} +{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} +{{- end }} +{{- $iconposition := .iconposition | default "left" }} +{{- with $context }} + + + {{- if and $icon (eq $iconposition "left") }} + + {{- end }} + {{ $title }} + {{- if and $icon (eq $iconposition "right") }} + + {{- end }} + + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/children.html b/layouts/partials/shortcodes/children.html new file mode 100644 index 0000000000..2592b3ffdf --- /dev/null +++ b/layouts/partials/shortcodes/children.html @@ -0,0 +1,107 @@ +{{- $context := .context }} +{{- $showhidden := .showhidden | default false }} +{{- if eq (printf "%T" $showhidden) "string" }} + {{- $showhidden = (eq $showhidden "true") }} +{{- end }} +{{- $style := .style | default "li" }} +{{- $depth := .depth | default 1 }} +{{- $withDescription := .description | default false }} +{{- if eq (printf "%T" $withDescription) "string" }} + {{- $withDescription = (eq $withDescription "true") }} +{{- end }} +{{- $sortTerm := .sort | lower }} +{{- $containerstyle := .containerstyle | default "ul" }} +{{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }} + {{- $containerstyle = "div" }} +{{- end }} + +{{- with $context }} +{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }} + {{- $pages := .Page.Pages }} + {{- if .Page.IsHome }} + {{- $pages = .Page.Sections }} + {{- else if .Page.Sections}} + {{- $pages = (.Page.Pages | union .Page.Sections) }} + {{- end }} + + {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} + {{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }} + {{- if eq $currentOrdersectionsby "weight" }} + {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }} + {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- else if eq $currentOrdersectionsby "publishdate" }} + {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- else if eq $currentOrdersectionsby "date" }} + {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- else if eq $currentOrdersectionsby "length" }} + {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- else }} + {{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} + {{- end }} +{{ (printf "" $containerstyle)|safeHTML }} +{{- end }} + +{{- define "childs" }} + {{- range .menu }} + {{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} + {{- if not $hidden }} + {{- if not .IsHome }} + {{- if hasPrefix $.style "h" }} + {{- $num := sub ( int (trim $.style "h") ) 1 }} + {{- $numn := add $num $.count }} + +{{ (printf "" $numn)|safeHTML -}} +{{ .Title }} +{{- (printf "" $numn)|safeHTML }} + + {{- else }} +{{ (printf "<%s>" $.style)|safeHTML -}} +{{ .Title }} +{{- (printf "" $.style)|safeHTML }} + {{- end }} + + {{- if $.description }} + {{- if .Description }} +

{{ .Description }}

+ {{else}} +

{{ .Summary }}

+ {{- end }} + {{- end }} + {{- end }} + {{- if lt $.count $.depth }} + + {{- if eq $.style "li" }} +{{- (printf "<%s>" $.containerstyle)|safeHTML }} + {{- end }} + + {{- $pages := .Page.Pages }} + {{- if .Page.IsHome }} + {{- $pages = .Page.Sections }} + {{- else if .Page.Sections}} + {{- $pages = (.Page.Pages | union .Page.Sections) }} + {{- end }} + + {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} + {{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }} + {{- if eq $currentOrdersectionsby "weight" }} + {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }} + {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- else if eq $.currentOrdersectionsby "publishdate" }} + {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- else if eq $.currentOrdersectionsby "date" }} + {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- else if eq $.currentOrdersectionsby "length" }} + {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- else }} + {{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} + {{- end }} + + {{- if eq $.style "li" }} +{{- (printf "" $.containerstyle)|safeHTML }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/expand.html b/layouts/partials/shortcodes/expand.html new file mode 100644 index 0000000000..ae817791f1 --- /dev/null +++ b/layouts/partials/shortcodes/expand.html @@ -0,0 +1,24 @@ +{{- $context := .context }} +{{- $content := .content }} +{{- $title := .title | default (T "Expand-title") }} +{{- $expanded := .open | default false }} +{{- if eq (printf "%T" $expanded) "string" }} + {{- $expanded = (eq $expanded "true") }} +{{- end }} +{{- with $context }} +
+ {{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}} + + + + {{ $title }} + +
+{{ $content | safeHTML }} +
+
+{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/include.html b/layouts/partials/shortcodes/include.html new file mode 100644 index 0000000000..11c78ca9ce --- /dev/null +++ b/layouts/partials/shortcodes/include.html @@ -0,0 +1,13 @@ +{{- $context := .context }} +{{- $file := .file }} +{{- $showFirstHeading := .showfirstheading | default true }} +{{- if eq (printf "%T" $showFirstHeading) "string" }} + {{- $showFirstHeading = (eq $showFirstHeading "true") }} +{{- end }} +{{- if not $showFirstHeading }}
{{ end }} +{{- with $context }} + +{{ $file | readFile | safeHTML }} + +{{- if not $showFirstHeading }}
{{ end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/mermaid.html b/layouts/partials/shortcodes/mermaid.html new file mode 100644 index 0000000000..cef7f3d9a7 --- /dev/null +++ b/layouts/partials/shortcodes/mermaid.html @@ -0,0 +1,9 @@ +{{- $context := .context }} +{{- $content := .content }} +{{- $align := .align | default "center" }} +{{- with $context }} +
+ {{- safeHTML $content -}} +
+{{- .Page.Store.Set "htmlHasMermaid" true }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/notice.html b/layouts/partials/shortcodes/notice.html new file mode 100644 index 0000000000..4ddc716df3 --- /dev/null +++ b/layouts/partials/shortcodes/notice.html @@ -0,0 +1,22 @@ +{{- $context := .context }} +{{- $content := .content }} +{{- $style := .style | default "default" }} +{{- $title := .title | default ($style | T) }} +{{- $icon := .icon | default "" }} +{{- if and (not $icon) (eq (len $icon) 0) }} + {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} + {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} + {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} + {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} +{{- end }} +{{- $icon = trim $icon " " }} +{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} +{{- end }} +{{- with $context }} +
+
{{ if $icon }} {{ end }}{{ $title }}
+
+{{ $content | safeHTML }}
+
+{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/siteparam.html b/layouts/partials/shortcodes/siteparam.html new file mode 100644 index 0000000000..edfa288ed8 --- /dev/null +++ b/layouts/partials/shortcodes/siteparam.html @@ -0,0 +1,10 @@ +{{- $context := .context }} +{{- $paramName := .name }} +{{- with $context }} +{{- $siteParams := .Site.Params }} +{{- with $paramName }} + {{- with $siteParams }} + {{- index . (lower $paramName) }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/swagger.html b/layouts/partials/shortcodes/swagger.html new file mode 100644 index 0000000000..c135499935 --- /dev/null +++ b/layouts/partials/shortcodes/swagger.html @@ -0,0 +1,28 @@ +{{- $context := .context }} +{{- $src := .src }} +{{- with $context }} +{{- with .Page.Resources.Match $src }} + {{- range . }} + {{- $src = .RelPermalink }} + {{- end }} +{{- end }} + + +{{- .Page.Store.Set "htmlHasSwagger" true }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/tabs.html b/layouts/partials/shortcodes/tabs.html new file mode 100644 index 0000000000..c13c9c969c --- /dev/null +++ b/layouts/partials/shortcodes/tabs.html @@ -0,0 +1,24 @@ +{{- $context := .context }} +{{- $tabs := .tabs | default slice }} +{{- $groupId := .groupId | default "default" }} +{{- with $context }} +
+
+ {{- range $idx, $tab := $tabs }} + + {{- end }} +
+
+ {{- range $idx, $tab := $tabs }} +
+{{ .content | safeHTML }} +
+ {{- end }} +
+
+{{- end }} \ No newline at end of file diff --git a/layouts/shortcodes/attachments.html b/layouts/shortcodes/attachments.html index 358c4f8881..4bf4494066 100644 --- a/layouts/shortcodes/attachments.html +++ b/layouts/shortcodes/attachments.html @@ -1,47 +1,10 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $style := .Get "style" | default "transparent" }} -{{- $title := .Get "title" | default ($style | T) | default ("Attachments-label" | T) }} -{{- $icon := .Get "icon" | default "" }} -{{- if and (not $icon) (eq (len $icon) 0) }} - {{- $icon = "paperclip" }} - {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} - {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} - {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} - {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} -{{- end }} -{{- $icon = trim $icon " " }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} -{{- $sort := .Get "sort" | default "asc" }} -{{- $pattern := .Get "pattern" | default "" }} -
-
{{ if $icon }} {{ end }}{{ $title }}
- - {{- .Inner }} -
\ No newline at end of file +{{- partial "shortcodes/attachments.html" (dict + "context" . + "content" .Inner + "icon" (.Get "icon") + "pattern" (.Get "pattern") + "style" (.Get "style") + "sort" (.Get "sort") + "title" (.Get "title") +) }} \ No newline at end of file diff --git a/layouts/shortcodes/button.html b/layouts/shortcodes/button.html index 035c2a3f5b..71934932ed 100644 --- a/layouts/shortcodes/button.html +++ b/layouts/shortcodes/button.html @@ -1,27 +1,10 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $href := .Get "href" }} -{{- $style := .Get "style" | default "transparent" }} -{{- $title := .Get "title" | default (.Inner) | default ($style | T) }} -{{- $icon := .Get "icon" | default "" }} -{{- if and (not $icon) (eq (len $icon) 0) }} - {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} - {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} - {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} - {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} -{{- end }} -{{- $icon = trim $icon " " }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} -{{- $iconposition := .Get "icon-position" | default "left" }} - - - {{- if and $icon (eq $iconposition "left") }} - - {{- end }} - {{ $title }} - {{- if and $icon (eq $iconposition "right") }} - - {{- end }} - - \ No newline at end of file +{{- partial "shortcodes/button.html" (dict + "context" . + "content" .Inner + "href" (.Get "href") + "icon" (.Get "icon") + "icon-position" (.Get "iconposition") + "style" (.Get "style") + "title" (.Get "title") +) }} \ No newline at end of file diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index 246ff316ec..e5a5fcf876 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -1,105 +1,10 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $showhidden := .Get "showhidden" | default false }} -{{- if eq (printf "%T" $showhidden) "string" }} - {{- $showhidden = (eq $showhidden "true") }} -{{- end }} -{{- $style := .Get "style" | default "li" }} -{{- $depth := .Get "depth" | default 1 }} -{{- $withDescription := .Get "description" | default false }} -{{- if eq (printf "%T" $withDescription) "string" }} - {{- $withDescription = (eq $withDescription "true") }} -{{- end }} -{{- $sortTerm := .Get "sort" | lower }} -{{- $containerstyle := .Get "containerstyle" | default "ul" }} -{{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }} - {{- $containerstyle = "div" }} -{{- end }} - -{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }} - {{- $pages := .Page.Pages }} - {{- if .Page.IsHome }} - {{- $pages = .Page.Sections }} - {{- else if .Page.Sections}} - {{- $pages = (.Page.Pages | union .Page.Sections) }} - {{- end }} - - {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} - {{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }} - {{- if eq $currentOrdersectionsby "weight" }} - {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }} - {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- else if eq $currentOrdersectionsby "publishdate" }} - {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- else if eq $currentOrdersectionsby "date" }} - {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- else if eq $currentOrdersectionsby "length" }} - {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- else }} - {{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} - {{- end }} -{{ (printf "" $containerstyle)|safeHTML }} - -{{- define "childs" }} - {{- range .menu }} - {{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} - {{- if not $hidden }} - {{- if not .IsHome }} - {{- if hasPrefix $.style "h" }} - {{- $num := sub ( int (trim $.style "h") ) 1 }} - {{- $numn := add $num $.count }} - -{{ (printf "" $numn)|safeHTML -}} -{{ .Title }} -{{- (printf "" $numn)|safeHTML }} - - {{- else }} -{{ (printf "<%s>" $.style)|safeHTML -}} -{{ .Title }} -{{- (printf "" $.style)|safeHTML }} - {{- end }} - - {{- if $.description }} - {{- if .Description }} -

{{ .Description }}

- {{else}} -

{{ .Summary }}

- {{- end }} - {{- end }} - {{- end }} - {{- if lt $.count $.depth }} - - {{- if eq $.style "li" }} -{{- (printf "<%s>" $.containerstyle)|safeHTML }} - {{- end }} - - {{- $pages := .Page.Pages }} - {{- if .Page.IsHome }} - {{- $pages = .Page.Sections }} - {{- else if .Page.Sections}} - {{- $pages = (.Page.Pages | union .Page.Sections) }} - {{- end }} - - {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} - {{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }} - {{- if eq $currentOrdersectionsby "weight" }} - {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }} - {{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- else if eq $.currentOrdersectionsby "publishdate" }} - {{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- else if eq $.currentOrdersectionsby "date" }} - {{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- else if eq $.currentOrdersectionsby "length" }} - {{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- else }} - {{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} - {{- end }} - - {{- if eq $.style "li" }} -{{- (printf "" $.containerstyle)|safeHTML }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} \ No newline at end of file +{{- partial "shortcodes/children.html" (dict + "context" . + "containerstyle" (.Get "containerstyle") + "descrption" (.Get "description") + "depth" (.Get "depth") + "showhidden" (.Get "showhidden") + "sort" (.Get "sort") + "style" (.Get "style") +) }} \ No newline at end of file diff --git a/layouts/shortcodes/expand.html b/layouts/shortcodes/expand.html index e5f1a502ab..581acd7128 100644 --- a/layouts/shortcodes/expand.html +++ b/layouts/shortcodes/expand.html @@ -1,22 +1,7 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $title := .Get "title" | default (.Get 0) | default (T "Expand-title") }} -{{- $expanded := .Get "open" | default (.Get 1) | default false }} -{{- if eq (printf "%T" $expanded) "string" }} - {{- $expanded = (eq $expanded "true") }} -{{- end }} -{{- $content := .Inner | safeHTML }} -
- {{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}} - - - - {{ $title }} - -
-{{ $content }} -
-
\ No newline at end of file +{{- partial "shortcodes/expand.html" (dict + "context" . + "content" .Inner + "open" (.Get "open" | default (.Get 1)) + "title" (.Get "title" | default (.Get 0)) +) }} \ No newline at end of file diff --git a/layouts/shortcodes/include.html b/layouts/shortcodes/include.html index 5f357bf576..d316b40a0f 100644 --- a/layouts/shortcodes/include.html +++ b/layouts/shortcodes/include.html @@ -1,10 +1,5 @@ -{{- $file := .Get "file" | default (.Get 0) }} -{{- $showFirstHeading := .Get "showfirstheading" | default (.Get 1) | default true }} -{{- if eq (printf "%T" $showFirstHeading) "string" }} - {{- $showFirstHeading = (eq $showFirstHeading "true") }} -{{- end }} -{{- if not $showFirstHeading }}
{{ end }} - -{{ $file | readFile | safeHTML }} - -{{- if not $showFirstHeading }}
{{ end }} \ No newline at end of file +{{- partial "shortcodes/include.html" (dict + "context" . + "file" (.Get "align" | default (.Get 0)) + "showFirstHeading" (.Get "showfirstheading" | default (.Get 1)) +) }} \ No newline at end of file diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index c7af39c62c..bc52efc732 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,6 +1,6 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $align := .Get "align" | default "center" }} -
- {{- safeHTML .Inner -}} -
-{{- .Page.Store.Set "htmlHasMermaid" true }} \ No newline at end of file +{{- partial "shortcodes/mermaid.html" (dict + "context" . + "content" .Inner + "align" (.Get "align") +) }} \ No newline at end of file diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html index 88e0120ab2..f3cb4fa2a3 100644 --- a/layouts/shortcodes/notice.html +++ b/layouts/shortcodes/notice.html @@ -1,19 +1,8 @@ {{- $_hugo_config := `{ "version": 1 }` }} -{{- $style := .Get "style" | default (.Get 0) | default "default" }} -{{- $title := .Get "title" | default (.Get 1) | default ($style | T) }} -{{- $icon := .Get "icon" | default (.Get 2) | default "" }} -{{- if and (not $icon) (eq (len $icon) 0) }} - {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} - {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} - {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} - {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} -{{- end }} -{{- $icon = trim $icon " " }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} -
-
{{ if $icon }} {{ end }}{{ $title }}
-
-{{ .Inner }}
-
\ No newline at end of file +{{- partial "shortcodes/notice.html" (dict + "context" . + "content" .Inner + "icon" (.Get "icon" | default (.Get 2)) + "style" (.Get "style" | default (.Get 0)) + "title" (.Get "title" | default (.Get 1)) +) }} \ No newline at end of file diff --git a/layouts/shortcodes/siteparam.html b/layouts/shortcodes/siteparam.html index d4cbd07da9..3f8e226496 100644 --- a/layouts/shortcodes/siteparam.html +++ b/layouts/shortcodes/siteparam.html @@ -1,7 +1,4 @@ -{{- $paramName := .Get "name" | default (.Get 0) -}} -{{- $siteParams := .Site.Params -}} -{{- with $paramName -}} - {{- with $siteParams -}} - {{- index . (lower $paramName) -}} - {{- end -}} -{{- end -}} \ No newline at end of file +{{- partial "shortcodes/siteparam.html" (dict + "context" . + "name" (.Get "name" | default (.Get 0)) +) }} \ No newline at end of file diff --git a/layouts/shortcodes/swagger.html b/layouts/shortcodes/swagger.html index ba360bedc4..54bcf98a57 100644 --- a/layouts/shortcodes/swagger.html +++ b/layouts/shortcodes/swagger.html @@ -1,25 +1,4 @@ -{{- $original := .Get "src" }} -{{- with .Page.Resources.Match $original }} - {{- range . }} - {{- $original = .RelPermalink }} - {{- end }} -{{- end }} - - -{{- .Page.Store.Set "htmlHasSwagger" true }} \ No newline at end of file +{{- partial "shortcodes/swagger.html" (dict + "context" . + "src" (.Get "src") +) }} \ No newline at end of file diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index 661af3615c..3283b5d30e 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,11 +1,10 @@ -{{ if .Parent }} - {{ $name := trim (.Get "name") " " }} - {{ if not (.Parent.Scratch.Get "tabs") }} - {{ .Parent.Scratch.Set "tabs" slice }} - {{ end }} - {{ with .Inner }} - {{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" . ) }} - {{ end }} -{{ else }} +{{- $content := .Inner }} +{{- $name := (.Get "name") }} +{{- if .Parent }} + {{- if not (.Parent.Scratch.Get "tabs") }} + {{- .Parent.Scratch.Set "tabs" slice }} + {{- end }} + {{- $.Parent.Scratch.Add "tabs" (dict "name" (trim $name " ") "content" $content ) }} +{{- else }} {{- errorf "[%s] %q: tab shortcode missing its parent" site.Language.Lang .Page.Path -}} -{{ end}} +{{- end}} \ No newline at end of file diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index bc4c56158f..3f2a312383 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,21 +1,6 @@ -{{- with .Inner }}{{/* don't do anything, just call it */}}{{ end }} -{{- $groupId := .Get "groupId" | default "default" }} -
-
- {{- range $idx, $tab := .Scratch.Get "tabs" }} - - {{- end }} -
-
- {{- range $idx, $tab := .Scratch.Get "tabs" }} -
-{{ .content }} -
- {{- end }} -
-
+{{- partial "shortcodes/tabs.html" (dict + "context" . + "content" .Inner + "groupId" (.Get "groupId") + "tabs" (.Scratch.Get "tabs") +) }} \ No newline at end of file