hugo-book
This commit is contained in:
12
themes/hugo-book/layouts/shortcodes/button.html
Normal file
12
themes/hugo-book/layouts/shortcodes/button.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{ $ref := "" }}
|
||||
{{ $target := "" }}
|
||||
{{ with .Get "href" }}
|
||||
{{ $ref = . }}
|
||||
{{ $target = "_blank" }}
|
||||
{{ end }}
|
||||
{{ with .Get "relref" }}
|
||||
{{ $ref = relref $ . }}
|
||||
{{ end }}
|
||||
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||
{{ .Inner | .Page.RenderString }}
|
||||
</a>
|
||||
7
themes/hugo-book/layouts/shortcodes/columns.html
Normal file
7
themes/hugo-book/layouts/shortcodes/columns.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="book-columns flex flex-wrap">
|
||||
{{ range split .Inner "<--->" }}
|
||||
<div class="flex-even markdown-inner">
|
||||
{{ . | $.Page.RenderString }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
7
themes/hugo-book/layouts/shortcodes/details.html
Normal file
7
themes/hugo-book/layouts/shortcodes/details.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}>
|
||||
{{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}}
|
||||
<summary>{{ $summary | .Page.RenderString }}</summary>
|
||||
<div class="markdown-inner">
|
||||
{{ .Inner | .Page.RenderString }}
|
||||
</div>
|
||||
</details>
|
||||
13
themes/hugo-book/layouts/shortcodes/expand.html
Normal file
13
themes/hugo-book/layouts/shortcodes/expand.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{{ warnf "Expand shortcode is deprecated. Use 'details' instead." }}
|
||||
<div class="book-expand">
|
||||
<label>
|
||||
<div class="book-expand-head flex justify-between">
|
||||
<span>{{ default (i18n "Expand") (.Get 0) }}</span>
|
||||
<span>{{ default "↕" (.Get 1) }}</span>
|
||||
</div>
|
||||
<input type="checkbox" class="hidden" />
|
||||
<div class="book-expand-content markdown-inner">
|
||||
{{ .Inner | markdownify }}
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
3
themes/hugo-book/layouts/shortcodes/hint.html
Normal file
3
themes/hugo-book/layouts/shortcodes/hint.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<blockquote class="book-hint {{ .Get 0 }}">
|
||||
{{ .Inner | .Page.RenderString }}
|
||||
</blockquote>
|
||||
13
themes/hugo-book/layouts/shortcodes/katex.html
Normal file
13
themes/hugo-book/layouts/shortcodes/katex.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{{- if not (.Page.Scratch.Get "katex") -}}
|
||||
<!-- Include katext only first time -->
|
||||
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
|
||||
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
|
||||
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body);"></script>
|
||||
{{- .Page.Scratch.Set "katex" true -}}
|
||||
{{- end -}}
|
||||
|
||||
<span {{- with .Get "class" }} class="{{ . }}"{{ end }}>
|
||||
{{ cond (in .Params "display") "\\[" "\\(" -}}
|
||||
{{- trim .Inner "\n" -}}
|
||||
{{- cond (in .Params "display") "\\]" "\\)" }}
|
||||
</span>
|
||||
12
themes/hugo-book/layouts/shortcodes/mermaid.html
Normal file
12
themes/hugo-book/layouts/shortcodes/mermaid.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{ if not (.Page.Scratch.Get "mermaid") }}
|
||||
<!-- Include mermaid only first time -->
|
||||
<script src="{{ "mermaid.min.js" | relURL }}"></script>
|
||||
{{ with resources.Get "mermaid.json" }}
|
||||
<script>mermaid.initialize({{ .Content | safeJS }})</script>
|
||||
{{ end }}
|
||||
{{ .Page.Scratch.Set "mermaid" true }}
|
||||
{{ end }}
|
||||
|
||||
<p class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||
{{- .Inner -}}
|
||||
</p>
|
||||
10
themes/hugo-book/layouts/shortcodes/section.html
Normal file
10
themes/hugo-book/layouts/shortcodes/section.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<dl>
|
||||
{{ range .Page.Pages }}
|
||||
<dt>
|
||||
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
|
||||
</dt>
|
||||
<dd class="markdown-inner">
|
||||
{{ default .Summary .Description }}
|
||||
</dd>
|
||||
{{ end }}
|
||||
</dl>
|
||||
12
themes/hugo-book/layouts/shortcodes/tab.html
Normal file
12
themes/hugo-book/layouts/shortcodes/tab.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{ if .Parent }}
|
||||
{{ $name := .Get 0 }}
|
||||
{{ $group := printf "tabs-%s" (.Parent.Get 0) }}
|
||||
|
||||
{{ if not (.Parent.Scratch.Get $group) }}
|
||||
{{ .Parent.Scratch.Set $group slice }}
|
||||
{{ end }}
|
||||
|
||||
{{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }}
|
||||
{{ else }}
|
||||
{{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }}
|
||||
{{ end}}
|
||||
15
themes/hugo-book/layouts/shortcodes/tabs.html
Normal file
15
themes/hugo-book/layouts/shortcodes/tabs.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{{ if .Inner }}{{ end }}
|
||||
{{ $id := .Get 0 }}
|
||||
{{ $group := printf "tabs-%s" $id }}
|
||||
|
||||
<div class="book-tabs">
|
||||
{{- range $index, $tab := .Scratch.Get $group -}}
|
||||
<input type="radio" class="toggle" name="{{ $group }}" id="{{ printf "%s-%d" $group $index }}" {{ if not $index }}checked="checked"{{ end }} />
|
||||
<label for="{{ printf "%s-%d" $group $index }}">
|
||||
{{- $tab.Name -}}
|
||||
</label>
|
||||
<div class="book-tabs-content markdown-inner">
|
||||
{{- .Content | $.Page.RenderString -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
Reference in New Issue
Block a user