{{ with .CurrentSection.OutputFormats.Get "rss" -}} - + {{ end -}} diff --git a/layouts/blog/baseof.print.html b/layouts/blog/baseof.print.html index 99e3c1c4d1..21e63c5f79 100644 --- a/layouts/blog/baseof.print.html +++ b/layouts/blog/baseof.print.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/blog/content.html b/layouts/blog/content.html index c74806a6f8..dbb6559135 100644 --- a/layouts/blog/content.html +++ b/layouts/blog/content.html @@ -3,20 +3,21 @@

{{ .Title }}

{{ with .Params.description }}
{{ . | markdownify }}
{{ end }} {{ .Content }} - {{ if (.Site.Params.DisqusShortname) }} + {{ if (.Site.Config.Services.Disqus.Shortname) -}}
- {{ partial "disqus-comment.html" . }} + {{- partial "disqus-comment.html" . -}}
- {{ end }} + {{ end -}} {{ partial "pager.html" . }} + {{ partial "page-meta-lastmod.html" . -}} diff --git a/layouts/blog/list.html b/layouts/blog/list.html index 4c95d2206f..43f536ae9c 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -8,14 +8,14 @@
{{ if .Pages -}} {{ $pag := .Paginate (( $.Scratch.Get "blog-pages").GroupByDate "2006" ) -}} - {{ range $pag.PageGroups }} + {{ range $pag.PageGroups -}}
{{ T "post_posts_in" }} {{ .Key }}
    - {{ range .Pages }} + {{ range .Pages -}}
  • {{ .Title }}
    -

    {{ .Date.Format ($.Param "time_format_blog") }} {{ T "ui_in"}} {{ .CurrentSection.LinkTitle }}

    +

    {{ .Date.Format ($.Param "time_format_blog") }} {{ T "ui_in"}} {{ .CurrentSection.LinkTitle }}

    -{{ end }} +{{ end -}} diff --git a/layouts/partials/breadcrumb.html b/layouts/partials/breadcrumb.html index 6bd3e2bc76..d01224a2ac 100644 --- a/layouts/partials/breadcrumb.html +++ b/layouts/partials/breadcrumb.html @@ -23,7 +23,7 @@ {{ if $isActive -}} {{ .p1.LinkTitle -}} {{ else -}} - {{ .p1.LinkTitle }} + {{ .p1.LinkTitle }} {{- end -}}
  • {{- end -}} diff --git a/layouts/partials/community_links.html b/layouts/partials/community_links.html index 690e19b539..4f0505ebc2 100644 --- a/layouts/partials/community_links.html +++ b/layouts/partials/community_links.html @@ -16,7 +16,7 @@

    {{ T "community_develop" }}

    {{ end }}

    {{ T "community_how_to" . }} - {{ T "community_guideline" }}. + {{ T "community_guideline" }}.

