diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
| commit | 900bb5e845c3ad44defbd427cae3d44a4a43321f (patch) | |
| tree | df3d96a93771884add571e82336c29fc3d9c7a1c /code/frontpage/layouts/partials | |
| download | greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.tar.xz greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.zip | |
feat: Initial commit
Diffstat (limited to 'code/frontpage/layouts/partials')
29 files changed, 1195 insertions, 0 deletions
diff --git a/code/frontpage/layouts/partials/content/card-image.html b/code/frontpage/layouts/partials/content/card-image.html new file mode 100644 index 0000000..51a5e51 --- /dev/null +++ b/code/frontpage/layouts/partials/content/card-image.html @@ -0,0 +1,17 @@ +{{ $fillImage := .Scratch.Get "fillImageCard" }} +{{ if not $fillImage -}} +{{ $fillImage = site.Params.fillImage }} +{{ end -}} + +{{ $image := .Resources.GetMatch (printf "**%s" (index .Params.images 0)) }} +{{ if not $image -}} +{{ $image = resources.Get (printf "%s%s" "images/" site.Params.defaultImage) }} +{{ end -}} + +{{ $webp := printf "%s%s" $fillImage " webp" }} +{{/* {{ $image = $image.Resize $webp}} */}} + +{{ $lqip := $image.Resize site.Params.lqipWidth -}} + +<img class="card-img-top img-fluid lazyload blur-up" src="{{ $lqip.Permalink }}" data-src="{{ $image.Permalink }}" + width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}">
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/content/figure.html b/code/frontpage/layouts/partials/content/figure.html new file mode 100644 index 0000000..fbb0bde --- /dev/null +++ b/code/frontpage/layouts/partials/content/figure.html @@ -0,0 +1,37 @@ +{{ $fillImage := .Scratch.Get "fillImage" }} +{{ if not $fillImage -}} + {{ $fillImage = site.Params.fillImage }} +{{ end -}} + +{{ $image := .Resources.GetMatch (printf "**%s" (index .Params.images 0)) }} +{{ if not $image -}} + {{ $image = resources.Get (printf "%s%s" "images/" site.Params.defaultImage) }} +{{ end -}} + +{{ $image = $image.Fill $fillImage }} +{{ $lqip := $image.Resize site.Params.lqipWidth -}} + +{{ $imgSrc := "" -}} +{{ $imgSrcSet := slice -}} + +{{ $widths := site.Params.landscapePhotoWidths -}} +{{ if gt $image.Height $image.Width -}} + {{ $widths = site.Params.portraitPhotoWidths -}} +{{ end -}} + +{{ range $widths -}} + {{ $srcUrl := (printf "%dx" . | $image.Resize).Permalink -}} + {{ if eq $imgSrc "" -}}{{ $imgSrc = $srcUrl -}}{{ end -}} + {{ $imgSrcSet = $imgSrcSet | append (printf "%s %dw" $srcUrl .) -}} +{{ end -}} +{{ $imgSrcSet = (delimit $imgSrcSet ",") -}} + +{{ if gt $image.Width site.Params.smallLimit -}} + <figure class="figure"> + <img class="figure-img img-fluid lazyload blur-up" data-sizes="auto" src="{{ $lqip.Permalink }}" data-srcset="{{ $imgSrcSet }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"> + <noscript><img class="figure-img img-fluid" sizes="100vw" srcset="{{ $imgSrcSet }}" src="{{ $image.Permalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"></noscript> + <!-- {{ with .Title }}<figcaption class="figure-caption">{{ . | safeHTML }}</figcaption>{{ end -}} --> + </figure> +{{ else -}} + <img class="img-fluid lazyload blur-up" src="{{ $lqip.Permalink }}" data-src="{{ $image.Permalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"> +{{ end -}} diff --git a/code/frontpage/layouts/partials/content/image.html b/code/frontpage/layouts/partials/content/image.html new file mode 100644 index 0000000..2772531 --- /dev/null +++ b/code/frontpage/layouts/partials/content/image.html @@ -0,0 +1,32 @@ +{{ $image := .Resources.GetMatch (printf "**%s" (index .Params.images 0)) }} +{{ if not $image -}} + {{ $image = resources.Get (printf "%s%s" "images/" site.Params.defaultImage) }} +{{ end -}} + +{{ $image = $image.Fill site.Params.fillImage }} +{{ $lqip := $image.Resize site.Params.lqipWidth -}} + +{{ $imgSrc := "" -}} +{{ $imgSrcSet := slice -}} + +{{ $widths := site.Params.landscapePhotoWidths -}} +{{ if gt $image.Height $image.Width -}} + {{ $widths = site.Params.portraitPhotoWidths -}} +{{ end -}} + +{{ range $widths -}} + {{ $srcUrl := (printf "%dx" . | $image.Resize).Permalink -}} + {{ if eq $imgSrc "" -}}{{ $imgSrc = $srcUrl -}}{{ end -}} + {{ $imgSrcSet = $imgSrcSet | append (printf "%s %dw" $srcUrl .) -}} +{{ end -}} +{{ $imgSrcSet = (delimit $imgSrcSet ",") -}} + +{{ if gt $image.Width site.Params.smallLimit -}} + <figure class="figure"> + <img class="figure-img img-fluid lazyload blur-up" data-sizes="auto" src="{{ $lqip.Permalink }}" data-srcset="{{ $imgSrcSet }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"> + <noscript><img class="figure-img img-fluid" sizes="100vw" srcset="{{ $imgSrcSet }}" src="{{ $image.Permalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"></noscript> + <!-- {{ with .Title }}<figcaption class="figure-caption">{{ . | safeHTML }}</figcaption>{{ end -}} --> + </figure> +{{ else -}} + <img class="img-fluid lazyload blur-up" src="{{ $lqip.Permalink }}" data-src="{{ $image.Permalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ .Title }}"> +{{ end -}} diff --git a/code/frontpage/layouts/partials/footer/footer.html b/code/frontpage/layouts/partials/footer/footer.html new file mode 100644 index 0000000..ceb5fae --- /dev/null +++ b/code/frontpage/layouts/partials/footer/footer.html @@ -0,0 +1,18 @@ +<footer class="footer text-muted"> + <div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}"> + <div class="row"> + <div class="col-lg-8 order-last order-lg-first"> + <ul class="list-inline"> + <li class="list-inline-item">{{ .Site.Params.footer | safeHTML }}</li> + </ul> + </div> + <div class="col-lg-8 order-first order-lg-last text-lg-end"> + <ul class="list-inline"> + {{ range .Site.Menus.footer -}} + <li class="list-inline-item"><a href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + </ul> + </div> + </div> + </div> +</footer>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/footer/script-footer.html b/code/frontpage/layouts/partials/footer/script-footer.html new file mode 100644 index 0000000..8799730 --- /dev/null +++ b/code/frontpage/layouts/partials/footer/script-footer.html @@ -0,0 +1,119 @@ +{{ $indexTemplate := resources.Get "js/index.js" -}} +{{ $index := $indexTemplate | resources.ExecuteAsTemplate "index.js" . -}} + +{{ $bs := resources.Get "js/bootstrap.js" -}} +{{ $bs := $bs | js.Build -}} + +{{ $highlight := resources.Get "js/highlight.js" -}} +{{ $highlight := $highlight | js.Build -}} + +{{ $katex := resources.Get "js/vendor/katex/dist/katex.js" -}} +{{ $katexAutoRender := resources.Get "js/vendor/katex/dist/contrib/auto-render.js" -}} + +{{ $mermaid := resources.Get "js/mermaid.js" | js.Build -}} + +{{ $app := resources.Get "js/app.js" -}} + +{{ $slice := slice $app -}} + +{{ if .Site.Params.options.lazySizes -}} + {{ $lazySizes := resources.Get "js/lazysizes.js" -}} + {{ $lazySizes := $lazySizes | js.Build -}} + {{ $slice = $slice | append $lazySizes -}} +{{ end -}} + +{{ if .Site.Params.options.clipBoard -}} + {{ $clipBoard := resources.Get "js/clipboard.js" -}} + {{ $clipBoard := $clipBoard | js.Build -}} + {{ $slice = $slice | append $clipBoard -}} +{{ end -}} + +{{ if .Site.Params.options.instantPage -}} + {{ $instantPage := resources.Get "js/instant.page.js" -}} + {{ $instantPage := $instantPage | js.Build -}} + {{ $slice = $slice | append $instantPage -}} +{{ end -}} + +{{ $showFlexSearch := .Site.Params.options.flexSearch }} + +{{ if $showFlexSearch -}} + {{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}} + {{ $slice = $slice | append $flexSearch -}} + {{ if and (isset .Site.Params.options "searchsectionsshow") (not (eq .Site.Params.options.searchSectionsShow "ALL")) -}} + {{ $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section) (and .IsHome (in .Site.Params.options.searchSectionsShow "HomePage")) -}} + {{ end -}} +{{ end -}} + +{{ if .Site.Params.options.darkMode -}} + {{ $darkMode := resources.Get "js/darkmode.js" -}} + {{ $darkMode := $darkMode | js.Build -}} + {{ $slice = $slice | append $darkMode -}} +{{ end -}} + +{{ if and (.Site.Params.alert) (.Site.Params.alertDismissable) -}} + {{ $alert := resources.Get "js/alert.js" -}} + {{ $alert := $alert | js.Build -}} + {{ $slice = $slice | append $alert -}} +{{ end -}} + +{{ if .Site.Params.options.kaTex -}} + {{ $katexConfig := resources.Get "js/katex.js" -}} + {{ $katexConfig := $katexConfig | js.Build -}} + {{ $slice = $slice | append $katexConfig -}} +{{ end -}} + +{{ $scrollLock := resources.Get "js/scroll-lock.js" | js.Build -}} +{{ $slice = $slice | append $scrollLock -}} + +{{ if .Site.Params.options.toTopButton -}} + {{ $toTopButton := resources.Get "js/to-top.js" -}} + {{ $toTopButton := $toTopButton | js.Build -}} + {{ $slice = $slice | append $toTopButton -}} +{{ end -}} + +{{ $js := $slice | resources.Concat "main.js" -}} + +{{ if eq (hugo.Environment) "development" -}} + {{ if .Site.Params.options.bootStrapJs -}} + <script src="{{ $bs.RelPermalink }}" defer></script> + {{ end -}} + {{ if .Site.Params.options.highLight -}} + <script src="{{ $highlight.RelPermalink }}" defer></script> + {{ end -}} + {{ if .Site.Params.options.kaTex -}} + <script src="{{ $katex.RelPermalink }}" defer></script> + <script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script> + {{ end -}} + <script src="{{ $js.RelPermalink }}" defer></script> + {{ with .Params.mermaid -}} + <script src="{{ $mermaid.RelPermalink }}" defer></script> + {{ end -}} + {{ if $showFlexSearch -}} + <script src="{{ $index.RelPermalink }}" defer></script> + {{ end -}} +{{ else -}} + {{ $js := $js | minify | fingerprint "sha512" -}} + {{ $index := $index | minify | fingerprint "sha512" -}} + {{ $bs := $bs | minify | fingerprint "sha512" -}} + {{ $highlight := $highlight | minify | fingerprint "sha512" -}} + {{ $katex := $katex | minify | fingerprint "sha512" -}} + {{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}} + {{ $mermaid := $mermaid | minify | fingerprint "sha512" -}} + {{ if .Site.Params.options.bootStrapJs -}} + <script src="{{ $bs.RelPermalink }}" integrity="{{ $bs.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ end -}} + {{ if .Site.Params.options.highLight -}} + <script src="{{ $highlight.RelPermalink }}" integrity="{{ $highlight.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ end -}} + {{ if .Site.Params.options.kaTex -}} + <script src="{{ $katex.RelPermalink }}" integrity="{{ $katex.Data.Integrity }}" crossorigin="anonymous" defer></script> + <script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ end -}} + <script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ with .Params.mermaid -}} + <script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ end -}} + {{ if $showFlexSearch -}} + <script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script> + {{ end -}} +{{ end -}} diff --git a/code/frontpage/layouts/partials/head/custom-head.html b/code/frontpage/layouts/partials/head/custom-head.html new file mode 100644 index 0000000..0c59d7f --- /dev/null +++ b/code/frontpage/layouts/partials/head/custom-head.html @@ -0,0 +1 @@ +<!-- Custom head --> diff --git a/code/frontpage/layouts/partials/head/favicons.html b/code/frontpage/layouts/partials/head/favicons.html new file mode 100644 index 0000000..93c5ed5 --- /dev/null +++ b/code/frontpage/layouts/partials/head/favicons.html @@ -0,0 +1,9 @@ +<meta name="theme-color" content="{{ $.Site.Params.themeColor }}"> +<link rel="icon" href="{{ "favicon.ico" | absURL }}" sizes="any"> +{{ if os.FileExists "static/favicon.svg" -}} + <link rel="icon" type="image/svg+xml" href="{{ "favicon.svg" | absURL }}"> +{{ end -}} +<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | absURL }}"> +<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | absURL }}"> +<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | absURL }}"> +<link rel="manifest" crossorigin="use-credentials" href="{{ "site.webmanifest" | absURL }}"> diff --git a/code/frontpage/layouts/partials/head/head.html b/code/frontpage/layouts/partials/head/head.html new file mode 100644 index 0000000..12e2a8c --- /dev/null +++ b/code/frontpage/layouts/partials/head/head.html @@ -0,0 +1,11 @@ +<head> + <meta charset="utf-8"> + <meta http-equiv="x-ua-compatible" content="ie=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + {{ block "head/resource-hints" . }}{{ partial "head/resource-hints.html" . }}{{ end }} + {{ block "head/script-header" . }}{{ partial "head/script-header.html" . }}{{ end }} + {{ block "head/stylesheet" . }}{{ partial "head/stylesheet.html" . }}{{ end }} + {{ block "head/seo" . }}{{ partial "head/seo.html" . }}{{ end }} + {{ block "head/favicons" . }}{{ partial "head/favicons.html" . }}{{ end }} + {{ block "head/custom-head" . }}{{ partial "head/custom-head.html" . }}{{ end }} +</head> diff --git a/code/frontpage/layouts/partials/head/opengraph.html b/code/frontpage/layouts/partials/head/opengraph.html new file mode 100644 index 0000000..6127e82 --- /dev/null +++ b/code/frontpage/layouts/partials/head/opengraph.html @@ -0,0 +1,69 @@ +<meta property="og:locale" content="{{ .Site.Params.ogLocale }}"> +<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}"> +<meta property="og:title" content="{{ .Title }}"> +<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"> +{{ if $.Scratch.Get "paginator" -}} + {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} + <meta property="og:url" content="{{ .Paginator.URL | absURL }}"> +{{ else -}} + <meta property="og:url" content="{{ .Permalink }}"> +{{ end -}} +{{ with .Site.Params.title -}} + <meta property="og:site_name" content="{{ . }}"> +{{ end -}} + +{{ $iso8601 := "2006-01-02T15:04:05-07:00" -}} +{{ if .IsPage -}} + {{ if not .PublishDate.IsZero -}} + <meta property="article:published_time" {{ .PublishDate.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ else if not .Date.IsZero -}} + <meta property="article:published_time" {{ .Date.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} + {{ if not .Lastmod.IsZero -}} + <meta property="article:modified_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} +{{ else -}} + {{ if not .Date.IsZero -}} + <meta property="og:updated_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} +{{ end -}} + +{{ if eq .Kind "home" -}} + {{ .Scratch.Set "title" .Site.Params.titleHome -}} +{{ else -}} + {{ .Scratch.Set "title" .Title -}} +{{ end -}} + +{{ with $.Params.images -}} + {{ range first 6 . -}} + <meta property="og:image" content="{{ $.Permalink }}{{ . }}"> + {{ end -}} +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end -}} + {{ with $featured -}} + <meta property="og:image" content="{{ $featured.Permalink }}"/> + {{ else -}} + {{ with $.Site.Params.images -}} + <meta property="og:image" content="{{ index . 0 | absURL }}"/> + <meta property="og:image:alt" content="{{ $.Site.Params.title }}"> + {{ end -}} + {{ end -}} +{{ end -}} + +{{ with $.Site.Params.images -}} + {{ $.Scratch.Set "primaryImage" (index . 0 | absURL) -}} +{{ end -}} + +{{ with .Params.audio -}} + <meta property="og:audio" content="{{ . | absURL }}"> +{{ end -}} + +{{ with .Params.videos -}} + {{ range . -}} + <meta property="og:video" content="{{ . | absURL }}"> + {{ end -}} +{{ end -}} diff --git a/code/frontpage/layouts/partials/head/resource-hints.html b/code/frontpage/layouts/partials/head/resource-hints.html new file mode 100644 index 0000000..6ebcdeb --- /dev/null +++ b/code/frontpage/layouts/partials/head/resource-hints.html @@ -0,0 +1,4 @@ +{{ if .Site.Params.options.kaTex -}} +<link rel="preload" as="font" href="{{ " fonts/KaTeX_Main-Regular.woff2" | absURL }}" type="font/woff2" crossorigin> +<link rel="preload" as="font" href="{{ " fonts/KaTeX_Math-Italic.woff2" | absURL }}" type="font/woff2" crossorigin> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/script-header.html b/code/frontpage/layouts/partials/head/script-header.html new file mode 100644 index 0000000..38e5b5b --- /dev/null +++ b/code/frontpage/layouts/partials/head/script-header.html @@ -0,0 +1,8 @@ +{{ if .Site.Params.options.darkMode -}} + {{ $darkModeInit := resources.Get "js/darkmode-init.js" | js.Build | minify -}} + <script>{{ $darkModeInit.Content | safeJS }}</script> +{{ end -}} +{{- if and (.Site.Params.alert) (.Site.Params.alertDismissable) -}} + {{ $alertInit := resources.Get "js/alert-init.js" | js.Build | minify -}} + <script>{{ $alertInit.Content | safeJS }}</script> +{{- end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/seo.html b/code/frontpage/layouts/partials/head/seo.html new file mode 100644 index 0000000..ac31d72 --- /dev/null +++ b/code/frontpage/layouts/partials/head/seo.html @@ -0,0 +1,48 @@ +{{ if eq .Kind "404" -}} + <meta name="robots" content="noindex, follow"> +{{ else -}} + {{ with .Params.robots -}} + <meta name="robots" content="{{ . }}"> + {{ else -}} + <meta name="robots" content="index, follow"> + <meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> + <meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> + {{ end -}} +{{ end -}} + +{{ if .IsHome -}} + <title>{{ .Site.Params.title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.titleAddition }}</title> +{{ else -}} + <title>{{ .Title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.title }}</title> +{{ end -}} + +{{ with .Description -}} + <meta name="description" content="{{ . }}"> +{{ else -}} + {{ with .Summary | plainify -}} + <meta name="description" content="{{ . }}"> + {{ else -}} + <meta name="description" content="{{ .Site.Params.description }}"> + {{ end -}} +{{ end -}} + +{{ if $.Scratch.Get "paginator" }} + <link rel="canonical" href="{{ .Paginator.URL | absURL }}"> + {{ if .Paginator.HasPrev -}} + <link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}"> + {{ end -}} + {{ if .Paginator.HasNext -}} + <link rel="next" href="{{ .Paginator.Next.URL | absURL }}"> + {{ end -}} +{{ else -}} + <link rel="canonical" href="{{ .Permalink }}"> +{{ end -}} + +{{ partial "head/opengraph.html" . }} +{{ partial "head/twitter_cards.html" . }} + +{{ range .AlternativeOutputFormats -}} + <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}"> +{{ end -}} + +{{ partial "head/structured-data.html" . }} diff --git a/code/frontpage/layouts/partials/head/structured-data.html b/code/frontpage/layouts/partials/head/structured-data.html new file mode 100644 index 0000000..1f153a3 --- /dev/null +++ b/code/frontpage/layouts/partials/head/structured-data.html @@ -0,0 +1,210 @@ +{{ $baseURL := "/" | absURL -}} + +{{ $dot := . -}} +{{ $dot.Scratch.Set "path" "" -}} +{{ $dot.Scratch.Set "breadcrumb" slice -}} + +{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $.Scratch.Add "path" .Site.BaseURL -}} + +{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} + {{ range $index, $element := split $url "/" -}} + {{ $dot.Scratch.Add "path" $element -}} + {{ $.Scratch.Add "path" "/" -}} + {{ if ne $element "" -}} + {{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}} + {{ end -}} +{{ end -}} + +<script type="application/ld+json"> +{ + "@context": "https://schema.org", + "@graph": [ + { + {{ if eq .Site.Params.schemaType "Organization" -}} + "@type": "Organization", + "@id": {{ print $baseURL "#/schema/organization/1" }}, + {{ else -}} + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/1" }}, + {{ end -}} + "name": "{{ .Site.Params.schemaName }}", + "url": {{ print $baseURL }}, + "sameAs": [ + {{ with .Site.Params.schemaTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaGitHub -}} + , {{ . }} + {{ end -}} + ], + {{ if eq .Site.Params.schemaType "Organization" -}} + "logo": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaLogo }}, + "width": {{ .Site.Params.schemaLogoWidth }}, + "height": {{ .Site.Params.schemaLogoHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + }, + "image": { + "@id": {{ print $baseURL "#/schema/image/1" }} + } + {{ else -}} + "image": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaImage }}, + "width": {{ .Site.Params.schemaImageWidth }}, + "height": {{ .Site.Params.schemaImageHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + } + {{ end -}} + }, + { + "@type": "WebSite", + "@id": {{ print $baseURL "#/schema/website/1" }}, + "url": {{ print $baseURL }}, + "name": "{{ .Site.Params.title }}", + "description": "{{ .Site.Params.description }}", + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + } + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + } + {{ end -}} + }, + { + {{ if and (ne .Kind "taxonomy") (ne .Kind "term") -}} + "@type": "WebPage", + {{ else -}} + "@type": "CollectionPage", + {{ end -}} + "@id": {{ .Permalink }}, + "url": {{ .Permalink }}, + "name": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ print $baseURL "#/schema/website/1" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "about": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "about": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "breadcrumb": { + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }} + }, + "primaryImageOfPage": { + "@id": {{ print .Permalink "#/schema/image/2" }} + }, + "inLanguage": "{{ .Site.Params.schemaLocale }}", + "potentialAction": [{ + "@type": "ReadAction", "target": [{{ .Permalink }}] + }] + }, + { + "@type": "BreadcrumbList", + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }}, + "name": "Breadcrumbs", + "itemListElement": [{{ $list := $.Scratch.Get "breadcrumb" }}{{ $len := (len $list) }}{{ range $index, $element := $list }}{{ if ne .position 1 }},{{ end }}{ + "@type": "ListItem", + "position": {{ .position }}, + "item": { + {{ if ne (add $index 1) $len -}} + "@type": "WebPage", + "@id": {{ .url }}, + "url": {{ .url }}, + "name": "{{ .name | humanize | title }}" + {{ else -}} + "@id": {{ .url }} + {{ end -}} + } + }{{ end }}] + }, + + {{ if and (eq .Kind "page") (or (eq .Section "blog") (eq .Section "docs") (eq .Section "tutorial") (eq .Section "showcase")) -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Article", + "@id": {{ print $baseURL "#/schema/article/1" }}, + "headline": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ .Permalink }} + }, + "mainEntityOfPage": { + "@id": {{ .Permalink }} + }, + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "author": { + "@id": {{ print $baseURL "#/schema/person/2" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "image": { + "@id": {{ print .Permalink "#/schema/image/2" }} + } + } + ] + }, + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/2" }}, + "name": {{ .Site.Params.schemaAuthor }}, + "sameAs": [ + {{ with .Site.Params.schemaAuthorTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorGitHub -}} + , {{ . }} + {{ end -}} + ] + } + ] + }, + {{ end -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "ImageObject", + "@id": {{ print .Permalink "#/schema/image/2" }}, + "url": {{ $.Scratch.Get "primaryImage" }}, + "contentUrl": {{ $.Scratch.Get "primaryImage" }}, + "caption": "{{ .Title }}" + } + ] + } + + ] +} +</script>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/stylesheet.html b/code/frontpage/layouts/partials/head/stylesheet.html new file mode 100644 index 0000000..4dc25c0 --- /dev/null +++ b/code/frontpage/layouts/partials/head/stylesheet.html @@ -0,0 +1,11 @@ +{{ if eq (hugo.Environment) "development" -}} + {{ $options := (dict "targetPath" "main.css" "enableSourceMap" true "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options -}} + <link rel="stylesheet" href="{{ $css.Permalink | relURL }}"> +{{ else -}} + {{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options | postCSS (dict "config" "config/postcss.config.js") -}} + {{ $secureCSS := $css | resources.Fingerprint "sha512" -}} + <link rel="stylesheet" href="{{ $secureCSS.Permalink }}" integrity="{{ $secureCSS.Data.Integrity }}" crossorigin="anonymous"> +{{ end -}} +<noscript><style>img.lazyload { display: none; }</style></noscript>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/twitter_cards.html b/code/frontpage/layouts/partials/head/twitter_cards.html new file mode 100644 index 0000000..fdf581c --- /dev/null +++ b/code/frontpage/layouts/partials/head/twitter_cards.html @@ -0,0 +1,24 @@ +<meta name="twitter:card" content="summary_large_image"> +<meta name="twitter:site" content="{{ .Site.Params.twitterSite }}"> +<meta name="twitter:creator" content="{{ .Site.Params.twitterCreator }}"> +<meta name="twitter:title" content="{{ .Title }}"> +<meta name="twitter:description" content="{{ .Description }}"> +{{ with $.Params.images -}} + <meta name="twitter:image" content="{{ $.Permalink }}{{ index . 0 }}"> +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}} + {{ end -}} + {{ with $featured -}} + <meta name="twitter:image" content="{{ $featured.Permalink }}"> + {{ else -}} + {{ with $.Site.Params.images -}} + <meta name="twitter:image" content="{{ index . 0 | absURL }}"> + {{ else -}} + <meta name="twitter:card" content="summary"> + {{ end -}} + {{ end -}} +{{ end -}} +<meta name="twitter:image:alt" content="{{ .Title }}">
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/header/alert.html b/code/frontpage/layouts/partials/header/alert.html new file mode 100644 index 0000000..7944ae9 --- /dev/null +++ b/code/frontpage/layouts/partials/header/alert.html @@ -0,0 +1,10 @@ +{{ if .Site.Params.alertDismissable -}} + <div id="announcement" data-id="global-alert-{{ md5 .Site.Params.alertText }}" class="alert alert-primary alert-dismissible fade show text-lg-center" role="alert"> + {{ .Site.Params.alertText | safeHTML }} + <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> + </div> +{{ else -}} + <div class="alert alert-primary text-lg-center" role="alert"> + {{ .Site.Params.alertText | safeHTML }} + </div> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/header/header.html b/code/frontpage/layouts/partials/header/header.html new file mode 100644 index 0000000..7869784 --- /dev/null +++ b/code/frontpage/layouts/partials/header/header.html @@ -0,0 +1,254 @@ +{{ if .Site.Params.alert -}} +{{ partial "header/alert.html" . }} +{{ end -}} + +{{ if eq .Site.Params.options.navbarSticky true -}} +<div class="sticky-top"> + {{ end -}} + + <header class="navbar navbar-expand-md navbar-light doks-navbar"> + <nav class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }} flex-wrap flex-lg-nowrap" + aria-label="Main navigation"> + + <a class="navbar-brand order-0" href="/" aria-label="{{ .Site.Params.Title }}"> + {{ .Site.Params.Title }} + </a> + + {{ if (in .Site.Params.sections.sectionNav .Section) -}} + <button class="btn btn-link order-0 ms-auto d-md-none" type="button" data-bs-toggle="offcanvas" + data-bs-target="#offcanvasExample" aria-controls="offcanvasExample"> + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" + stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" + class="feather feather-more-horizontal"> + <circle cx="12" cy="12" r="1"></circle> + <circle cx="19" cy="12" r="1"></circle> + <circle cx="5" cy="12" r="1"></circle> + </svg> + </button> + <div class="offcanvas offcanvas-start d-md-none" tabindex="-1" id="offcanvasExample" + aria-labelledby="offcanvasExampleLabel"> + <div class="offcanvas-header"> + <h5 class="offcanvas-title" id="offcanvasExampleLabel">{{ i18n "browse" }} {{ .Section }}</h5> + <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button> + </div> + <div class="offcanvas-body"> + <aside class="doks-sidebar mt-n3"> + <nav id="doks-docs-nav" aria-label="Tertiary navigation"> + {{ partial "sidebar/docs-menu.html" . }} + </nav> + </aside> + </div> + </div> + {{ end -}} + + <button class="btn btn-menu order-2 d-block d-md-none" type="button" data-bs-toggle="offcanvas" + data-bs-target="#offcanvasDoks" aria-controls="offcanvasDoks" aria-label="Open main menu"> + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" + stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" + class="feather feather-menu"> + <line x1="3" y1="12" x2="21" y2="12"></line> + <line x1="3" y1="6" x2="21" y2="6"></line> + <line x1="3" y1="18" x2="21" y2="18"></line> + </svg> + </button> + <div class="offcanvas offcanvas-end border-0 py-md-1" tabindex="-1" id="offcanvasDoks" data-bs-backdrop="true" + aria-labelledby="offcanvasDoksLabel"> + <div class="offcanvas-header d-md-none"> + <h2 class="h5 offcanvas-title ps-2" id="offcanvasDoksLabel"><a class="text-dark" href="{{ " /" | relLangURL + }}">{{ .Site.Params.Title }}</a></h2> + <button type="button" class="btn-close text-reset me-2" data-bs-dismiss="offcanvas" + aria-label="Close main menu"></button> + </div> + <div class="offcanvas-body p-4 p-md-0"> + <ul class="nav flex-column flex-md-row align-items-md-center mt-2 mt-md-0 ms-md-2 me-md-auto"> + {{- $current := . -}} + {{- $section := $current.Section -}} + {{ range .Site.Menus.main -}} + {{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}} + {{- $active = or $active (eq .Name $current.Title) -}} + {{- $active = or $active (and (eq .Name ($section | humanize)) (eq $current.Section $section)) -}} + {{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "contributors" "categories" + "tags")) -}} + {{ if .HasChildren }} + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle ps-0 py-1" href="#" id="navbarDropdownMenuLink" role="button" + data-bs-toggle="dropdown" aria-expanded="false"> + {{ .Name }} + <span class="dropdown-caret"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" + viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" + stroke-linejoin="round" class="feather feather-chevron-down"> + <polyline points="6 9 12 15 18 9"></polyline> + </svg></span> + </a> + <ul class="dropdown-menu dropdown-menu-main shadow rounded border-0" + aria-labelledby="navbarDropdownMenuLink"> + {{ range .Children -}} + {{- $active = eq .Name $current.Title -}} + <li> + <a class="dropdown-item{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}" {{ if $active + }} aria-current="true" {{ end }}>{{ .Name }}</a> + </li> + {{ end -}} + </ul> + </li> + {{ else }} + <li class="nav-item"> + <a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name + }}</a> + </li> + {{ end }} + {{ end -}} + </ul> + + {{- $showFlexSearch := .Site.Params.options.flexSearch }} + {{- if $showFlexSearch }} + {{- if and (isset .Site.Params.options "searchsectionsshow") (not (eq .Site.Params.options.searchSectionsShow + "ALL")) }} + {{- $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in + .Site.Params.options.searchSectionsShow .Section) (and .IsHome (in .Site.Params.options.searchSectionsShow + "HomePage")) }} + {{- end }} + {{- end }} + + {{ if $showFlexSearch -}} + <hr class="text-black-50 my-4 d-lg-none"> + <form class="doks-search position-relative flex-grow-1 ms-lg-auto me-lg-2"> + <input id="search" class="form-control is-search" type="search" placeholder="{{ i18n " search-text" }}" + aria-label="{{ i18n " search-text" }}" autocomplete="off"> + <div id="suggestions" class="shadow bg-white rounded d-none"></div> + </form> + {{ end -}} + + <hr class="text-black-50 my-4 d-lg-none"> + <ul class="nav flex-column flex-lg-row"> + {{ range .Site.Menus.social -}} + <li class="nav-item"> + <a class="nav-link social-link" href="{{ .URL | relURL }}">{{ .Pre | safeHTML }}<small + class="ms-2 d-lg-none">{{ .Name | safeHTML }}</small></a> + </li> + {{ end -}} + </ul> + + {{ if .Site.Params.options.darkMode -}} + <hr class="text-black-50 my-4 d-lg-none"> + <button id="mode" class="btn btn-link" type="button" aria-label="Toggle user interface mode"> + <span class="toggle-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" + fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" + class="feather feather-moon"> + <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path> + </svg></span> + <span class="toggle-light"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" + viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" + stroke-linejoin="round" class="feather feather-sun"> + <circle cx="12" cy="12" r="5"></circle> + <line x1="12" y1="1" x2="12" y2="3"></line> + <line x1="12" y1="21" x2="12" y2="23"></line> + <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> + <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> + <line x1="1" y1="12" x2="3" y2="12"></line> + <line x1="21" y1="12" x2="23" y2="12"></line> + <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> + <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> + </svg></span> + </button> + {{ end -}} + + {{ if eq .Site.Params.options.multilingualMode true -}} + <hr class="text-black-50 my-4 d-lg-none"> + <div class="dropdown"> + <button class="btn btn-doks-light dropdown-toggle" id="doks-languages" data-bs-toggle="dropdown" + aria-expanded="false" data-bs-display="static"> + {{ .Site.Params.languageName }} + <span class="dropdown-caret"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" + viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" + stroke-linejoin="round" class="feather feather-chevron-down"> + <polyline points="6 9 12 15 18 9"></polyline> + </svg></span> + </button> + <ul class="dropdown-menu dropdown-menu-lg-end me-lg-2 shadow rounded border-0" + aria-labelledby="doks-languages"> + + <li><a class="dropdown-item current" aria-current="true" href="{{ .RelPermalink }}">{{ + .Site.Language.LanguageName }}</a></li> + + <li> + <hr class="dropdown-divider"> + </li> + + {{ if .IsTranslated -}} + {{ range .Translations }} + <li><a class="dropdown-item" rel="alternate" href="{{ .RelPermalink }}" hreflang="{{ .Lang }}" + lang="{{ .Lang }}">{{ .Language.LanguageName }}</a></li> + {{ end -}} + {{ else -}} + {{ range .Site.Languages -}} + {{ if ne $.Site.Language.Lang .Lang }} + <li><a class="dropdown-item" rel="alternate" href="{{ .Lang | relLangURL }}" hreflang="{{ .Lang }}" + lang="{{ .Lang }}">{{ .LanguageName }}</a></li> + {{ end -}} + {{ end -}} + {{ end -}} + <!-- + <li><hr class="dropdown-divider"></li> + <li><a class="dropdown-item" href="/docs/contributing/how-to-contribute/">Help Translate</a></li> + --> + </ul> + </div> + {{ end -}} + + {{ if eq .Site.Params.options.docsVersioning true -}} + <hr class="text-black-50 my-4 d-lg-none"> + <div class="dropdown"> + <button class="btn btn-doks-light dropdown-toggle" id="doks-versions" data-bs-toggle="dropdown" + aria-expanded="false" data-bs-display="static" aria-label="Toggle version menu"> + <span class="d-none">Doks</span> v{{ .Site.Params.docsVersion }} + <span class="dropdown-caret"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" + viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" + stroke-linejoin="round" class="feather feather-chevron-down"> + <polyline points="6 9 12 15 18 9"></polyline> + </svg></span> + </button> + <ul class="dropdown-menu dropdown-menu-lg-end me-lg-2 shadow rounded border-0" + aria-labelledby="doks-versions"> + <li><a class="dropdown-item current" aria-current="true" + href="/docs/{{ .Site.Params.docsVersion }}/prologue/introduction/">Latest ({{ .Site.Params.docsVersion + }}.x)</a></li> + <li> + <hr class="dropdown-divider"> + </li> + <li><a class="dropdown-item" href="/docs/0.2/prologue/introduction/">v0.2.x</a></li> + <li><a class="dropdown-item" href="/docs/0.1/prologue/introduction/">v0.1.x</a></li> + <li> + <hr class="dropdown-divider"> + </li> + <li><a class="dropdown-item" href="/docs/versions/">All versions</a></li> + </ul> + </div> + {{ end -}} + </div> + </div> + </nav> + </header> + + {{ if eq .Site.Params.options.navbarSticky true }} +</div> +{{ end -}} + +{{ if eq .Section "docs" -}} +<div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}"> + <aside class="doks-sidebar"> + <nav id="doks-docs-nav" class="collapse d-lg-none" aria-label="Tertiary navigation"> + {{ partial "sidebar/docs-menu.html" . }} + </nav> + </aside> +</div> + +{{ else if ne .CurrentSection .FirstSection -}} +<div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}"> + <aside class="doks-sidebar"> + <nav id="doks-docs-nav" class="collapse d-lg-none" aria-label="Tertiary navigation"> + {{ partial "sidebar/docs-menu.html" . }} + </nav> + </aside> +</div> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/main/blog-meta.html b/code/frontpage/layouts/partials/main/blog-meta.html new file mode 100644 index 0000000..7d11e94 --- /dev/null +++ b/code/frontpage/layouts/partials/main/blog-meta.html @@ -0,0 +1,2 @@ +{{ $last := sub (len .Params.contributors) 1 }} +<p><small>Posted{{ if .Params.categories -}} in {{ range $index, $category := .Params.categories -}}{{ if gt $index 0 -}}, {{ end -}}<a class="stretched-link position-relative link-muted" href="{{ "/categories/" | absURL }}{{ . | urlize }}/">{{ . }}</a>{{ end -}}{{ end -}} on {{ .PublishDate.Format "January 2, 2006" }} by {{ if .Params.contributors -}}{{ range $index, $contributor := .Params.contributors }}{{ if gt $index 0 }}{{ if eq $index $last }} and {{ else }}, {{ end }}{{ end }}<a class="stretched-link position-relative" href="{{ "/contributors/" | relURL }}{{ . | urlize }}/">{{ . }}</a>{{ end -}}{{ end -}} ‐ <strong>{{ .ReadingTime -}} min read</strong></small><p>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/main/breadcrumb.html b/code/frontpage/layouts/partials/main/breadcrumb.html new file mode 100644 index 0000000..1d960d2 --- /dev/null +++ b/code/frontpage/layouts/partials/main/breadcrumb.html @@ -0,0 +1,4 @@ +{{ with .Parent -}} + {{ partial "main/breadcrumb.html" . -}} + <li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ if .IsHome }}Home{{ else if eq .CurrentSection .FirstSection }}{{ .Section | humanize }}{{ else }}{{ .Title }}{{ end }}</a></li> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/main/date.html b/code/frontpage/layouts/partials/main/date.html new file mode 100644 index 0000000..4b41ddb --- /dev/null +++ b/code/frontpage/layouts/partials/main/date.html @@ -0,0 +1,6 @@ +<!-- + Returns formatted date. + Usage: partial "docs/date" (dict "Date" .Date "Format" .Site.Params.BookDateFormat) +--> +{{ $format := default "January 2, 2006" .Format -}} +{{ return (.Date.Format $format) -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/main/docs-navigation.html b/code/frontpage/layouts/partials/main/docs-navigation.html new file mode 100644 index 0000000..e6a5668 --- /dev/null +++ b/code/frontpage/layouts/partials/main/docs-navigation.html @@ -0,0 +1,24 @@ +{{ if or .Prev .Next -}} + <div class="docs-navigation d-flex justify-content-between"> + <!-- https://www.feliciano.tech/blog/custom-sort-hugo-single-pages/ --> + {{ $pages := where site.RegularPages "Section" .Section -}} + {{ with $pages.Next . -}} + <a href="{{ .RelPermalink }}"> + <div class="card my-1"> + <div class="card-body py-2"> + ← {{ .Title }} + </div> + </div> + </a> + {{ end -}} + {{ with $pages.Prev . -}} + <a class="ms-auto" href="{{ .RelPermalink }}"> + <div class="card my-1"> + <div class="card-body py-2"> + {{ .Title }} → + </div> + </div> + </a> + {{ end -}} + </div> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/main/edit-page.html b/code/frontpage/layouts/partials/main/edit-page.html new file mode 100644 index 0000000..b69ed36 --- /dev/null +++ b/code/frontpage/layouts/partials/main/edit-page.html @@ -0,0 +1,34 @@ +{{ $parts := slice .Site.Params.docsRepo }} + +{{ if (eq .Site.Params.repoHost "GitHub") }} + {{ $parts = $parts | append "blob" .Site.Params.docsRepoBranch }} +{{ else if (eq .Site.Params.repoHost "Gitea") }} + {{ $parts = $parts | append "_edit" .Site.Params.docsRepoBranch }} +{{ else if (eq .Site.Params.repoHost "GitLab") }} + {{ $parts = $parts | append "-/blob" .Site.Params.docsRepoBranch }} +{{ else if (eq .Site.Params.repoHost "Bitbucket") }} + {{ $parts = $parts | append "src" .Site.Params.docsRepoBranch }} +{{ else if (eq .Site.Params.repoHost "BitbucketServer") }} + {{ $parts = $parts | append "browse" .Site.Params.docsRepoBranch }} +{{ end }} + +{{ if isset .Site.Params "docsreposubpath" }} + {{ if not (eq .Site.Params.docsRepoSubPath "") }} + {{ $parts = $parts | append .Site.Params.docsRepoSubPath }} + {{ end }} +{{ end }} + +{{ $filePath := replace .File.Path "\\" "/" }} + +{{ $parts = $parts | append "content" .Lang $filePath }} + +{{ $url := delimit $parts "/" }} + +<div class="edit-page"> + <a href="{{ $url }}"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"> + <path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path> + </svg> + Edit this page on {{ .Site.Params.repoHost }} + </a> +</div> diff --git a/code/frontpage/layouts/partials/main/last-modified.html b/code/frontpage/layouts/partials/main/last-modified.html new file mode 100644 index 0000000..edb6c7d --- /dev/null +++ b/code/frontpage/layouts/partials/main/last-modified.html @@ -0,0 +1,10 @@ +{{ if and .GitInfo .Site.Params.docsRepo -}} + {{- $date := partial "main/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}} + {{- $commitPath := default "commit" .Site.Params.BookCommitPath -}} + <div class="last-modified"> + <a href="{{ .Site.Params.docsRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg> + Last modified on {{ $date }} + </a> + </div> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/sidebar/auto-collapsible-menu.html b/code/frontpage/layouts/partials/sidebar/auto-collapsible-menu.html new file mode 100644 index 0000000..4600d0a --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/auto-collapsible-menu.html @@ -0,0 +1,57 @@ +<!-- Auto collapsible section menu --> +<ul class="list-unstyled collapsible-sidebar"> + {{ $currentPage := . -}} + {{ $section := $currentPage.Section -}} + {{ range (where .Site.Sections "Section" "in" $section) }} + {{ range .Sections }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li class="mb-1"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Title }} + </button> + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Pages }} + {{ if .IsNode }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li class="my-1 ms-3"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Title }} + </button> + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Pages }} + {{ if .IsNode }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li class="my-1 ms-3"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Title }} + </button> + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Pages }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li> + {{ end }} + </ul> + </div> + </li> + {{ else }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li> + {{ end }} + {{ end }} + </ul> + </div> + </li> + {{ else }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li> + {{ end }} + {{ end }} + </ul> + </div> + </li> + {{ end }} + {{ end }} +</ul> diff --git a/code/frontpage/layouts/partials/sidebar/auto-default-menu.html b/code/frontpage/layouts/partials/sidebar/auto-default-menu.html new file mode 100644 index 0000000..6e4565b --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/auto-default-menu.html @@ -0,0 +1,37 @@ +<!-- Auto default section menu --> +{{ $currentPage := . -}} +{{ $section := $currentPage.Section -}} +{{ range (where .Site.Sections "Section" "in" $section) }} + {{ range .Sections }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <h3 class="h6 text-uppercase mb-2">{{ .Title }}</h3> + <ul class="list-unstyled"> + {{ range .Pages }} + {{ if .IsNode }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <h4 class="h6 text-uppercase ms-3 mt-3 mb-2">{{ .Title }}</h4> + <ul class="list-unstyled ms-3"> + {{ range .Pages }} + {{ if .IsNode }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <h5 class="h6 text-uppercase mt-2 mb-2">{{ .Title }}</h5> + <ul class="list-unstyled ms-3"> + {{ range .Pages }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Name }}</a></li> + {{ end }} + </ul> + {{ else }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Name }}</a></li> + {{ end }} + {{ end }} + </ul> + {{ else }} + {{ $active := in $currentPage.RelPermalink .RelPermalink }} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Name }}</a></li> + {{ end }} + {{ end }} + </ul> + {{ end }} +{{ end }} diff --git a/code/frontpage/layouts/partials/sidebar/docs-menu.html b/code/frontpage/layouts/partials/sidebar/docs-menu.html new file mode 100644 index 0000000..b7baebb --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/docs-menu.html @@ -0,0 +1,9 @@ +{{ if and .Site.Params.menu.section.auto .Site.Params.menu.section.collapsibleSidebar -}} + {{ partial "sidebar/auto-collapsible-menu.html" . -}} +{{ else if and .Site.Params.menu.section.auto (not .Site.Params.menu.section.collapsibleSidebar) -}} + {{ partial "sidebar/auto-default-menu.html" . -}} +{{ else if and (not .Site.Params.menu.section.auto) .Site.Params.menu.section.collapsibleSidebar -}} + {{ partial "sidebar/manual-collapsible-menu.html" . -}} +{{ else if and (not .Site.Params.menu.section.auto) (not .Site.Params.menu.section.collapsibleSidebar) -}} + {{ partial "sidebar/manual-default-menu.html" . -}} +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/sidebar/docs-toc.html b/code/frontpage/layouts/partials/sidebar/docs-toc.html new file mode 100644 index 0000000..c71a7b8 --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/docs-toc.html @@ -0,0 +1,26 @@ +{{ if and (ne .Params.toc false) (ne .TableOfContents "<nav id=\"TableOfContents\"></nav>") -}} +<div class="d-xl-none"> + <button class="btn btn-outline-primary btn-sm doks-toc-toggle collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#onThisPage" aria-controls="doks-docs-nav" aria-expanded="false" aria-label="Toggle On this page navigation"> + <span>{{ i18n "on-this-page" }}</span> + <span> + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" class="doks doks-expand" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Expand</title><polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline></svg> + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" class="doks doks-collapse" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Collapse</title><polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline></svg> + </span> + </button> + <div class="collapse" id="onThisPage"> + <div class="card card-body mt-3 py-1"> + <div class="page-links"> + {{ .TableOfContents }} + </div> + </div> + </div> +</div> +<div class="page-links d-none d-xl-block"> + <h3>{{ i18n "on-this-page" }}</h3> + {{ if eq .Site.Params.options.scrollSpy true -}} + {{ .TableOfContents | replaceRE "<nav id=\"TableOfContents\">" "<nav id=\"toc\">" | safeHTML }} + {{ else -}} + {{ .TableOfContents }} + {{ end -}} +</div> +{{ end -}} diff --git a/code/frontpage/layouts/partials/sidebar/manual-collapsible-menu.html b/code/frontpage/layouts/partials/sidebar/manual-collapsible-menu.html new file mode 100644 index 0000000..f83c667 --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/manual-collapsible-menu.html @@ -0,0 +1,63 @@ +<!-- Manual collapsible section menu --> +<ul class="list-unstyled collapsible-sidebar"> + {{ $currentPage := . -}} + {{ $section := $currentPage.Section -}} + {{ range (index .Site.Menus $section) -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li class="mb-1"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ .Identifier }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Name }} + </button> + {{ if .HasChildren -}} + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ .Identifier }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Children -}} + {{ if .HasChildren -}} + <li class="my-1 ms-3"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ .Identifier }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Name }} + </button> + {{ if .HasChildren -}} + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ .Identifier }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Children -}} + {{ if .HasChildren -}} + <li class="my-1 ms-3"> + <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ .Identifier }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}"> + {{ .Name }} + </button> + {{ if .HasChildren -}} + <div class="collapse{{ if $active }} show{{ end }}" id="section-{{ .Identifier }}"> + <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small"> + {{ range .Children -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + </ul> + </div> + {{ end -}} + </li> + {{ else -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + {{ end -}} + </ul> + </div> + {{ end -}} + </li> + {{ else -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + {{ end -}} + </ul> + </div> + {{ end -}} + </li> + {{ end -}} +</ul> diff --git a/code/frontpage/layouts/partials/sidebar/manual-default-menu.html b/code/frontpage/layouts/partials/sidebar/manual-default-menu.html new file mode 100644 index 0000000..32c4cd4 --- /dev/null +++ b/code/frontpage/layouts/partials/sidebar/manual-default-menu.html @@ -0,0 +1,41 @@ +<!-- Manual default section menu --> +{{ $currentPage := . -}} +{{ $section := $currentPage.Section -}} +{{ range (index .Site.Menus $section) -}} + <h3 class="h6 text-uppercase mb-2">{{ .Name }}</h3> + {{ if .HasChildren -}} + <ul class="list-unstyled"> + {{ range .Children -}} + {{ if .HasChildren -}} + <h4 class="h6 text-uppercase ms-3 mt-3 mb-2">{{ .Name }}</h4> + {{ if .HasChildren -}} + <ul class="list-unstyled ms-3"> + {{ range .Children -}} + {{ if .HasChildren -}} + <h5 class="h6 text-uppercase mt-2 mb-2">{{ .Name }}</h5> + {{ if .HasChildren -}} + <ul class="list-unstyled ms-3"> + {{ range .Children -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + </ul> + {{ end -}} + {{ else -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + {{ end -}} + </ul> + {{ end -}} + {{ else -}} + {{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}} + {{- $active = or $active (eq $currentPage.Section .Identifier) -}} + <li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li> + {{ end -}} + {{ end -}} + </ul> + {{ end -}} +{{ end -}} |
