Fix Learn theme addition to git
This commit is contained in:
34
themes/learn/layouts/shortcodes/attachments.html
Normal file
34
themes/learn/layouts/shortcodes/attachments.html
Normal file
@ -0,0 +1,34 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<section class="attachments {{ with .Get "style"}}{{.}}{{ end }}">
|
||||
<label>
|
||||
<i class="fas fa-paperclip" aria-hidden="true"></i>
|
||||
{{with .Get "title"}}{{.}}{{else}}{{T "Attachments-label"}}{{end}}
|
||||
</label>
|
||||
<div class="attachments-files">
|
||||
{{- $filesName := "files" }}
|
||||
{{- if ne .Page.File.BaseFileName "index" }}
|
||||
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
|
||||
{{- end}}
|
||||
{{- $fileDir := replace .Page.File.Dir "\\" "/" }}
|
||||
{{- $pattern := .Get "pattern" | default "" }}
|
||||
{{- range (readDir (printf "content/%s%s" .Page.File.Dir $filesName) ) }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte" }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Kilobyte" }}
|
||||
{{- end}}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Megabyte" }}
|
||||
{{- end}}
|
||||
<li>
|
||||
<a href="{{ (printf "%s%s/%s" $fileDir $filesName .Name) | relLangURL }}">{{.Name}}</a>
|
||||
({{$size}} {{T (print $unit "-symbol")}})
|
||||
</li>
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
</div>
|
||||
{{- .Inner}}
|
||||
</section>
|
14
themes/learn/layouts/shortcodes/button.html
Normal file
14
themes/learn/layouts/shortcodes/button.html
Normal file
@ -0,0 +1,14 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<a {{ with .Get "href"}} href="{{.}}" target="_blank" {{ end }} class="btn btn-default">
|
||||
{{ $icon := .Get "icon" }}
|
||||
{{ $iconposition := .Get "icon-position" }}
|
||||
{{ if ($icon) }}
|
||||
{{ if or (not ($iconposition)) (eq $iconposition "left") }}
|
||||
<i class="{{$icon}}"></i>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ .Inner }}
|
||||
{{ if and ($icon) (eq $iconposition "right")}}
|
||||
<i class="{{$icon}}"></i>
|
||||
{{ end }}
|
||||
</a>
|
99
themes/learn/layouts/shortcodes/children.html
Normal file
99
themes/learn/layouts/shortcodes/children.html
Normal file
@ -0,0 +1,99 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
{{ $showhidden := .Get "showhidden"}}
|
||||
{{ $style := .Get "style" | default "li" }}
|
||||
{{ $depth := .Get "depth" | default 1 }}
|
||||
{{ $withDescription := .Get "description" | default false }}
|
||||
{{ $sortTerm := .Get "sort" | default "Weight" }}
|
||||
|
||||
<ul class="children children-{{$style}}">
|
||||
{{ .Scratch.Set "pages" .Page.Pages }}
|
||||
|
||||
{{if .Page.IsHome}}
|
||||
<!-- Add pages that are in root dir -->
|
||||
{{ $rootPage := where .Page.Pages "Dir" "" }}
|
||||
{{ .Scratch.Set "pages" (.Page.Sections | union $rootPage)}}
|
||||
{{else}}
|
||||
{{ if .Page.Sections}}
|
||||
{{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{ $pages := (.Scratch.Get "pages") }}
|
||||
|
||||
{{if eq $sortTerm "Weight"}}
|
||||
{{template "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Name"}}
|
||||
{{template "childs" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "PublishDate"}}
|
||||
{{template "childs" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Date"}}
|
||||
{{template "childs" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else if eq $sortTerm "Length"}}
|
||||
{{template "childs" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{else}}
|
||||
{{template "childs" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
{{ define "childs" }}
|
||||
{{ range .menu }}
|
||||
{{ if and .Params.hidden (not $.showhidden) }}
|
||||
{{else}}
|
||||
{{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"}}
|
||||
<ul>
|
||||
{{end}}
|
||||
|
||||
{{ if .Sections}}
|
||||
{{ .Scratch.Set "pages" (.Pages | union .Sections) }}
|
||||
{{else}}
|
||||
{{ .Scratch.Set "pages" .Pages }}
|
||||
{{end}}
|
||||
|
||||
{{ $pages := (.Scratch.Get "pages") }}
|
||||
|
||||
{{if eq $.sortTerm "Weight"}}
|
||||
{{template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Name"}}
|
||||
{{template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "PublishDate"}}
|
||||
{{template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Date"}}
|
||||
{{template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else if eq $.sortTerm "Length"}}
|
||||
{{template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{else}}
|
||||
{{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
|
||||
{{end}}
|
||||
|
||||
{{if eq $.style "li"}}
|
||||
</ul>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
17
themes/learn/layouts/shortcodes/expand.html
Normal file
17
themes/learn/layouts/shortcodes/expand.html
Normal file
@ -0,0 +1,17 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<div class="expand">
|
||||
<div class="expand-label" style="cursor: pointer;" onclick="$h = $(this);$h.next('div').slideToggle(100,function () {$h.children('i').attr('class',function () {return $h.next('div').is(':visible') ? 'fas fa-chevron-down' : 'fas fa-chevron-right';});});">
|
||||
<i style="font-size:x-small;" class="fas fa-chevron-right"></i>
|
||||
<span>
|
||||
{{$expandMessage := T "Expand-title"}}
|
||||
{{ if .IsNamedParams }}
|
||||
{{.Get "default" | default $expandMessage}}
|
||||
{{else}}
|
||||
{{.Get 0 | default $expandMessage}}
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="expand-content" style="display: none;">
|
||||
{{.Inner | safeHTML}}
|
||||
</div>
|
||||
</div>
|
2
themes/learn/layouts/shortcodes/mermaid.html
Normal file
2
themes/learn/layouts/shortcodes/mermaid.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<div class="mermaid" align="{{ if .Get "align" }}{{ .Get "align" }}{{ else }}center{{ end }}">{{ safeHTML .Inner }}</div>
|
2
themes/learn/layouts/shortcodes/notice.html
Normal file
2
themes/learn/layouts/shortcodes/notice.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<div class="notices {{ .Get 0 }}" {{ if len .Params | eq 2 }} id="{{ .Get 1 }}" {{ end }}>{{ .Inner }}</div>
|
14
themes/learn/layouts/shortcodes/ref.html
Normal file
14
themes/learn/layouts/shortcodes/ref.html
Normal file
@ -0,0 +1,14 @@
|
||||
{{- if in (.Get 0) "/_index.md" -}}
|
||||
{{- $paths := (split (.Get 0) "_index.md") -}}
|
||||
{{- $pagepath := index $paths 0 -}}
|
||||
{{- $anchor := index $paths 1 -}}
|
||||
{{- with .Site.GetPage "section" (trim $pagepath "/") -}}
|
||||
{{- ( printf "%s%s" $pagepath $anchor ) | relLangURL -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- with .Site.GetPage "section" (.Get 0) }}
|
||||
{{- .RelPermalink -}}
|
||||
{{- else -}}
|
||||
{{- .Get 0 | relref .Page -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
14
themes/learn/layouts/shortcodes/relref.html
Normal file
14
themes/learn/layouts/shortcodes/relref.html
Normal file
@ -0,0 +1,14 @@
|
||||
{{- if in (.Get 0) "/_index.md" -}}
|
||||
{{- $paths := (split (.Get 0) "_index.md") -}}
|
||||
{{- $pagepath := index $paths 0 -}}
|
||||
{{- $anchor := index $paths 1 -}}
|
||||
{{- with .Site.GetPage "section" (trim $pagepath "/") -}}
|
||||
{{- ( printf "%s%s" $pagepath $anchor ) | relLangURL -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- with .Site.GetPage "section" (.Get 0) }}
|
||||
{{- .RelPermalink -}}
|
||||
{{- else -}}
|
||||
{{- .Get 0 | relref .Page -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
7
themes/learn/layouts/shortcodes/siteparam.html
Normal file
7
themes/learn/layouts/shortcodes/siteparam.html
Normal file
@ -0,0 +1,7 @@
|
||||
{{- $paramName := (.Get 0) -}}
|
||||
{{- $siteParams := .Site.Params -}}
|
||||
{{- with $paramName -}}
|
||||
{{- with $siteParams -}}
|
||||
{{- index . (lower $paramName) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
12
themes/learn/layouts/shortcodes/tab.html
Normal file
12
themes/learn/layouts/shortcodes/tab.html
Normal file
@ -0,0 +1,12 @@
|
||||
{{ 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 }}
|
||||
{{- errorf "[%s] %q: tab shortcode missing its parent" site.Language.Lang .Page.Path -}}
|
||||
{{ end}}
|
||||
|
21
themes/learn/layouts/shortcodes/tabs.html
Normal file
21
themes/learn/layouts/shortcodes/tabs.html
Normal file
@ -0,0 +1,21 @@
|
||||
{{ with .Inner }}{{/* don't do anything, just call it */}}{{ end }}
|
||||
{{ $groupId := default "default" (.Get "groupId") }}
|
||||
<div class="tab-panel">
|
||||
<div class="tab-nav">
|
||||
{{ range $idx, $tab := .Scratch.Get "tabs" }}
|
||||
<button
|
||||
data-tab-item="{{ .name }}"
|
||||
data-tab-group="{{ $groupId }}"
|
||||
class="tab-nav-button btn {{ cond (eq $idx 0) "active" ""}}"
|
||||
onclick="switchTab('{{ $groupId }}','{{ .name }}')"
|
||||
>{{ .name }}</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>
|
Reference in New Issue
Block a user