diff --git a/layouts/partials/disqus-comment.html b/layouts/partials/disqus-comment.html index c3ae3f91b3..f7406c4848 100644 --- a/layouts/partials/disqus-comment.html +++ b/layouts/partials/disqus-comment.html @@ -14,7 +14,7 @@ */ (function() { // DON'T EDIT BELOW THIS LINE var d = document, s = d.createElement('script'); -s.src = 'https://' + {{ .Site.DisqusShortname }} + '.disqus.com/embed.js'; +s.src = 'https://' + {{ .Site.Config.Services.Disqus.Shortname }} + '.disqus.com/embed.js'; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); })(); diff --git a/layouts/partials/featured-image.html b/layouts/partials/featured-image.html index 99b7ca093b..156a53b70a 100644 --- a/layouts/partials/featured-image.html +++ b/layouts/partials/featured-image.html @@ -8,7 +8,7 @@
Featured Image for {{ $p.Title }} {{ with $image.Params.byline }} -
{{ . | html }}
+
{{ . | html }}
{{ end }}
{{ end }} \ No newline at end of file diff --git a/layouts/partials/feedback.html b/layouts/partials/feedback.html index 20f5e46774..438edc423d 100644 --- a/layouts/partials/feedback.html +++ b/layouts/partials/feedback.html @@ -1,3 +1,5 @@ +{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable)) -}} +{{ with .Site.Params.ui.feedback -}}
- - - - + + + + @@ -35,21 +37,18 @@ noButton.disabled = true; }; const sendFeedback = (value) => { - if (typeof ga !== 'function') return; - const args = { - command: 'send', - hitType: 'event', - category: 'Helpful', - action: 'click', - label: window.location.pathname, - value: value - }; - ga(args.command, args.hitType, args.category, args.action, args.label, args.value); + if (typeof gtag !== 'function') return; + gtag('event', 'page_helpful', { + 'event_category': 'Helpful', + 'event_label': window.location.pathname, + 'value': value + }); }; yesButton.addEventListener('click', () => { yesResponse.classList.add('feedback--response__visible'); disableButtons(); - sendFeedback(1); + {{ $maxValue := .max_value | default 100 -}} + sendFeedback({{ $maxValue }}); }); noButton.addEventListener('click', () => { noResponse.classList.add('feedback--response__visible'); @@ -57,3 +56,6 @@ sendFeedback(0); }); +{{ end -}} +
+{{ end -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index b652549f2f..c61969b488 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,46 +1,17 @@ -{{ $links := .Site.Params.links -}}
-
- {{ with $links }} - {{ with index . "user" }} - {{ template "footer-links-block" . }} - {{ end }} - {{ end }} + -
- {{ with $links }} - {{ with index . "developer" }} - {{ template "footer-links-block" . }} - {{ end }} - {{ end }} + {{- /* Trim WS */ -}} + -
- -{{- define "footer-links-block" }} - -{{ end -}} diff --git a/layouts/partials/footer/center.html b/layouts/partials/footer/center.html new file mode 100644 index 0000000000..a12ada49cf --- /dev/null +++ b/layouts/partials/footer/center.html @@ -0,0 +1,15 @@ +{{ partial "footer/copyright.html" . -}} + +{{ with .Site.Params.privacy_policy -}} + {{ T "footer_privacy_policy" }} +{{- end -}} + +{{ if ne .Site.Params.ui.footer_about_disable nil -}} + {{ warnf "Config parameter '.params.ui.footer_about_disable' is DEPRECATED, use '.params.ui.footer_about_enable' instead." -}} +{{ end -}} + +{{ if or .Site.Params.ui.footer_about_enable (eq .Site.Params.ui.footer_about_disable false) -}} + {{ with .Site.GetPage "about" -}} + + {{- end -}} +{{ end -}} diff --git a/layouts/partials/footer/copyright.html b/layouts/partials/footer/copyright.html new file mode 100644 index 0000000000..1370c5e1f4 --- /dev/null +++ b/layouts/partials/footer/copyright.html @@ -0,0 +1,42 @@ +{{ $page := .Page -}} +{{ with .Site.Params.copyright -}} + {{ $fromYear := "" -}} + {{ $toYear := "" -}} + {{ $authors := "" -}} + {{ if reflect.IsMap . -}} + {{ $fromYear = .from_year -}} + {{ $toYear = .to_year -}} + {{ $authors = .authors -}} + {{ else -}} + {{ $authors = . -}} + {{ end -}} + + © + {{ with $fromYear -}} + {{ . }}– + {{- end -}} + {{ $toYear | default now.Year }} + + {{- $authors + | default (printf "%s Authors" ($.Site.Title | default "Site")) + | $page.RenderString -}} + + {{- /* Trim WS */ -}} + + + {{- with T "footer_all_rights_reserved" -}} + + {{- . -}} + + {{- end }} + +{{- else -}} + + {{ with .Site.Copyright -}} + {{/* For historical reasons we process this as HTML rather than markdown. */ -}} + + {{- . | safeHTML -}} + + {{- end -}} + +{{ end -}} diff --git a/layouts/partials/footer/left.html b/layouts/partials/footer/left.html new file mode 100644 index 0000000000..ed9265f4c2 --- /dev/null +++ b/layouts/partials/footer/left.html @@ -0,0 +1,5 @@ +{{ with .Site.Params.links -}} + {{ with index . "user" -}} + {{- partial "footer/links.html" . -}} + {{ end -}} +{{ end -}} diff --git a/layouts/partials/footer/links.html b/layouts/partials/footer/links.html new file mode 100644 index 0000000000..0d84f4e1dd --- /dev/null +++ b/layouts/partials/footer/links.html @@ -0,0 +1,9 @@ + diff --git a/layouts/partials/footer/right.html b/layouts/partials/footer/right.html new file mode 100644 index 0000000000..3afc3d2744 --- /dev/null +++ b/layouts/partials/footer/right.html @@ -0,0 +1,5 @@ +{{ with .Site.Params.links -}} + {{ with index . "developer" -}} + {{- partial "footer/links.html" . -}} + {{ end -}} +{{ end -}} diff --git a/layouts/partials/head-css.html b/layouts/partials/head-css.html index d2178317d4..af8310d88e 100644 --- a/layouts/partials/head-css.html +++ b/layouts/partials/head-css.html @@ -1,11 +1,39 @@ +{{ $scssMain := "scss/main.scss" -}} +{{ $css := resources.Get $scssMain + | toCSS (dict "enableSourceMap" (not hugo.IsProduction)) -}} +{{ $bsRtlCss := "vendor/bootstrap/dist/css/bootstrap.rtl.css" -}} +{{ $rtlCSS := "" -}} -{{ $scssMain := "scss/main.scss"}} -{{ if not hugo.IsProduction }} -{{/* Note the missing postCSS. This makes it snappier to develop in Chrome, but makes it look sub-optimal in other browsers. */}} -{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" true) }} - -{{ else }} -{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" false) | postCSS | minify | fingerprint }} - - -{{ end }} +{{ if eq .Site.Language.LanguageDirection "rtl" -}} + {{ with resources.Get $bsRtlCss -}} + {{ $rtlCSS = . -}} + {{ else -}} + {{ $msg := printf "Resource not found: %s" $bsRtlCss -}} + {{ warnf $msg -}} + + {{ end -}} +{{ end -}} + +{{ if hugo.IsProduction -}} + {{ with $rtlCSS -}} + {{ $rtlCSS = . | postCSS | minify | fingerprint -}} + {{ end -}} + {{ $css = $css | postCSS | minify | fingerprint -}} + +{{- end -}} + +{{/* NOTE: when not in production, we don't apply `postCSS`. This makes it +snappier to develop in Chrome, but makes it look sub-optimal in other browsers. +*/ -}} + +{{ with $css -}} + +{{ else -}} + {{ errorf "Resource not found: %s" $scssMain -}} +{{ end -}} + +{{ with $rtlCSS -}} + +{{ end -}} + +{{- /**/ -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 5fb1dd25ca..b1470a3577 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,6 +1,5 @@ -{{ hugo.Generator }} {{ range .AlternativeOutputFormats -}} {{ end -}} @@ -25,10 +24,10 @@ {{ template "_internal/opengraph.html" . -}} {{ template "_internal/schema.html" . -}} {{ template "_internal/twitter_cards.html" . -}} -{{ partialCached "head-css.html" . "asdf" -}} +{{ partialCached "head-css.html" . "head-css-cache-key" -}} {{ if .Site.Params.offlineSearch -}} {{ if $needmhchem -}} {{/* To add support for displaying chemical equations and physical units, load the mhchem extension: */ -}} - {{ end -}} {{/* To automatically render math in text elements, include the auto-render extension: */ -}} - {{ end -}} {{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}} {{ $jsBase := resources.Get "js/base.js" -}} -{{ $jsAnchor := resources.Get "js/anchor.js" -}} {{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home -}} -{{ $jsMermaid := resources.Get "js/mermaid.js" | resources.ExecuteAsTemplate "js/mermaid.js" . -}} {{ $jsMarkmap := resources.Get "js/markmap.js" | resources.ExecuteAsTemplate "js/markmap.js" . -}} {{ $jsPlantuml := resources.Get "js/plantuml.js" | resources.ExecuteAsTemplate "js/plantuml.js" . -}} {{ $jsDrawio := resources.Get "js/drawio.js" | resources.ExecuteAsTemplate "js/drawio.js" . -}} @@ -74,11 +67,14 @@ {{ $jsSearch = resources.Get "js/offline-search.js" -}} {{ end -}} -{{ $jsArray := slice $jsBs $jsBase $jsAnchor $jsSearch $jsPlantuml $jsMarkmap $jsDrawio -}} +{{ $jsArray := slice $jsBs $jsBase $jsSearch $jsPlantuml $jsMarkmap $jsDrawio -}} -{{ if $needmermaid -}} -{{ $jsArray = $jsArray | append $jsMermaid -}} - +{{ if .Page.Store.Get "hasmermaid" -}} +{{- partial "scripts/mermaid.html" . -}} +{{ end -}} + +{{ if .Site.Params.ui.showLightDarkModeMenu -}} + {{ $jsArray = $jsArray | append (resources.Get "js/dark-mode.js") -}} {{ end -}} {{ $js := $jsArray | resources.Concat "js/main.js" -}} @@ -101,5 +97,25 @@ crossorigin="anonymous"> {{ end -}} +{{ if and .Site.Params.search (isset .Site.Params.search "algolia") -}} + {{ template "algolia/scripts" .Site.Params.search.algolia -}} +{{ end -}} {{ partial "hooks/body-end.html" . -}} + +{{ define "algolia/scripts" -}} + + +{{ end -}} diff --git a/layouts/partials/scripts/mermaid.html b/layouts/partials/scripts/mermaid.html new file mode 100644 index 0000000000..62e8c072c0 --- /dev/null +++ b/layouts/partials/scripts/mermaid.html @@ -0,0 +1,67 @@ +{{ $version := .Site.Params.mermaid.version | default "latest" -}} + +{{ $cdnurl := printf "https://cdn.jsdelivr.net/npm/mermaid@%s/dist/mermaid.esm.min.mjs" $version -}} +{{ with resources.GetRemote $cdnurl -}} + {{ with .Err -}} + {{ errorf "Could not retrieve mermaid script from CDN. Reason: %s." . -}} + {{ end -}} +{{ else -}} + {{ errorf "Invalid Mermaid version %s, could not retrieve this version from CDN." $version -}} +{{ end -}} + + diff --git a/layouts/partials/search-input.html b/layouts/partials/search-input.html index feb1e74460..7817e0abc8 100644 --- a/layouts/partials/search-input.html +++ b/layouts/partials/search-input.html @@ -1,11 +1,30 @@ +{{ .Scratch.Set "docsy-search" 0 -}} + {{ if .Site.Params.gcs_engine_id -}} +{{ .Scratch.Add "docsy-search" 1 -}} + -{{ else if .Site.Params.algolia_docsearch -}} -
-{{ else if .Site.Params.offlineSearch -}} + +{{- end -}} + + +{{ if and .Site.Params.search (isset .Site.Params.search "algolia") -}} +{{ .Scratch.Add "docsy-search" 1 -}} +{{ .Scratch.Add "docsearch-id-num" 1 -}} + + + +{{- end -}} + + +{{ if .Site.Params.offlineSearch -}} +{{ .Scratch.Add "docsy-search" 1 -}} + {{ $offlineSearchIndex := resources.Get "json/offline-search-index.json" | resources.ExecuteAsTemplate "offline-search-index.json" . -}} {{ if hugo.IsProduction -}} {{/* Use `md5` as finger print hash function to shorten file name to avoid `file name too long` error. */ -}} @@ -33,4 +52,10 @@ data-offline-search-max-results="{{ .Site.Params.offlineSearchMaxResults | default 10 }}" >
+ +{{- end -}} + +{{ if gt (.Scratch.Get "docsy-search") 1 -}} +{{ warnf `You have more than one site-search option configured: choose only one. + For details, see https://www.docsy.dev/docs/adding-content/search.` -}} {{ end -}} diff --git a/layouts/partials/section-index.html b/layouts/partials/section-index.html index e1c83154c1..685dde8a50 100644 --- a/layouts/partials/section-index.html +++ b/layouts/partials/section-index.html @@ -1,31 +1,34 @@
- {{ $parent := .Page }} - {{ $pages := (where .Site.Pages "Section" .Section).ByWeight }} + {{ $page := .Page -}} + {{ $pages := (where .Site.Pages "Section" .Section).ByWeight -}} {{ $pages = (where $pages "Type" "!=" "search") }} - {{ $pages = (where $pages ".Params.hide_summary" "!=" true) }} - {{ $pages = (where $pages ".Parent" "!=" nil) }} - {{ $pages = (where $pages "Parent.File.UniqueID" "==" $parent.File.UniqueID) }} - {{ if or $parent.Params.no_list (eq (len $pages) 0) }} + {{ $pages = (where $pages ".Params.hide_summary" "!=" true) -}} + {{ $pages = (where $pages ".Parent" "!=" nil) -}} + {{ $pages = (where $pages ".Parent.File" "!=" nil) -}} + {{ if $page.File -}} + {{ $pages = (where $pages "Parent.File.UniqueID" "==" $page.File.UniqueID) -}} + {{ end -}} + {{ if or $page.Params.no_list (eq (len $pages) 0) -}} {{/* If no_list is true or we don't have subpages we don't show a list of subpages */}} - {{ else if $parent.Params.simple_list }} + {{ else if $page.Params.simple_list -}} {{/* If simple_list is true we show a bulleted list of subpages */}}
    - {{ range $pages }} + {{ range $pages -}} {{ $manualLink := cond (isset .Params "manuallink") .Params.manualLink ( cond (isset .Params "manuallinkrelref") (relref . .Params.manualLinkRelref) .RelPermalink) }}
  • {{- .Title -}}
  • - {{ end }} + {{ end -}}
- {{ else }} + {{ else -}} {{/* Otherwise we show a nice formatted list of subpages with page descriptions */}}
- {{ range $pages }} - {{ $manualLink := cond (isset .Params "manuallink") .Params.manualLink ( cond (isset .Params "manuallinkrelref") (relref . .Params.manualLinkRelref) .RelPermalink) }} + {{ range $pages -}} + {{ $manualLink := cond (isset .Params "manuallink") .Params.manualLink ( cond (isset .Params "manuallinkrelref") (relref . .Params.manualLinkRelref) .RelPermalink) -}}
{{- .Title -}}
-

{{ .Description | markdownify }}

+

{{ .Description | markdownify -}}

- {{ end }} - {{ end }} + {{ end -}} + {{ end -}}
diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index 60f583c111..2ce0c56373 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -18,7 +18,10 @@
{{ end -}} -