shortcodes: convert to partials feature #277

This commit is contained in:
Sören Weber 2022-06-22 20:32:18 +02:00
parent 46d2e17ec0
commit e62381572a
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
21 changed files with 390 additions and 293 deletions

View file

@ -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 }}
<div class="box attachments cstyle {{ $style }}">
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
<ul class="box-content attachments-files">
{{- $filesName := "files" }}
{{- if ne .Page.File.BaseFileName "index" }}
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
{{- end }}
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
{{- $fileDir = replace $fileDir "\\" "/" }}
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
{{- if findRE $pattern .Name}}
{{- $size := .Size }}
{{- $unit := "Byte-symbol" }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Kilobyte-symbol" }}
{{- end }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Megabyte-symbol" }}
{{- end }}
{{- $unitsymbol := $unit | T }}
<li><a href="{{ (printf "%s%s/%s" $fileLink $filesName .Name) | relURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
{{- end }}
{{- end }}
</ul>
{{- $content }}
</div>
{{- end }}

View file

@ -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 }}
<span class="btn cstyle {{ $style }}">
<a href="{{ $href }}" target="_blank">
{{- if and $icon (eq $iconposition "left") }}
<i class="{{ $icon }}"></i>
{{- end }}
{{ $title }}
{{- if and $icon (eq $iconposition "right") }}
<i class="{{ $icon }}"></i>
{{- end }}
</a>
</span>
{{- end }}

View file

@ -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 "</%s>" $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 "<h%d>" $numn)|safeHTML -}}
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
{{- (printf "</h%d>" $numn)|safeHTML }}
{{- else }}
{{ (printf "<%s>" $.style)|safeHTML -}}
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
{{- (printf "</%s>" $.style)|safeHTML }}
{{- end }}
{{- if $.description }}
{{- if .Description }}
<p>{{ .Description }}</p>
{{else}}
<p>{{ .Summary }}</p>
{{- 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 "</%s>" $.containerstyle)|safeHTML }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -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 }}
<div class="expand
{{- if $expanded }} expand-expanded{{ end -}}
">
{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}}
<a class="expand-label" onclick="$t=$(this); if($t.parent('.expand-expanded.expand-marked').length){ $t.next().css('display','none') }else if($t.parent('.expand-marked').length){ $t.next().css('display','block') }else{ $t.next('.expand-content').slideToggle(100); } $t.parent().toggleClass('expand-expanded');">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
{{ $title }}
</a>
<div class="expand-content" style="display:
{{- if $expanded }} block{{ else }} none{{ end -}}
;">
{{ $content | safeHTML }}
</div>
</div>
{{- end }}

View file

@ -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 }}<div class="include hide-first-heading">{{ end }}
{{- with $context }}
{{ $file | readFile | safeHTML }}
{{- if not $showFirstHeading }}</div>{{ end }}
{{- end }}

View file

@ -0,0 +1,9 @@
{{- $context := .context }}
{{- $content := .content }}
{{- $align := .align | default "center" }}
{{- with $context }}
<div class="mermaid" align="{{ $align }}">
{{- safeHTML $content -}}
</div>
{{- .Page.Store.Set "htmlHasMermaid" true }}
{{- end }}

View file

@ -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 }}
<div class="box notices cstyle {{ $style }}">
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
<div class="box-content">
{{ $content | safeHTML }} </div>
</div>
{{- end }}

View file

