Update for new Hugo versions
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
21
layouts/_shortcodes/bergamot_exercise.html
Normal file
21
layouts/_shortcodes/bergamot_exercise.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="bergamot-exercise">
|
||||
<details open>
|
||||
<summary>
|
||||
<span class="bergamot-exercise-label">
|
||||
<span class="bergamot-exercise-number"></span>
|
||||
{{ if or (eq (.Get "label") "") (eq (.Get "label") nil) }}{{ else }}({{ .Get "label" }}){{ end }}:
|
||||
</span>
|
||||
</summary>
|
||||
{{ transform.Markdownify .Inner }}
|
||||
|
||||
<div class="bergamot-button-group">
|
||||
{{ if or (eq (.Get "preset") "") (eq (.Get "preset") nil) }}
|
||||
{{ else }}
|
||||
<button class="bergamot-button bergamot-play" onclick='window.Bergamot.runPreset(this.parentElement, "bergamot-widget-container-{{ .Get "id" }}", "{{ .Get "preset" }}")'>{{ partial "icon.html" "play" }}Start Bergamot</button>
|
||||
<button class="bergamot-button bergamot-close bergamot-hidden" onclick='window.Bergamot.close(this.parentElement, "bergamot-widget-container-{{ .Get "id" }}")'>{{ partial "icon.html" "x" }}Close Bergamot</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div id="bergamot-widget-container-{{ .Get "id" }}"></div>
|
||||
</details>
|
||||
</div>
|
||||
8
layouts/_shortcodes/bergamot_widget.html
Normal file
8
layouts/_shortcodes/bergamot_widget.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<div id="{{ .Get "id" }}"></div>
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
window.Bergamot.run(null, '{{ .Get "id" }}',
|
||||
{{ partial "bergamotparseinputmodes.js" (.Get "modes") | safeJS }},
|
||||
'{{ .Get "prompt" }}', '{{ .Inner }}', '{{ default "default" (.Get "rendering") }}', '{{ .Get "query" }}');
|
||||
});
|
||||
</script>
|
||||
3
layouts/_shortcodes/block.html
Normal file
3
layouts/_shortcodes/block.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="block">
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
12
layouts/_shortcodes/codeblock.html
Normal file
12
layouts/_shortcodes/codeblock.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1)) -}}
|
||||
{{- $groupconfig := dict
|
||||
"url" ($scratch.Get "bestUrl")
|
||||
"basePath" ($scratch.Get "bestPath")
|
||||
"path" (.Get 1)
|
||||
"comment" ", entire file"
|
||||
"code" (readFile (printf "code/%s" (.Get 1)))
|
||||
"language" (.Get 0)
|
||||
"opts" "linenos=table"
|
||||
-}}
|
||||
{{- partial "highlightgroup.html" $groupconfig -}}
|
||||
59
layouts/_shortcodes/codelines.html
Normal file
59
layouts/_shortcodes/codelines.html
Normal file
@@ -0,0 +1,59 @@
|
||||
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
|
||||
{{- $allLines := split $source "\n" -}}
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- $remLines := $allLines -}}
|
||||
{{- if not (eq (int (.Get 2)) 1) -}}
|
||||
{{- $remLines = after (sub (int (.Get 2)) 1) $allLines -}}
|
||||
{{- end -}}
|
||||
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) $remLines -}}
|
||||
|
||||
{{- $opts := "" -}}
|
||||
{{- if (.Get 4) -}}
|
||||
{{- $opts = printf ",%s" (.Get 4) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if (.Get 5) -}}
|
||||
{{- $scratch.Set "hidden" (.Get 5) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $prefixLength := "" -}}
|
||||
{{- $joinedLines := "" -}}
|
||||
{{- if or (.Page.Params.left_align_code) (.Get 6) -}}
|
||||
{{- $prefixLength = -1 -}}
|
||||
{{- range $line := $lines -}}
|
||||
{{- $leading := sub (len $line) (len (strings.TrimLeft " " $line)) -}}
|
||||
{{- if and (ne $line "") (or (eq $prefixLength -1) (le $leading $prefixLength)) -}}
|
||||
{{- $prefixLength = $leading -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $line := $lines -}}
|
||||
{{- $joinedLines = add $joinedLines (substr $line $prefixLength) -}}
|
||||
{{- $joinedLines = add $joinedLines "\n" -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $joinedLines = delimit $lines "\n" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}}
|
||||
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
||||
|
||||
{{- with ($scratch.Get "hidden") -}}
|
||||
<details><summary>{{- . | markdownify -}}</summary>
|
||||
{{- end -}}
|
||||
{{- $groupconfig := dict
|
||||
"url" ($scratch.Get "bestUrl")
|
||||
"basePath" ($scratch.Get "bestPath")
|
||||
"path" (.Get 1)
|
||||
"comment" ($scratch.Get "comment")
|
||||
"code" $joinedLines
|
||||
"firstLine" (int (.Get 2))
|
||||
"lastLine" (int (.Get 3))
|
||||
"language" (.Get 0)
|
||||
"offset" $prefixLength
|
||||
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) $opts)
|
||||
-}}
|
||||
{{- partial "highlightgroup.html" $groupconfig -}}
|
||||
{{- with ($scratch.Get "hidden") -}}
|
||||
</details>
|
||||
{{- end -}}
|
||||
3
layouts/_shortcodes/codeurl.html
Normal file
3
layouts/_shortcodes/codeurl.html
Normal file
@@ -0,0 +1,3 @@
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0)) -}}
|
||||
{{- $scratch.Get "bestUrl" -}}
|
||||
4
layouts/_shortcodes/details.html
Normal file
4
layouts/_shortcodes/details.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<details>
|
||||
<summary>{{- .Get "summary" | markdownify -}}</summary>
|
||||
{{- .Inner | markdownify -}}
|
||||
</details>
|
||||
3
layouts/_shortcodes/dialog.html
Normal file
3
layouts/_shortcodes/dialog.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<p class="dialog">
|
||||
{{- .Inner -}}
|
||||
</p>
|
||||
6
layouts/_shortcodes/draftlink.html
Normal file
6
layouts/_shortcodes/draftlink.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{{- $page := site.GetPage (.Get 1) -}}
|
||||
{{- if $page -}}
|
||||
<a href="{{ $page.RelPermalink }}">{{ .Get 0 }}</a>
|
||||
{{- else -}}
|
||||
<span class="draft-link">{{ .Get 0 }} (coming soon)</span>
|
||||
{{- end -}}
|
||||
1
layouts/_shortcodes/foldtable.html
Normal file
1
layouts/_shortcodes/foldtable.html
Normal file
@@ -0,0 +1 @@
|
||||
<span class="fold-table"></span>
|
||||
11
layouts/_shortcodes/githubsnippet.html
Normal file
11
layouts/_shortcodes/githubsnippet.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{{- $repo := .Get 0 -}}
|
||||
{{- $commit := .Get 1 -}}
|
||||
{{- $file := .Get 2 -}}
|
||||
{{- $lang := .Get 3 -}}
|
||||
{{- $line := .Get 4 -}}
|
||||
{{- $lines := split (trim .Inner "\n") "\n" -}}
|
||||
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- $url := printf "https://github.com/%s/blob/%s/%s#L%d" $repo $commit $file $line -}}
|
||||
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" 0 "to" $line) -}}
|
||||
{{- partial "highlightgroup.html" (dict "url" $url "path" $file "comment" ($scratch.Get "comment") "code" (trim .Inner "\n") "language" $lang) -}}
|
||||
12
layouts/_shortcodes/internal.html
Normal file
12
layouts/_shortcodes/internal.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{- $name := .Get 0 -}}
|
||||
{{- $number := 1 -}}
|
||||
{{- with .Page.Scratch.Get "internal-ref-counter" -}}
|
||||
{{- $number = add . 1 }}
|
||||
{{- end -}}
|
||||
{{- .Page.Scratch.Set "internal-ref-counter" $number -}}
|
||||
{{- .Page.Scratch.SetInMap "internal-ref" $name $number -}}
|
||||
|
||||
<span class="internal-ref" id="internal-ref-{{ $name }}">
|
||||
{{ .Inner }}
|
||||
<span class="internal-ref-counter">{{ $number }}</span></span>
|
||||
{{- /* chomp whitespace at the end */ -}}
|
||||
7
layouts/_shortcodes/internalref.html
Normal file
7
layouts/_shortcodes/internalref.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{- $name := .Get 0 -}}
|
||||
{{- $number := index (.Page.Scratch.Get "internal-ref") $name -}}
|
||||
|
||||
<a href="#internal-ref-{{ $name }}">
|
||||
{{ .Inner }}
|
||||
<span class="internal-ref-counter">{{ $number }}</span></a>
|
||||
{{- /* chomp whitespace at the end */ -}}
|
||||
3
layouts/_shortcodes/latex.html
Normal file
3
layouts/_shortcodes/latex.html
Normal file
@@ -0,0 +1,3 @@
|
||||
$$
|
||||
{{ htmlEscape .Inner }}
|
||||
$$
|
||||
10
layouts/_shortcodes/message.html
Normal file
10
layouts/_shortcodes/message.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<span class="message side-{{ .Get 0 }}">
|
||||
<span class="message-sender">
|
||||
{{- if (eq (.Get 1) "reader") -}}
|
||||
{{- partial "icon.html" "moon" -}}
|
||||
{{- else -}}
|
||||
{{- partial "icon.html" "sun" -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
<span class="message-text">{{- .Inner -}}</span>
|
||||
</span>
|
||||
10
layouts/_shortcodes/rawblock.html
Normal file
10
layouts/_shortcodes/rawblock.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" hugo.Data.submodules) -}}
|
||||
{{- $groupconfig := dict
|
||||
"url" ($scratch.Get "bestUrl")
|
||||
"basePath" ($scratch.Get "bestPath")
|
||||
"path" (.Get 0)
|
||||
"comment" ", entire file"
|
||||
"content" (safeHTML (printf "<pre><code>%s</code></pre>" (htmlEscape (readFile (printf "code/%s" (.Get 0))))))
|
||||
-}}
|
||||
{{- partial "group.html" $groupconfig -}}
|
||||
3
layouts/_shortcodes/seriesnav.html
Normal file
3
layouts/_shortcodes/seriesnav.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="early-navigation-wrapper">
|
||||
{{ partial "seriesnav.html" .Page }}
|
||||
</div>
|
||||
3
layouts/_shortcodes/sidebyside.html
Normal file
3
layouts/_shortcodes/sidebyside.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="side-by-side">
|
||||
{{ .Inner }}
|
||||
</div>
|
||||
3
layouts/_shortcodes/sidebysideitem.html
Normal file
3
layouts/_shortcodes/sidebysideitem.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="side-by-side-item" {{ with .Get "weight" }} style="flex-grow: {{ . }};" {{ end }}>
|
||||
{{ .Inner }}
|
||||
</div>
|
||||
16
layouts/_shortcodes/sidenote.html
Normal file
16
layouts/_shortcodes/sidenote.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<span class="sidenote">
|
||||
<label class="sidenote-label" for="{{- .Get 1 -}}">{{- .Get 2 | markdownify -}}</label>
|
||||
{{- /* chomp trailing whitespace */ -}}
|
||||
<input class="sidenote-checkbox" style="display: none;" type="checkbox" id="{{- .Get 1 -}}"></input>
|
||||
{{- if $offset := .Get 3 -}}
|
||||
<span class="sidenote-content sidenote-{{- .Get 0 -}}" style="margin-top: {{- $offset -}}rem">
|
||||
{{- else -}}
|
||||
<span class="sidenote-content sidenote-{{- .Get 0 -}}">
|
||||
{{- end -}}
|
||||
<span class="sidenote-delimiter">[{{- i18n "note" -}}:</span>
|
||||
{{- .Inner -}}
|
||||
<span class="sidenote-delimiter">]</span>
|
||||
</span>
|
||||
{{- /* chomp trailing whitespace */ -}}
|
||||
</span>
|
||||
{{- /* chomp trailing whitespace */ -}}
|
||||
Reference in New Issue
Block a user