snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s
Some checks failed
master / ci (push) Failing after 0s
This commit is contained in:
114
docs/layouts/shortcodes/load-snippet-partial.html
Normal file
114
docs/layouts/shortcodes/load-snippet-partial.html
Normal file
@@ -0,0 +1,114 @@
|
||||
{{ $file := (.Get "file") }}
|
||||
{{ $content := readFile $file }}
|
||||
|
||||
{{ $first_line_contains := (.Get "first_line_contains") }}
|
||||
{{ $last_line_contains := (.Get "last_line_contains") }}
|
||||
{{ $last_line_equals := (.Get "last_line_equals") }}
|
||||
|
||||
{{ $show_line := false }}
|
||||
|
||||
{{/*if true, first or last line was not found*/}}
|
||||
{{ $first_line_found := false}}
|
||||
{{ $last_line_found := false}}
|
||||
|
||||
{{ $padding_after := (.Get "padding_after" | default "0" | int) }}
|
||||
|
||||
{{ $first_line_num := 0 }}
|
||||
{{ $last_line_num := 0 }}
|
||||
|
||||
{{ $linkFile := $file }}
|
||||
{{ $repo := "watermill" }}
|
||||
|
||||
{{ if in $file "src-link/watermill-" }}
|
||||
{{ $repo = index (findRE "watermill-[a-z]+" $linkFile) 0 }}
|
||||
{{ $linkFile = replace $linkFile $repo "" }}
|
||||
{{ $linkFile = replace $linkFile "src-link//" "" }}
|
||||
{{ else if in $linkFile "src-link/" }}
|
||||
{{ $linkFile = replace $linkFile "src-link/" "" }}
|
||||
{{ else }}
|
||||
{{ $linkFile = print "docs/content/" $linkFile }}
|
||||
{{ end }}
|
||||
|
||||
{{ $lines := slice }}
|
||||
|
||||
{{ range $elem_key, $elem_val := split $content "\n" }}
|
||||
{{ $line_num := (add $elem_key 1) }}
|
||||
|
||||
{{ if and (not $first_line_found) (in $elem_val $first_line_contains) }}
|
||||
{{ if ne $elem_key 0 }}
|
||||
{{ $lines = $lines | append "// ..." }}
|
||||
{{ end }}
|
||||
|
||||
{{ $show_line = true }}
|
||||
{{ $first_line_found = true}}
|
||||
{{ $first_line_num = $line_num }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $show_line }}
|
||||
{{ $lines = $lines | append $elem_val }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and ($first_line_found) (in $elem_val $last_line_contains) (ne $last_line_contains "") }}
|
||||
{{ $last_line_found = true }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and ($first_line_found) (eq $elem_val $last_line_equals) (ne $last_line_equals "") }}
|
||||
{{ $last_line_found = true }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and $last_line_found $show_line }}
|
||||
{{ if gt $padding_after 0 }}
|
||||
{{ $padding_after = sub $padding_after 1}}
|
||||
{{ else }}
|
||||
{{ $lines = $lines | append "// ..." }}
|
||||
{{ $show_line = false }}
|
||||
{{ $last_line_num = $line_num }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Calculate minimum indentation (common whitespace) */}}
|
||||
{{ $min_indent := 999999 }}
|
||||
{{ range $lines }}
|
||||
{{ if and (ne . "// ...") (ne (trim . " \t") "") }}
|
||||
{{ $leading := 0 }}
|
||||
{{ range $i, $char := split . "" }}
|
||||
{{ if or (eq $char " ") (eq $char "\t") }}
|
||||
{{ $leading = add $leading 1 }}
|
||||
{{ else }}
|
||||
{{ break }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if lt $leading $min_indent }}
|
||||
{{ $min_indent = $leading }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Remove common leading whitespace from all lines */}}
|
||||
{{ $normalized_lines := slice }}
|
||||
{{ range $lines }}
|
||||
{{ if or (eq . "// ...") (eq (trim . " \t") "") }}
|
||||
{{ $normalized_lines = $normalized_lines | append . }}
|
||||
{{ else if gt $min_indent 0 }}
|
||||
{{ $normalized_lines = $normalized_lines | append (substr . $min_indent) }}
|
||||
{{ else }}
|
||||
{{ $normalized_lines = $normalized_lines | append . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="expressive-code">
|
||||
<figure class="frame not-content">
|
||||
{{ transform.Highlight (delimit $normalized_lines "\n" | safeHTML) (.Get "type" | default "go") }}
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<small class="smaller">Full source: [github.com/ThreeDotsLabs/{{ $repo }}/{{ $linkFile }}](https://github.com/ThreeDotsLabs/{{ $repo }}/tree/master/{{ $linkFile }}{{ if ne $first_line_num 0 }}#L{{ $first_line_num }}{{ end }})</small>
|
||||
|
||||
{{if not $first_line_found }}
|
||||
{{ errorf "`first_line_contains` %s not found in %s snippet" $first_line_contains $file }}
|
||||
{{end}}
|
||||
|
||||
{{if and (not $last_line_found) (ne $last_line_contains "") }}
|
||||
{{ errorf "`last_line_contains` %s not found in %s snippet" $last_line_contains $file }}
|
||||
{{end}}
|
||||
37
docs/layouts/shortcodes/load-snippet.html
Normal file
37
docs/layouts/shortcodes/load-snippet.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{{ $file := (.Get "file") }}
|
||||
{{ $content := readFile $file }}
|
||||
|
||||
{{ $start_line := (.Get "start_line") | default "0" }}
|
||||
{{ $end_line := (.Get "end_line") | default "0" }}
|
||||
|
||||
{{ $has_start_line := (ne $start_line "0") }}
|
||||
{{ $has_end_line := (ne $end_line "0") }}
|
||||
|
||||
{{ $lines := slice }}
|
||||
|
||||
{{ $linkFile := $file }}
|
||||
{{ $repo := "watermill" }}
|
||||
|
||||
{{ if in $file "src-link/watermill-" }}
|
||||
{{ $repo = index (findRE "watermill-[a-z]+" $linkFile) 0 }}
|
||||
{{ $linkFile = replace $linkFile $repo "" }}
|
||||
{{ $linkFile = replace $linkFile "src-link//" "" }}
|
||||
{{ else if in $linkFile "src-link/" }}
|
||||
{{ $linkFile = replace $linkFile "src-link/" "" }}
|
||||
{{ else }}
|
||||
{{ $linkFile = print "docs/content/" $linkFile }}
|
||||
{{ end }}
|
||||
|
||||
{{ range $elem_key, $elem_val := split $content "\n" }}
|
||||
{{if and (or (not $has_start_line) (ge (add $elem_key 1) ($start_line | int))) (or (not $has_end_line) (le (add $elem_key 1) ($end_line | int)))}}
|
||||
{{ $lines = $lines | append $elem_val }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="expressive-code">
|
||||
<figure class="frame not-content">
|
||||
{{ transform.Highlight (delimit $lines "\n" | safeHTML) (.Get "type" | default "go") }}
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<small class="smaller">Full source: [{{ $linkFile }}](https://github.com/ThreeDotsLabs/watermill/tree/master/{{ $linkFile }})</small>
|
||||
6
docs/layouts/shortcodes/readfile.html
Normal file
6
docs/layouts/shortcodes/readfile.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{{$file := .Get "file"}}
|
||||
{{- if eq (.Get "markdown") "true" -}}
|
||||
{{- $file | readFile | markdownify -}}
|
||||
{{- else -}}
|
||||
{{ $file | readFile | safeHTML }}
|
||||
{{- end -}}
|
||||
17
docs/layouts/shortcodes/tab.html
Normal file
17
docs/layouts/shortcodes/tab.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!--
|
||||
Source: https://github.com/alex-shpak/hugo-book/blob/master/layouts/shortcodes/tab.html
|
||||
-->
|
||||
|
||||
{{ if .Parent -}}
|
||||
{{ $name := .Get 0 }}
|
||||
{{ $slug := .Get 1 }}
|
||||
{{ $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 "Slug" $slug "Content" .Inner) }}
|
||||
{{ else -}}
|
||||
{{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }}
|
||||
{{ end -}}
|
||||
25
docs/layouts/shortcodes/tabs.html
Normal file
25
docs/layouts/shortcodes/tabs.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Based on: https://github.com/alex-shpak/hugo-book/blob/master/layouts/shortcodes/tabs.html
|
||||
-->
|
||||
|
||||
{{ if .Inner }}{{ end }}
|
||||
{{ $id := .Get 0 }}
|
||||
{{ $group := printf "tabs-%s" $id }}
|
||||
|
||||
<nav>
|
||||
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
||||
{{ range $index, $tab := .Scratch.Get $group -}}
|
||||
<button data-toggle-tab="{{ $tab.Slug }}" class="nav-link{{ if not $index }} active{{ end }}" id="{{ printf "%s-%d" $group $index }}-tab" data-bs-toggle="tab" data-bs-target="#{{ printf "%s-%d" $group $index }}" type="button" role="tab" aria-controls="{{ printf "%s-%d" $group $index }}" aria-selected="true">
|
||||
{{ $tab.Name -}}
|
||||
</button>
|
||||
{{ end -}}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
{{ range $index, $tab := .Scratch.Get $group -}}
|
||||
<div data-pane="{{ $tab.Slug }}" class="tab-pane fade{{ if not $index }} show active{{ end }}" id="{{ printf "%s-%d" $group $index }}" role="tabpanel" aria-labelledby="{{ printf "%s-%d" $group $index }}-tab" tabindex="0">
|
||||
{{ .Content | $.Page.RenderString -}}
|
||||
</div>
|
||||
{{ end -}}
|
||||
</div>
|
||||
Reference in New Issue
Block a user