@ -0,0 +1,10 @@
{{- $context := .context }}
{{- $paramName := .name }}
{{- with $context }}
{{- $siteParams := .Site.Params }}
{{- with $paramName }}
{{- with $siteParams }}
{{- index . (lower $paramName) }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,28 @@
{{- $context := .context }}
{{- $src := .src }}
{{- with $context }}
{{- with .Page.Resources.Match $src }}
{{- range . }}
{{- $src = .RelPermalink }}
{{- end }}
{{- end }}
<style>
rapi-doc::part(section-endpoint-head-method) {
font-size: 11px;
}
</style>
<rapi-doc
allow-spec-file-download="true"
default-schema-tab="example"
font-size="largest"
layout="column"
load-fonts="false"
render-style="view"
schema-description-expanded="true"
schema-style="table"
show-header="false"
spec-url="{{ $src }}"
sort-tags="true"
></rapi-doc>
{{- .Page.Store.Set "htmlHasSwagger" true }}
{{- end }}

View file

@ -0,0 +1,24 @@
{{- $context := .context }}
{{- $tabs := .tabs | default slice }}
{{- $groupId := .groupId | default "default" }}
{{- with $context }}
<div class="tab-panel">
<div class="tab-nav">
{{- range $idx, $tab := $tabs }}
<button
data-tab-item="{{ .name }}"
data-tab-group="{{ $groupId }}"
class="tab-nav-button {{ cond (eq $idx 0) "active" ""}}"
onclick="switchTab('{{ $groupId }}','{{ .name }}')"
><span>{{ .name }}</span></button>
{{- end }}
</div>
<div class="tab-content">
{{- range $idx, $tab := $tabs }}
<div data-tab-item="{{ .name }}" data-tab-group="{{ $groupId }}" class="tab-item {{ cond (eq $idx 0) "active" ""}}">
{{ .content | safeHTML }}
</div>
{{- end }}
</div>
</div>
{{- end }}

View file

@ -1,47 +1,10 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $style := .Get "style" | default "transparent" }} {{- partial "shortcodes/attachments.html" (dict
{{- $title := .Get "title" | default ($style | T) | default ("Attachments-label" | T) }} "context" .
{{- $icon := .Get "icon" | default "" }} "content" .Inner
{{- if and (not $icon) (eq (len $icon) 0) }} "icon" (.Get "icon")
{{- $icon = "paperclip" }} "pattern" (.Get "pattern")
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} "style" (.Get "style")
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} "sort" (.Get "sort")
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} "title" (.Get "title")
{{- 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 "" }}
<div class="box attachments cstyle {{ $style }}">
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
<ul class="box-content attachments-files">
{{- $filesName := "files" }}
{{- if ne .Page.File.BaseFileName "index" }}
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
{{- end }}
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
{{- $fileDir = replace $fileDir "\\" "/" }}
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
{{- if findRE $pattern .Name}}
{{- $size := .Size }}
{{- $unit := "Byte-symbol" }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Kilobyte-symbol" }}
{{- end }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Megabyte-symbol" }}
{{- end }}
{{- $unitsymbol := $unit | T }}
<li><a href="{{ (printf "%s%s/%s" $fileLink $filesName .Name) | relURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
{{- end }}
{{- end }}
</ul>
{{- .Inner }}
</div>

View file

@ -1,27 +1,10 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $href := .Get "href" }} {{- partial "shortcodes/button.html" (dict
{{- $style := .Get "style" | default "transparent" }} "context" .
{{- $title := .Get "title" | default (.Inner) | default ($style | T) }} "content" .Inner
{{- $icon := .Get "icon" | default "" }} "href" (.Get "href")
{{- if and (not $icon) (eq (len $icon) 0) }} "icon" (.Get "icon")
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} "icon-position" (.Get "iconposition")
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} "style" (.Get "style")
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} "title" (.Get "title")
{{- 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" }}
<span class="btn cstyle {{ $style }}">
<a href="{{ $href }}" target="_blank">
{{- if and $icon (eq $iconposition "left") }}
<i class="{{ $icon }}"></i>
{{- end }}
{{ $title }}
{{- if and $icon (eq $iconposition "right") }}
<i class="{{ $icon }}"></i>
{{- end }}
</a>
</span>

View file

@ -1,105 +1,10 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $showhidden := .Get "showhidden" | default false }} {{- partial "shortcodes/children.html" (dict
{{- if eq (printf "%T" $showhidden) "string" }} "context" .
{{- $showhidden = (eq $showhidden "true") }} "containerstyle" (.Get "containerstyle")
{{- end }} "descrption" (.Get "description")
{{- $style := .Get "style" | default "li" }} "depth" (.Get "depth")
{{- $depth := .Get "depth" | default 1 }} "showhidden" (.Get "showhidden")
{{- $withDescription := .Get "description" | default false }} "sort" (.Get "sort")
{{- if eq (printf "%T" $withDescription) "string" }} "style" (.Get "style")
{{- $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 "</%s>" $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 "<h%d>" $numn)|safeHTML -}}
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
{{- (printf "</h%d>" $numn)|safeHTML }}
{{- else }}
{{ (printf "<%s>" $.style)|safeHTML -}}
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
{{- (printf "</%s>" $.style)|safeHTML }}
{{- end }}
{{- if $.description }}
{{- if .Description }}
<p>{{ .Description }}</p>
{{else}}
<p>{{ .Summary }}</p>
{{- 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 "</%s>" $.containerstyle)|safeHTML }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,22 +1,7 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $title := .Get "title" | default (.Get 0) | default (T "Expand-title") }} {{- partial "shortcodes/expand.html" (dict
{{- $expanded := .Get "open" | default (.Get 1) | default false }} "context" .
{{- if eq (printf "%T" $expanded) "string" }} "content" .Inner
{{- $expanded = (eq $expanded "true") }} "open" (.Get "open" | default (.Get 1))
{{- end }} "title" (.Get "title" | default (.Get 0))
{{- $content := .Inner | safeHTML }} ) }}
<div class="expand
{{- if $expanded }} expand-expanded{{ end -}}
">
{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}}
<a class="expand-label" onclick="$t=$(this); if($t.parent('.expand-expanded.expand-marked').length){ $t.next().css('display','none') }else if($t.parent('.expand-marked').length){ $t.next().css('display','block') }else{ $t.next('.expand-content').slideToggle(100); } $t.parent().toggleClass('expand-expanded');">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
{{ $title }}
</a>
<div class="expand-content" style="display:
{{- if $expanded }} block{{ else }} none{{ end -}}
;">
{{ $content }}
</div>
</div>

View file

