mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
shortcode: make .context always a page #527
This commit is contained in:
parent
dc695da6a1
commit
77f41e9607
24 changed files with 40 additions and 40 deletions
|
@ -3,12 +3,12 @@
|
|||
{{- $pagefield := cond (ne $content nil) nil (.pagefield | default "Content") }}
|
||||
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
|
||||
{{- $langtrg := "pir" }}
|
||||
{{- $langsrc := cond (eq $context.Page.Lang $langtrg) (.langsrc | default "en") $context.Page.Lang }}
|
||||
{{- $langsrc := cond (eq $context.Lang $langtrg) (.langsrc | default "en") $context.Lang }}
|
||||
{{- $baseURL := urls.Parse site.BaseURL }}
|
||||
{{- $baseURLpath := $baseURL.Path | default "/" }}
|
||||
{{- $l := "" }}
|
||||
{{- $c := "" }}
|
||||
{{- range $context.Page.AllTranslations }}
|
||||
{{- range $context.AllTranslations }}
|
||||
{{- if eq .Language.Lang $langsrc }}
|
||||
{{- $l = .RelPermalink }}
|
||||
{{- if ne $content nil }}
|
||||
|
@ -21,10 +21,10 @@
|
|||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq $context.Page.Lang $langtrg }}
|
||||
{{- if eq $context.Lang $langtrg }}
|
||||
{{- if $writenotice }}
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
"context" .
|
||||
"context" $context
|
||||
"content" "<p>Fello' pirrrates, grog made us dizzy! Be awarrre <b>some stuff may not work</b> in this trrranslat'n. Like see'n <b>Merrrmaids</b>, do'n <b>math or chemistrrry</b>, writ'n docs and stuff.</p>\n"
|
||||
"icon" "skull-crossbones"
|
||||
"style" "warning"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{- partial "shortcodes/piratify.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"pagefield" "Content"
|
||||
"writenotice" (.Get "writenotice" | default (.Get 0))
|
||||
) }}
|
|
@ -21,23 +21,23 @@
|
|||
{{- end }}
|
||||
{{- $sort := .sort | default "asc" }}
|
||||
{{- $pattern := .pattern | default "" }}
|
||||
{{- $defaultUrlPrefix := strings.TrimRight "/" $context.Page.RelPermalink }}
|
||||
{{- $defaultUrlPrefix := strings.TrimRight "/" $context.RelPermalink }}
|
||||
{{- if .IsTranslated -}}
|
||||
{{- $defaultLanguage := (index $context.Site.Home.AllTranslations 0).Lang }}
|
||||
{{- $defaultLanguagePage := index (where $context.Page.AllTranslations "Language.Lang" $defaultLanguage) 0 }}
|
||||
{{- $defaultLanguagePage := index (where $context.AllTranslations "Language.Lang" $defaultLanguage) 0 }}
|
||||
{{- $defaultUrlPrefix = strings.TrimRight "/" $defaultLanguagePage.RelPermalink }}
|
||||
{{- end }}
|
||||
{{- $urlPrefix := strings.TrimRight "/" $context.Page.RelPermalink }}
|
||||
{{- $urlPrefix := strings.TrimRight "/" $context.RelPermalink }}
|
||||
{{- with $context }}
|
||||
<div class="box attachments cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}>
|
||||
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | markdownify }}</div>
|
||||
<ul class="box-content attachments-files">
|
||||
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileLink := printf "%s/%s" (.Language.ContentDir | default "content") .File.Dir }}
|
||||
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
|
||||
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileDir := printf "%s/%s" (.Language.ContentDir | default "content") .File.Dir }}
|
||||
{{- $fileDir = replace $fileDir "\\" "/" }}
|
||||
{{- $filesName := printf "%s.files" .Page.File.BaseFileName }}
|
||||
{{- if and (eq .Page.File.BaseFileName "index") (fileExists (printf "%sfiles" $fileDir)) }}
|
||||
{{- $filesName := printf "%s.files" .File.BaseFileName }}
|
||||
{{- if and (eq .File.BaseFileName "index") (fileExists (printf "%sfiles" $fileDir)) }}
|
||||
{{- $c := "" }}{{/* backward compat to < 5.9.0 behavior */}}
|
||||
{{- $filesName = "files" }}
|
||||
{{- end }}
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
{{- with $context }}
|
||||
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- $pages := .Pages }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- $currentOrdersectionsby := $sortTerm | default (.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 "context" . }}
|
||||
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
||||
|
@ -83,10 +83,10 @@
|
|||
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- $pages := .Pages }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- $currentOrdersectionsby := $.sortTerm | default (.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 "context" $context }}
|
||||
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{{- if eq (printf "%T" $expanded) "string" }}
|
||||
{{- $expanded = (eq $expanded "true") }}
|
||||
{{- end }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context.Page) .id }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
|
||||
{{- with $context }}
|
||||
<div class="expand">
|
||||
<input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
{{- $target := .target | default "" }}
|
||||
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }}
|
||||
{{- $target = "_blank" }}
|
||||
{{- if isset $context.Page.Site.Params "externallinktarget" }}
|
||||
{{- $target = $context.Page.Site.Params.externalLinkTarget }}
|
||||
{{- if isset $context.Site.Params "externallinktarget" }}
|
||||
{{- $target = $context.Site.Params.externalLinkTarget }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
<a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ $content | safeHTML }}</a>
|
|
@ -5,5 +5,5 @@
|
|||
<span class="math align-{{ $align }}">
|
||||
{{- $content | safeHTML -}}
|
||||
</span>
|
||||
{{- .Page.Store.Set "hasMathJax" true }}
|
||||
{{- .Store.Set "hasMathJax" true }}
|
||||
{{- end }}
|
|
@ -2,7 +2,7 @@
|
|||
{{- $content := .content }}
|
||||
{{- $align := .align | default "center" }}
|
||||
{{- $zoom := $context.Site.Params.mermaidZoom | default false }}
|
||||
{{- with $context.Page.Params.mermaidZoom }}
|
||||
{{- with $context.Params.mermaidZoom }}
|
||||
{{- $zoom = . }}
|
||||
{{- if eq (printf "%T" .) "string" }}
|
||||
{{- $zoom = (eq . "true") }}
|
||||
|
@ -18,5 +18,5 @@
|
|||
<div class="mermaid align-{{ $align }}{{ if $zoom }} zoom{{ end }}">
|
||||
{{- replaceRE "'" "'" ( replaceRE """ "\"" ( $content | safeHTML ) ) -}}
|
||||
</div>
|
||||
{{- .Page.Store.Set "hasMermaid" true }}
|
||||
{{- .Store.Set "hasMermaid" true }}
|
||||
{{- end }}
|
|
@ -1,8 +1,8 @@
|
|||
{{- $context := .context }}
|
||||
{{- $src := .src }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context.Page) .id }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
|
||||
{{- with $context }}
|
||||
{{- with .Page.Resources.Match $src }}
|
||||
{{- with .Resources.Match $src }}
|
||||
{{- range . }}
|
||||
{{- $src = .RelPermalink }}
|
||||
{{- end }}
|
||||
|
@ -14,5 +14,5 @@
|
|||
openapi-url="{{ $src }}"
|
||||
></div>
|
||||
</div>
|
||||
{{- .Page.Store.Set "hasOpenapi" true }}
|
||||
{{- .Store.Set "hasOpenapi" true }}
|
||||
{{- end }}
|
|
@ -1,4 +1,4 @@
|
|||
{{ warnf "DEPRECATED: Use shortcode openapi instead of swagger in %q" .context.Page.File.Path }}
|
||||
{{ warnf "DEPRECATED: Use shortcode openapi instead of swagger in %q" .context.File.Path }}
|
||||
{{- partial "shortcodes/openapi.html" (dict
|
||||
"context" .context
|
||||
"src" .src
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/attachments.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"color" (.Get "color")
|
||||
"content" .Inner
|
||||
"icon" (.Get "icon")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/badge.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"color" (.Get "color")
|
||||
"content" .Inner
|
||||
"icon" (.Get "icon")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/button.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"color" (.Get "color")
|
||||
"content" .Inner
|
||||
"href" (.Get "href")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/children.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"containerstyle" (.Get "containerstyle")
|
||||
"description" (.Get "description")
|
||||
"depth" (.Get "depth")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{- $id = .Ordinal }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/expand.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"content" .Inner
|
||||
"open" (.Get "open" | default (.Get 1))
|
||||
"title" (.Get "title" | default (.Get 0))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/icon.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"icon" (.Get "icon" | default (.Get 0))
|
||||
) }}
|
|
@ -1,5 +1,5 @@
|
|||
{{- partial "shortcodes/include.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"file" (.Get "file" | default (.Get 0))
|
||||
"hidefirstheading" (.Get "hidefirstheading" | default (.Get 1))
|
||||
) }}
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/math.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"content" .Inner
|
||||
"align" (.Get "align")
|
||||
) }}
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/mermaid.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"content" .Inner
|
||||
"align" (.Get "align")
|
||||
"zoom" (.Get "zoom")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"color" (.Get "color")
|
||||
"content" .Inner
|
||||
"icon" (.Get "icon" | default (.Get 2))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{{- $id = .Ordinal }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/openapi.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"src" (.Get "src")
|
||||
"id" $id
|
||||
) }}
|
|
@ -1,4 +1,4 @@
|
|||
{{- partial "shortcodes/siteparam.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"name" (.Get "name" | default (.Get 0))
|
||||
) }}
|
|
@ -6,7 +6,7 @@
|
|||
{{- $id = .Ordinal }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/swagger.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"src" (.Get "src")
|
||||
"id" $id
|
||||
) }}
|
|
@ -1,5 +1,5 @@
|
|||
{{- partial "shortcodes/tabs.html" (dict
|
||||
"context" .
|
||||
"context" .Page
|
||||
"content" .Inner
|
||||
"groupid" ((.Get "groupid") | default (.Get "groupId"))
|
||||
"tabs" (.Scratch.Get "tabs")
|
||||
|
|
Loading…
Reference in a new issue