diff --git a/tpl/tplimpl/embedded/templates/_hugo/build/js/batch-esm-runner.gotmpl b/tpl/tplimpl/embedded/templates/_hugo/build/js/batch-esm-runner.gotmpl index e1b3b9bc3..bea2cdf29 100644 --- a/tpl/tplimpl/embedded/templates/_hugo/build/js/batch-esm-runner.gotmpl +++ b/tpl/tplimpl/embedded/templates/_hugo/build/js/batch-esm-runner.gotmpl @@ -1,16 +1,16 @@ {{ range $i, $e := .Scripts -}} - {{ printf "import { %s as Script%d } from %q;" .Export $i .Import }} + {{ printf "import { %s as Script%d } from %q;" .Export $i .Import }} {{ end -}} {{ range $i, $e := .Runners }} - {{ printf "import { %s as Run%d } from %q;" .Export $i .Import }} + {{ printf "import { %s as Run%d } from %q;" .Export $i .Import }} {{ end }} {{/* */}} let scripts = []; {{ range $i, $e := .Scripts -}} - scripts.push({{ .RunnerJSON $i }}); + scripts.push({{ .RunnerJSON $i }}); {{ end -}} {{/* */}} {{ range $i, $e := .Runners }} - {{ $id := printf "Run%d" $i }} - {{ $id }}(scripts); + {{ $id := printf "Run%d" $i }} + {{ $id }}(scripts); {{ end }} diff --git a/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html b/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html index 35ec0b309..910617855 100644 --- a/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html +++ b/tpl/tplimpl/embedded/templates/_markup/render-codeblock-goat.html @@ -2,17 +2,17 @@ {{ $height := .Attributes.height }} {{ $class := .Attributes.class | default "" }}
- {{ with diagrams.Goat .Inner }} - - {{ .Inner }} - - {{ end }} + {{ with diagrams.Goat .Inner }} + + {{ .Inner }} + + {{ end }}
diff --git a/tpl/tplimpl/embedded/templates/_markup/render-image.html b/tpl/tplimpl/embedded/templates/_markup/render-image.html index d5040f6df..edb9eb988 100644 --- a/tpl/tplimpl/embedded/templates/_markup/render-image.html +++ b/tpl/tplimpl/embedded/templates/_markup/render-image.html @@ -1,23 +1,22 @@ {{- $u := urls.Parse .Destination -}} {{- $src := $u.String -}} {{- if not $u.IsAbs -}} - {{- $path := strings.TrimPrefix "./" $u.Path -}} - {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}} - {{- $src = .RelPermalink -}} - {{- with $u.RawQuery -}} - {{- $src = printf "%s?%s" $src . -}} - {{- end -}} - {{- with $u.Fragment -}} - {{- $src = printf "%s#%s" $src . -}} - {{- end -}} - {{- end -}} + {{- $path := strings.TrimPrefix "./" $u.Path -}} + {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}} + {{- $src = .RelPermalink -}} + {{- with $u.RawQuery -}} + {{- $src = printf "%s?%s" $src . -}} + {{- end -}} + {{- with $u.Fragment -}} + {{- $src = printf "%s#%s" $src . -}} + {{- end -}} + {{- end -}} {{- end -}} {{ .PlainText }} + {{- with .Title }} title="{{ . }}" {{- end -}} + {{- range $k, $v := .Attributes -}} + {{- if $v -}} + {{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr -}} + {{- end -}} + {{- end -}}> {{- /**/ -}} diff --git a/tpl/tplimpl/embedded/templates/_markup/render-link.html b/tpl/tplimpl/embedded/templates/_markup/render-link.html index 95e15aba4..ca8ee9938 100644 --- a/tpl/tplimpl/embedded/templates/_markup/render-link.html +++ b/tpl/tplimpl/embedded/templates/_markup/render-link.html @@ -1,22 +1,22 @@ {{- $u := urls.Parse .Destination -}} {{- $href := $u.String -}} {{- if strings.HasPrefix $u.String "#" -}} - {{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment -}} + {{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment -}} {{- else if and $href (not $u.IsAbs) -}} - {{- $path := strings.TrimPrefix "./" $u.Path -}} - {{- with or - ($.PageInner.GetPage $path) - ($.PageInner.Resources.Get $path) - (resources.Get $path) - -}} - {{- $href = .RelPermalink -}} - {{- with $u.RawQuery -}} - {{- $href = printf "%s?%s" $href . -}} - {{- end -}} - {{- with $u.Fragment -}} - {{- $href = printf "%s#%s" $href . -}} - {{- end -}} - {{- end -}} + {{- $path := strings.TrimPrefix "./" $u.Path -}} + {{- with or + ($.PageInner.GetPage $path) + ($.PageInner.Resources.Get $path) + (resources.Get $path) + -}} + {{- $href = .RelPermalink -}} + {{- with $u.RawQuery -}} + {{- $href = printf "%s?%s" $href . -}} + {{- end -}} + {{- with $u.Fragment -}} + {{- $href = printf "%s#%s" $href . -}} + {{- end -}} + {{- end -}} {{- end -}} {{ .Text }} {{- /**/ -}} diff --git a/tpl/tplimpl/embedded/templates/_markup/render-table.html b/tpl/tplimpl/embedded/templates/_markup/render-table.html index c43a72832..47f7b25dd 100644 --- a/tpl/tplimpl/embedded/templates/_markup/render-table.html +++ b/tpl/tplimpl/embedded/templates/_markup/render-table.html @@ -1,37 +1,35 @@ - - {{- range .THead }} - - {{- range . }} - - {{- end }} - - {{- end }} - - - {{- range .TBody }} - - {{- range . }} - - {{- end }} - - {{- end }} - + {{- range $k, $v := .Attributes }} + {{- if $v }} + {{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr }} + {{- end }} + {{- end }}> + + {{- range .THead }} + + {{- range . }} + + {{- end }} + + {{- end }} + + + {{- range .TBody }} + + {{- range . }} + + {{- end }} + + {{- end }} +
- {{- .Text -}} -
- {{- .Text -}} -
+ {{- .Text -}} +
+ {{- .Text -}} +
diff --git a/tpl/tplimpl/embedded/templates/_partials/_funcs/get-page-images.html b/tpl/tplimpl/embedded/templates/_partials/_funcs/get-page-images.html index bedf08c7a..6d730b85b 100644 --- a/tpl/tplimpl/embedded/templates/_partials/_funcs/get-page-images.html +++ b/tpl/tplimpl/embedded/templates/_partials/_funcs/get-page-images.html @@ -3,44 +3,50 @@ {{- $resources := .Resources.ByType "image" -}} {{/* Find featured image resources if the images parameter is empty. */}} {{- if not $imgParams }} - {{- $featured := $resources.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $resources.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{- with $featured }} - {{- $imgs = $imgs | append (dict - "Image" . - "RelPermalink" .RelPermalink - "Permalink" .Permalink) }} - {{- end }} + {{- $featured := $resources.GetMatch "*feature*" -}} + {{- if not $featured }}{{ $featured = $resources.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} + {{- with $featured }} + {{- $imgs = $imgs | append (dict + "Image" . + "RelPermalink" .RelPermalink + "Permalink" .Permalink + ) + }} + {{- end }} {{- end }} {{/* Use the first one of site images as the fallback. */}} {{- if and (not $imgParams) (not $imgs) }} - {{- with site.Params.images }} - {{- $imgParams = first 1 . }} - {{- end }} + {{- with site.Params.images }} + {{- $imgParams = first 1 . }} + {{- end }} {{- end }} {{/* Parse page's images parameter. */}} {{- range $imgParams }} - {{- $img := . }} - {{- $url := urls.Parse $img }} - {{- if eq $url.Scheme "" }} - {{/* Internal image: check page resources first, then global resources. */}} - {{- with or ($resources.GetMatch $img) (resources.GetMatch $img) -}} - {{- $imgs = $imgs | append (dict - "Image" . - "RelPermalink" .RelPermalink - "Permalink" .Permalink) }} - {{- else }} - {{- $imgs = $imgs | append (dict - "RelPermalink" (relURL $img) - "Permalink" (absURL $img) - ) }} - {{- end }} - {{- else }} - {{/* External image */}} - {{- $imgs = $imgs | append (dict - "RelPermalink" $img - "Permalink" $img - ) }} - {{- end }} + {{- $img := . }} + {{- $url := urls.Parse $img }} + {{- if eq $url.Scheme "" }} + {{/* Internal image: check page resources first, then global resources. */}} + {{- with or ($resources.GetMatch $img) (resources.GetMatch $img) -}} + {{- $imgs = $imgs | append (dict + "Image" . + "RelPermalink" .RelPermalink + "Permalink" .Permalink + ) + }} + {{- else }} + {{- $imgs = $imgs | append (dict + "RelPermalink" (relURL $img) + "Permalink" (absURL $img) + ) + }} + {{- end }} + {{- else }} + {{/* External image */}} + {{- $imgs = $imgs | append (dict + "RelPermalink" $img + "Permalink" $img + ) + }} + {{- end }} {{- end }} {{- return $imgs }} diff --git a/tpl/tplimpl/embedded/templates/_partials/disqus.html b/tpl/tplimpl/embedded/templates/_partials/disqus.html index fb7cbd0fe..64091e824 100644 --- a/tpl/tplimpl/embedded/templates/_partials/disqus.html +++ b/tpl/tplimpl/embedded/templates/_partials/disqus.html @@ -1,6 +1,6 @@ {{- $pc := .Site.Config.Privacy.Disqus -}} {{- if not $pc.Disable -}} -{{ if .Site.Config.Services.Disqus.Shortname }}
+ {{ if .Site.Config.Services.Disqus.Shortname }}
- -comments powered by Disqus{{end}} + + comments powered by Disqus + {{ end }} {{- end -}} diff --git a/tpl/tplimpl/embedded/templates/_partials/google_analytics.html b/tpl/tplimpl/embedded/templates/_partials/google_analytics.html index f16239321..08dd6fdf4 100644 --- a/tpl/tplimpl/embedded/templates/_partials/google_analytics.html +++ b/tpl/tplimpl/embedded/templates/_partials/google_analytics.html @@ -1,8 +1,8 @@ {{ if not site.Config.Privacy.GoogleAnalytics.Disable }} - {{- with site.Config.Services.GoogleAnalytics.ID }} - {{- if strings.HasPrefix (lower .) "ua-" }} - {{- warnf "Google Analytics 4 (GA4) replaced Google Universal Analytics (UA) effective 1 July 2023. See https://support.google.com/analytics/answer/11583528. Create a GA4 property and data stream, then replace the Google Analytics ID in your project configuration with the new value." }} - {{- else }} + {{- with site.Config.Services.GoogleAnalytics.ID }} + {{- if strings.HasPrefix (lower .) "ua-" }} + {{- warnf "Google Analytics 4 (GA4) replaced Google Universal Analytics (UA) effective 1 July 2023. See https://support.google.com/analytics/answer/11583528. Create a GA4 property and data stream, then replace the Google Analytics ID in your project configuration with the new value." }} + {{- else }} - {{- end }} - {{- end }} + {{- end }} + {{- end }} {{- end -}} diff --git a/tpl/tplimpl/embedded/templates/_partials/opengraph.html b/tpl/tplimpl/embedded/templates/_partials/opengraph.html index 8705b53a3..a5578f4da 100644 --- a/tpl/tplimpl/embedded/templates/_partials/opengraph.html +++ b/tpl/tplimpl/embedded/templates/_partials/opengraph.html @@ -1,74 +1,74 @@ {{- with or site.Title site.Params.title | plainify }} - + {{- end }} {{- with or .Title site.Title site.Params.title | plainify }} - + {{- end }} {{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }} - + {{- end }} {{- with or .Params.locale site.Language.Locale }} - + {{- end }} {{- if .IsPage }} - - {{- with .Section }} - - {{- end }} - {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }} - {{- with .PublishDate }} - - {{- end }} - {{- with .Lastmod }} - - {{- end }} - {{- range .GetTerms "tags" | first 6 }} - - {{- end }} + + {{- with .Section }} + + {{- end }} + {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }} + {{- with .PublishDate }} + + {{- end }} + {{- with .Lastmod }} + + {{- end }} + {{- range .GetTerms "tags" | first 6 }} + + {{- end }} {{- else }} - + {{- end }} {{- with partial "_funcs/get-page-images" . }} - {{- range . | first 6 }} - - {{- end }} + {{- range . | first 6 }} + + {{- end }} {{- end }} {{- with .Params.audio }} - {{- range . | first 6 }} - - {{- end }} + {{- range . | first 6 }} + + {{- end }} {{- end }} {{- with .Params.videos }} - {{- range . | first 6 }} - - {{- end }} + {{- range . | first 6 }} + + {{- end }} {{- end }} {{- range .GetTerms "series" }} - {{- range .Pages | first 7 }} - {{- if ne $ . }} - - {{- end }} - {{- end }} + {{- range .Pages | first 7 }} + {{- if ne $ . }} + + {{- end }} + {{- end }} {{- end }} {{- with site.Params.social }} - {{- if reflect.IsMap . }} - {{- with .facebook_app_id }} - - {{- else }} - {{- with .facebook_admin }} - - {{- end }} - {{- end }} - {{- end }} + {{- if reflect.IsMap . }} + {{- with .facebook_app_id }} + + {{- else }} + {{- with .facebook_admin }} + + {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/tpl/tplimpl/embedded/templates/_partials/pagination.html b/tpl/tplimpl/embedded/templates/_partials/pagination.html index 995ac5680..23123793d 100644 --- a/tpl/tplimpl/embedded/templates/_partials/pagination.html +++ b/tpl/tplimpl/embedded/templates/_partials/pagination.html @@ -7,148 +7,148 @@ {{- $format := "default" }} {{- if reflect.IsMap . }} - {{- with .page }} - {{- $page = . }} - {{- else }} - {{- errorf $msg1 }} - {{- end }} - {{- with .format }} - {{- $format = lower . }} - {{- end }} + {{- with .page }} + {{- $page = . }} + {{- else }} + {{- errorf $msg1 }} + {{- end }} + {{- with .format }} + {{- $format = lower . }} + {{- end }} {{- end }} {{- if in $validFormats $format }} - {{- if gt $page.Paginator.TotalPages 1 }} - - {{- end }} + {{- if gt $page.Paginator.TotalPages 1 }} + + {{- end }} {{- else }} - {{- errorf $msg2 (delimit $validFormats ", ") }} + {{- errorf $msg2 (delimit $validFormats ", ") }} {{- end -}} {{/* Format: default {{/* --------------------------------------------------------------------- */}} {{- define "_partials/inline/pagination/default.html" }} - {{- with .Paginator }} - {{- $currentPageNumber := .PageNumber }} +{{- with .Paginator }} + {{- $currentPageNumber := .PageNumber }} - {{- with .First }} - {{- if ne $currentPageNumber .PageNumber }} -
  • - -
  • - {{- else }} -
  • - -
  • - {{- end }} - {{- end }} + {{- with .First }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} + {{- end }} - {{- with .Prev }} -
  • - -
  • - {{- else }} -
  • - -
  • - {{- end }} + {{- with .Prev }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} - {{- $slots := 5 }} - {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} - {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} - {{- if lt (add (sub $end $start) 1) $slots }} - {{- $start = math.Max 1 (add (sub $end $slots) 1) }} - {{- end }} + {{- $slots := 5 }} + {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} + {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} + {{- if lt (add (sub $end $start) 1) $slots }} + {{- $start = math.Max 1 (add (sub $end $slots) 1) }} + {{- end }} - {{- range $k := seq $start $end }} - {{- if eq $.Paginator.PageNumber $k }} -
  • - {{ $k }} -
  • - {{- else }} -
  • - {{ $k }} -
  • - {{- end }} - {{- end }} + {{- range $k := seq $start $end }} + {{- if eq $.Paginator.PageNumber $k }} +
  • + {{ $k }} +
  • + {{- else }} +
  • + {{ $k }} +
  • + {{- end }} + {{- end }} - {{- with .Next }} -
  • - -
  • - {{- else }} -
  • - -
  • - {{- end }} + {{- with .Next }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} - {{- with .Last }} - {{- if ne $currentPageNumber .PageNumber }} -
  • - -
  • - {{- else }} -
  • - -
  • - {{- end }} - {{- end }} - {{- end }} + {{- with .Last }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- else }} +
  • + +
  • + {{- end }} + {{- end }} +{{- end }} {{- end -}} {{/* Format: terse {{/* --------------------------------------------------------------------- */}} {{- define "_partials/inline/pagination/terse.html" }} - {{- with .Paginator }} - {{- $currentPageNumber := .PageNumber }} +{{- with .Paginator }} + {{- $currentPageNumber := .PageNumber }} - {{- with .First }} - {{- if ne $currentPageNumber .PageNumber }} -
  • - -
  • - {{- end }} - {{- end }} + {{- with .First }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- end }} + {{- end }} - {{- with .Prev }} -
  • - -
  • - {{- end }} + {{- with .Prev }} +
  • + +
  • + {{- end }} - {{- $slots := 3 }} - {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} - {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} - {{- if lt (add (sub $end $start) 1) $slots }} - {{- $start = math.Max 1 (add (sub $end $slots) 1) }} - {{- end }} + {{- $slots := 3 }} + {{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }} + {{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }} + {{- if lt (add (sub $end $start) 1) $slots }} + {{- $start = math.Max 1 (add (sub $end $slots) 1) }} + {{- end }} - {{- range $k := seq $start $end }} - {{- if eq $.Paginator.PageNumber $k }} -
  • - {{ $k }} -
  • - {{- else }} -
  • - {{ $k }} -
  • - {{- end }} - {{- end }} + {{- range $k := seq $start $end }} + {{- if eq $.Paginator.PageNumber $k }} +
  • + {{ $k }} +
  • + {{- else }} +
  • + {{ $k }} +
  • + {{- end }} + {{- end }} - {{- with .Next }} -
  • - -
  • - {{- end }} + {{- with .Next }} +
  • + +
  • + {{- end }} - {{- with .Last }} - {{- if ne $currentPageNumber .PageNumber }} -
  • - -
  • - {{- end }} - {{- end }} - {{- end }} + {{- with .Last }} + {{- if ne $currentPageNumber .PageNumber }} +
  • + +
  • + {{- end }} + {{- end }} +{{- end }} {{- end -}} diff --git a/tpl/tplimpl/embedded/templates/_partials/schema.html b/tpl/tplimpl/embedded/templates/_partials/schema.html index 36c01178b..36895c2a3 100644 --- a/tpl/tplimpl/embedded/templates/_partials/schema.html +++ b/tpl/tplimpl/embedded/templates/_partials/schema.html @@ -1,27 +1,27 @@ {{- with or .Title site.Title | plainify }} - + {{- end }} {{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }} - + {{- end }} {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }} {{- with .PublishDate }} - + {{- end }} {{- with .Lastmod }} - + {{- end }} {{- with .WordCount }} - + {{- end }} {{- $images := partial "_funcs/get-page-images" . }} {{- range first 6 $images }} - + {{- end }} {{- /* @@ -35,22 +35,22 @@ Keywords precedence: */}} {{- $keywords := slice }} {{- range .GetTerms "keywords" }} - {{- $keywords = $keywords | append .Title }} + {{- $keywords = $keywords | append .Title }} {{- else }} - {{- with .Keywords }} - {{- $keywords = . }} - {{- else }} - {{- range .GetTerms "tags" }} - {{- $keywords = $keywords | append .Title }} - {{- else }} - {{- range $taxonomy, $_ := site.Taxonomies }} - {{- range $.GetTerms $taxonomy }} - {{- $keywords = $keywords | append .Title }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} + {{- with .Keywords }} + {{- $keywords = . }} + {{- else }} + {{- range .GetTerms "tags" }} + {{- $keywords = $keywords | append .Title }} + {{- else }} + {{- range $taxonomy, $_ := site.Taxonomies }} + {{- range $.GetTerms $taxonomy }} + {{- $keywords = $keywords | append .Title }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- end }} {{- with $keywords }} - + {{- end -}} diff --git a/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html b/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html index 8af0e986c..cfe240635 100644 --- a/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html +++ b/tpl/tplimpl/embedded/templates/_partials/twitter_cards.html @@ -1,28 +1,28 @@ {{- $images := partial "_funcs/get-page-images" . }} {{- with index $images 0 }} - - + + {{- else }} - + {{- end }} {{- with or .Title site.Title site.Params.title | plainify }} - + {{- end }} {{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }} - + {{- end }} {{- $twitterSite := "" }} {{- with site.Params.social }} - {{- if reflect.IsMap . }} - {{- with .twitter }} - {{- $content := . }} - {{- if not (strings.HasPrefix . "@") }} - {{- $content = printf "@%v" . }} - {{- end }} - - {{- end }} - {{- end }} + {{- if reflect.IsMap . }} + {{- with .twitter }} + {{- $content := . }} + {{- if not (strings.HasPrefix . "@") }} + {{- $content = printf "@%v" . }} + {{- end }} + + {{- end }} + {{- end }} {{- end }} diff --git a/tpl/tplimpl/embedded/templates/_server/error.html b/tpl/tplimpl/embedded/templates/_server/error.html index 9f62363ac..84d53a11f 100644 --- a/tpl/tplimpl/embedded/templates/_server/error.html +++ b/tpl/tplimpl/embedded/templates/_server/error.html @@ -1,8 +1,8 @@ - - - Hugo Server: Error + + + Hugo Server: Error - - -
    - {{ $codeStyle := "dracula" }} -
    - {{ highlight .Error "apl" (printf "linenos=false,noclasses=true,style=%s" $codeStyle ) }} -
    -
    - {{ range $i, $e := .Files }} - {{ if not .ErrorContext }} - {{ continue }} - {{ end }} - {{ $params := printf "noclasses=true,style=%s,linenos=table,hl_lines=%d,linenostart=%d" $codeStyle (add .ErrorContext.LinesPos 1) (sub .Position.LineNumber .ErrorContext.LinesPos) }} - {{ $lexer := .ErrorContext.ChromaLexer | default "go-html-template" }} - {{ with .Position }} - {{ printf "%s:%d:%d" .Filename .LineNumber .ColumnNumber }}: - {{ end }} - {{ highlight (delimit .ErrorContext.Lines "\n") $lexer $params }} -
    - {{ end }} -

    {{ .Version }}

    - Reload Page -
    - + + +
    + {{ $codeStyle := "dracula" }} +
    + {{ highlight .Error "apl" (printf "linenos=false,noclasses=true,style=%s" $codeStyle) }} +
    +
    + {{ range $i, $e := .Files }} + {{ if not .ErrorContext }} + {{ continue }} + {{ end }} + {{ $params := printf "noclasses=true,style=%s,linenos=table,hl_lines=%d,linenostart=%d" $codeStyle (add .ErrorContext.LinesPos 1) (sub .Position.LineNumber .ErrorContext.LinesPos) }} + {{ $lexer := .ErrorContext.ChromaLexer | default "go-html-template" }} + {{ with .Position }} + {{ printf "%s:%d:%d" .Filename .LineNumber .ColumnNumber }}: + {{ end }} + {{ highlight (delimit .ErrorContext.Lines "\n") $lexer $params }} +
    + {{ end }} +

    {{ .Version }}

    + Reload Page +
    + diff --git a/tpl/tplimpl/embedded/templates/_shortcodes/1__h_simple_assets.html b/tpl/tplimpl/embedded/templates/_shortcodes/1__h_simple_assets.html index da1bb82eb..cd0fede2b 100644 --- a/tpl/tplimpl/embedded/templates/_shortcodes/1__h_simple_assets.html +++ b/tpl/tplimpl/embedded/templates/_shortcodes/1__h_simple_assets.html @@ -1,7 +1,7 @@ {{ define "__h_simple_css" }}{{/* These template definitions are global. */}} {{- if not (.Page.Scratch.Get "__h_simple_css") -}} -{{/* Only include once */}} -{{- .Page.Scratch.Set "__h_simple_css" true -}} + {{/* Only include once */}} + {{- .Page.Scratch.Set "__h_simple_css" true -}} - {{- end -}} +{{- end -}} {{- end -}} diff --git a/tpl/tplimpl/embedded/templates/_shortcodes/youtube.html b/tpl/tplimpl/embedded/templates/_shortcodes/youtube.html index 18b086944..041ccb66a 100644 --- a/tpl/tplimpl/embedded/templates/_shortcodes/youtube.html +++ b/tpl/tplimpl/embedded/templates/_shortcodes/youtube.html @@ -24,104 +24,102 @@ Renders an embedded YouTube video. {{- $pc := .Page.Site.Config.Privacy.YouTube }} {{- $remoteErrID := "err-youtube-remote" }} {{- if not $pc.Disable }} - {{- with $id := or (.Get "id") (.Get 0) }} + {{- with $id := or (.Get "id") (.Get 0) }} - {{- /* Set defaults. */}} - {{- $allowFullScreen := true }} - {{- $autoplay := 0 }} - {{- $class := "" }} - {{- $controls := 1 }} - {{- $end := 0 }} - {{- $loading := "eager" }} - {{- $loop := 0 }} - {{- $mute := 0 }} - {{- $start := 0 }} - {{- $title := "YouTube video" }} - {{- $iframeAllowList := "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" }} + {{- /* Set defaults. */}} + {{- $allowFullScreen := true }} + {{- $autoplay := 0 }} + {{- $class := "" }} + {{- $controls := 1 }} + {{- $end := 0 }} + {{- $loading := "eager" }} + {{- $loop := 0 }} + {{- $mute := 0 }} + {{- $start := 0 }} + {{- $title := "YouTube video" }} + {{- $iframeAllowList := "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" }} - {{- /* Get arguments. */}} - {{- if in (slice "true" true 1) ($.Get "allowFullScreen") }} - {{- $allowFullScreen = true }} - {{- else if in (slice "false" false 0) ($.Get "allowFullScreen") }} - {{- $allowFullScreen = false }} - {{- end }} - {{- if in (slice "true" true 1) ($.Get "autoplay") }} - {{- $autoplay = 1 }} - {{- else if in (slice "false" false 0) ($.Get "autoplay") }} - {{- $autoplay = 0 }} - {{- end }} - {{- if in (slice "true" true 1) ($.Get "controls") }} - {{- $controls = 1 }} - {{- else if in (slice "false" false 0) ($.Get "controls") }} - {{- $controls = 0 }} - {{- end }} - {{- if in (slice "true" true 1) ($.Get "loop") }} - {{- $loop = 1 }} - {{- else if in (slice "false" false 0) ($.Get "loop") }} - {{- $loop = 0 }} - {{- end }} - {{- if or (in (slice "true" true 1) ($.Get "mute")) $autoplay }} - {{- $mute = 1 }} - {{- else if in (slice "false" false 0) ($.Get "mute") }} - {{- $mute = 0 }} - {{- end }} - {{- $class := or ($.Get "class") $class }} - {{- $end := or ($.Get "end") $end }} - {{- $loading := or ($.Get "loading") $loading }} - {{- $start := or ($.Get "start") $start }} - {{- $title := or ($.Get "title") $title }} + {{- /* Get arguments. */}} + {{- if in (slice "true" true 1) ($.Get "allowFullScreen") }} + {{- $allowFullScreen = true }} + {{- else if in (slice "false" false 0) ($.Get "allowFullScreen") }} + {{- $allowFullScreen = false }} + {{- end }} + {{- if in (slice "true" true 1) ($.Get "autoplay") }} + {{- $autoplay = 1 }} + {{- else if in (slice "false" false 0) ($.Get "autoplay") }} + {{- $autoplay = 0 }} + {{- end }} + {{- if in (slice "true" true 1) ($.Get "controls") }} + {{- $controls = 1 }} + {{- else if in (slice "false" false 0) ($.Get "controls") }} + {{- $controls = 0 }} + {{- end }} + {{- if in (slice "true" true 1) ($.Get "loop") }} + {{- $loop = 1 }} + {{- else if in (slice "false" false 0) ($.Get "loop") }} + {{- $loop = 0 }} + {{- end }} + {{- if or (in (slice "true" true 1) ($.Get "mute")) $autoplay }} + {{- $mute = 1 }} + {{- else if in (slice "false" false 0) ($.Get "mute") }} + {{- $mute = 0 }} + {{- end }} + {{- $class := or ($.Get "class") $class }} + {{- $end := or ($.Get "end") $end }} + {{- $loading := or ($.Get "loading") $loading }} + {{- $start := or ($.Get "start") $start }} + {{- $title := or ($.Get "title") $title }} - {{- /* Adjust iframeAllowList. */}} - {{- if $allowFullScreen }} - {{- $iframeAllowList = printf "%s; fullscreen" $iframeAllowList }} - {{- end }} + {{- /* Adjust iframeAllowList. */}} + {{- if $allowFullScreen }} + {{- $iframeAllowList = printf "%s; fullscreen" $iframeAllowList }} + {{- end }} - {{- /* Define src attribute. */}} - {{- $host := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" }} - {{- $src := printf "https://%s/embed/%s" $host $id }} - {{- $params := dict - "autoplay" $autoplay - "controls" $controls - "end" $end - "mute" $mute - "start" $start - "loop" $loop - }} - {{- if $loop }} - {{- $params = merge $params (dict "playlist" $id) }} - {{- end }} - {{- with querify $params }} - {{- $src = printf "%s?%s" $src . }} - {{- end }} + {{- /* Define src attribute. */}} + {{- $host := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" }} + {{- $src := printf "https://%s/embed/%s" $host $id }} + {{- $params := dict + "autoplay" $autoplay + "controls" $controls + "end" $end + "mute" $mute + "start" $start + "loop" $loop + }} + {{- if $loop }} + {{- $params = merge $params (dict "playlist" $id) }} + {{- end }} + {{- with querify $params }} + {{- $src = printf "%s?%s" $src . }} + {{- end }} - {{- /* Set div attributes. */}} - {{- $divStyle := "position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;" }} - {{- if $class }} - {{- $divStyle = "" }} - {{- end }} + {{- /* Set div attributes. */}} + {{- $divStyle := "position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;" }} + {{- if $class }} + {{- $divStyle = "" }} + {{- end }} - {{- /* Set iframe attributes. */}} - {{- $iframeStyle := "position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" }} - {{- if $class }} - {{- $iframeStyle = "" }} - {{- end }} - {{- $referrerpolicy := "strict-origin-when-cross-origin" }} + {{- /* Set iframe attributes. */}} + {{- $iframeStyle := "position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" }} + {{- if $class }} + {{- $iframeStyle = "" }} + {{- end }} + {{- $referrerpolicy := "strict-origin-when-cross-origin" }} - {{- /* Render. */ -}} -
    - -
    - {{- else }} - {{- errorf "The %q shortcode requires an id argument. See %s" .Name .Position }} - {{- end }} + {{- /* Render. */ -}} +
    + +
    + {{- else }} + {{- errorf "The %q shortcode requires an id argument. See %s" .Name .Position }} + {{- end }} {{- end }} diff --git a/tpl/tplimpl/embedded/templates/alias.html b/tpl/tplimpl/embedded/templates/alias.html index ea1e4df11..94dcf9dfe 100644 --- a/tpl/tplimpl/embedded/templates/alias.html +++ b/tpl/tplimpl/embedded/templates/alias.html @@ -1,9 +1,9 @@ - - {{ .Permalink }} - {{ with .OutputFormats.Canonical }}{{ end }} - - - + + {{ .Permalink }} + {{ with .OutputFormats.Canonical }}{{ end }} + + + diff --git a/tpl/tplimpl/embedded/templates/rss.xml b/tpl/tplimpl/embedded/templates/rss.xml index d9e7815b1..2314f42f3 100644 --- a/tpl/tplimpl/embedded/templates/rss.xml +++ b/tpl/tplimpl/embedded/templates/rss.xml @@ -1,59 +1,67 @@ {{- $authorEmail := "" }} {{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .email }} - {{- $authorEmail = . }} - {{- end }} - {{- end }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} {{- end }} {{- $authorName := "" }} {{- with site.Params.author }} - {{- if reflect.IsMap . }} - {{- with .name }} - {{- $authorName = . }} - {{- end }} - {{- else }} - {{- $authorName = . }} - {{- end }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} {{- end }} {{- $pctx := . }} {{- if .IsHome }}{{ $pctx = .Site }}{{ end }} {{- $pages := slice }} {{- if or $.IsHome $.IsSection }} -{{- $pages = $pctx.RegularPages }} + {{- $pages = $pctx.RegularPages }} {{- else }} -{{- $pages = $pctx.Pages }} + {{- $pages = $pctx.Pages }} {{- end }} {{- $limit := .Site.Config.Services.RSS.Limit }} {{- if ge $limit 1 }} -{{- $pages = $pages | first $limit }} + {{- $pages = $pages | first $limit }} {{- end }} {{- printf "" | safeHTML }} - - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} - {{ .Permalink }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} - Hugo - {{ site.Language.Locale }}{{ with $authorEmail }} - {{.}}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} - {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} - {{ . }}{{ end }}{{ if not .Date.IsZero }} - {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end }} - {{- range $pages }} - - {{ .Title }} - {{ .Permalink }} - {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} - {{ .Permalink }} - {{ .Summary | transform.XMLEscape | safeHTML }} - - {{- end }} - + + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo + {{ site.Language.Locale }} + {{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }} + {{ end }} + {{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }} + {{ end }} + {{ with .Site.Copyright }} + {{ . }} + {{ end }} + {{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ end }} + {{- with .OutputFormats.Get "RSS" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end }} + {{- range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} + {{ .Permalink }} + {{ .Summary | transform.XMLEscape | safeHTML }} + + {{- end }} + diff --git a/tpl/tplimpl/embedded/templates/sitemap.xml b/tpl/tplimpl/embedded/templates/sitemap.xml index 98a5594e5..d3539b190 100644 --- a/tpl/tplimpl/embedded/templates/sitemap.xml +++ b/tpl/tplimpl/embedded/templates/sitemap.xml @@ -1,3 +1,4 @@ +{{/* gotmplfmt-ignore-all */}} {{ printf "" | safeHTML }} diff --git a/tpl/tplimpl/embedded/templates/sitemapindex.xml b/tpl/tplimpl/embedded/templates/sitemapindex.xml index d6eec055d..60cbcced4 100644 --- a/tpl/tplimpl/embedded/templates/sitemapindex.xml +++ b/tpl/tplimpl/embedded/templates/sitemapindex.xml @@ -1,11 +1,11 @@ {{ printf "" | safeHTML }} - {{ range . }} - - {{ .SitemapAbsURL }} - {{ if not .Lastmod.IsZero }} - {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ end }} - - {{ end }} + {{ range . }} + + {{ .SitemapAbsURL }} + {{ if not .Lastmod.IsZero }} + {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }} + {{ end }} + + {{ end }} diff --git a/tpl/tplimpl/shortcodes_integration_test.go b/tpl/tplimpl/shortcodes_integration_test.go index 32edbe52d..bd6f676ee 100644 --- a/tpl/tplimpl/shortcodes_integration_test.go +++ b/tpl/tplimpl/shortcodes_integration_test.go @@ -122,7 +122,7 @@ Content: {{ .Content }} ` b := hugolib.Test(t, files) - b.AssertFileContent("public/index.html", "35b077dcb9887a84") + b.AssertFileContent("public/index.html", "c18e12c59a2f9bdb") } func TestHighlightShortcode(t *testing.T) { @@ -237,12 +237,12 @@ Content: {{ .Content }} // Regular mode b := hugolib.Test(t, files) - b.AssertFileContent("public/index.html", "6e93404b93277876") + b.AssertFileContent("public/index.html", "336bb64b13c24575") // Simple mode files = strings.ReplaceAll(files, "privacy.instagram.simple = false", "privacy.instagram.simple = true") b = hugolib.Test(t, files) - b.AssertFileContent("public/index.html", "2c1dce3881be0513") + b.AssertFileContent("public/index.html", "4c094707f37b2340") } func TestParamShortcode(t *testing.T) { @@ -469,14 +469,14 @@ Content: {{ .Content }} // Regular mode b := hugolib.Test(t, files) - b.AssertFileContent("public/p1/index.html", "31c54d7f8c54f73d") - b.AssertFileContent("public/p2/index.html", "31c54d7f8c54f73d") - b.AssertFileContent("public/p3/index.html", "7c073565f380599b") + b.AssertFileContent("public/p1/index.html", "2144844b57ee39d8") + b.AssertFileContent("public/p2/index.html", "2144844b57ee39d8") + b.AssertFileContent("public/p3/index.html", "a131e93ce53bc318") // Simple mode files = strings.ReplaceAll(files, "privacy.vimeo.simple = false", "privacy.vimeo.simple = true") b = hugolib.Test(t, files) - b.AssertFileContent("public/p1/index.html", "fb22905d5b100a5a") + b.AssertFileContent("public/p1/index.html", "582bde2225dc43c0") // Simple mode with non-existent id files = strings.ReplaceAll(files, "{{< vimeo 19899678 >}}", "{{< vimeo __id_does_not_exist__ >}}") @@ -587,14 +587,14 @@ title: p2 b := hugolib.Test(t, files) - b.AssertFileContent("public/p1/index.html", "4b54bf9bd03946ec") - b.AssertFileContent("public/p2/index.html", "289c655e727e596c") + b.AssertFileContent("public/p1/index.html", "365fe481b0377cd9") + b.AssertFileContent("public/p2/index.html", "82d7f05fb1fefb3b") files = strings.ReplaceAll(files, "privacy.youtube.privacyEnhanced = false", "privacy.youtube.privacyEnhanced = true") b = hugolib.Test(t, files) - b.AssertFileContent("public/p1/index.html", "78eb19b5c6f3768f") - b.AssertFileContent("public/p2/index.html", "a6db910a9cf54bc1") + b.AssertFileContent("public/p1/index.html", "48398992f5ff0afc") + b.AssertFileContent("public/p2/index.html", "116436ffc3f62191") } func TestShortcodePlainTextVsHTMLTemplateIssue13698(t *testing.T) {