@ -1,10 +1,5 @@
{{- $file := .Get "file" | default (.Get 0) }} {{- partial "shortcodes/include.html" (dict
{{- $showFirstHeading := .Get "showfirstheading" | default (.Get 1) | default true }} "context" .
{{- if eq (printf "%T" $showFirstHeading) "string" }} "file" (.Get "align" | default (.Get 0))
{{- $showFirstHeading = (eq $showFirstHeading "true") }} "showFirstHeading" (.Get "showfirstheading" | default (.Get 1))
{{- end }} ) }}
{{- if not $showFirstHeading }}<div class="include hide-first-heading">{{ end }}
{{ $file | readFile | safeHTML }}
{{- if not $showFirstHeading }}</div>{{ end }}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $align := .Get "align" | default "center" }} {{- partial "shortcodes/mermaid.html" (dict
<div class="mermaid" align="{{ $align }}"> "context" .
{{- safeHTML .Inner -}} "content" .Inner
</div> "align" (.Get "align")
{{- .Page.Store.Set "htmlHasMermaid" true }} ) }}

View file

@ -1,19 +1,8 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $style := .Get "style" | default (.Get 0) | default "default" }} {{- partial "shortcodes/notice.html" (dict
{{- $title := .Get "title" | default (.Get 1) | default ($style | T) }} "context" .
{{- $icon := .Get "icon" | default (.Get 2) | default "" }} "content" .Inner
{{- if and (not $icon) (eq (len $icon) 0) }} "icon" (.Get "icon" | default (.Get 2))
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} "style" (.Get "style" | default (.Get 0))
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} "title" (.Get "title" | default (.Get 1))
{{- 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 }}
<div class="box notices cstyle {{ $style }}">
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
<div class="box-content">
{{ .Inner }} </div>
</div>

View file

@ -1,7 +1,4 @@
{{- $paramName := .Get "name" | default (.Get 0) -}} {{- partial "shortcodes/siteparam.html" (dict
{{- $siteParams := .Site.Params -}} "context" .
{{- with $paramName -}} "name" (.Get "name" | default (.Get 0))
{{- with $siteParams -}} ) }}
{{- index . (lower $paramName) -}}
{{- end -}}
{{- end -}}

View file

@ -1,25 +1,4 @@
{{- $original := .Get "src" }} {{- partial "shortcodes/swagger.html" (dict
{{- with .Page.Resources.Match $original }} "context" .
{{- range . }} "src" (.Get "src")
{{- $original = .RelPermalink }} ) }}
{{- end }}
{{- end }}
<style>
rapi-doc::part(section-endpoint-head-method) {
font-size: 11px;
}
</style>
<rapi-doc
allow-spec-file-download="true"
default-schema-tab="example"
font-size="largest"
layout="column"
load-fonts="false"
render-style="view"
schema-description-expanded="true"
schema-style="table"
show-header="false"
spec-url="{{ $original }}"
sort-tags="true"
></rapi-doc>
{{- .Page.Store.Set "htmlHasSwagger" true }}

View file

@ -1,11 +1,10 @@
{{ if .Parent }} {{- $content := .Inner }}
{{ $name := trim (.Get "name") " " }} {{- $name := (.Get "name") }}
{{ if not (.Parent.Scratch.Get "tabs") }} {{- if .Parent }}
{{ .Parent.Scratch.Set "tabs" slice }} {{- if not (.Parent.Scratch.Get "tabs") }}
{{ end }} {{- .Parent.Scratch.Set "tabs" slice }}
{{ with .Inner }} {{- end }}
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" . ) }} {{- $.Parent.Scratch.Add "tabs" (dict "name" (trim $name " ") "content" $content ) }}
{{ end }} {{- else }}
{{ else }}
{{- errorf "[%s] %q: tab shortcode missing its parent" site.Language.Lang .Page.Path -}} {{- errorf "[%s] %q: tab shortcode missing its parent" site.Language.Lang .Page.Path -}}
{{ end}} {{- end}}

View file

@ -1,21 +1,6 @@
{{- with .Inner }}{{/* don't do anything, just call it */}}{{ end }} {{- partial "shortcodes/tabs.html" (dict
{{- $groupId := .Get "groupId" | default "default" }} "context" .
<div class="tab-panel"> "content" .Inner
<div class="tab-nav"> "groupId" (.Get "groupId")
{{- range $idx, $tab := .Scratch.Get "tabs" }} "tabs" (.Scratch.Get "tabs")
<button ) }}
data-tab-item="{{ .name }}"
data-tab-group="{{ $groupId }}"
class="tab-nav-button {{ cond (eq $idx 0) "active" ""}}"
onclick="switchTab('{{ $groupId }}','{{ .name }}')"
><span>{{ .name }}</span></button>
{{- end }}
</div>
<div class="tab-content">
{{- range $idx, $tab := .Scratch.Get "tabs" }}
<div data-tab-item="{{ .name }}" data-tab-group="{{ $groupId }}" class="tab-item {{ cond (eq $idx 0) "active" ""}}">
{{ .content }}
</div>
{{- end }}
</div>
</div>