From 4c41e477e13d37e187c8de4225c7e8056bd9ed28 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 29 Sep 2025 19:17:13 +0200 Subject: Internalise theme --- layouts/404.html | 17 +++--- layouts/_default/baseof.html | 29 ++++++---- layouts/_default/list.html | 27 +++++++--- layouts/_default/single.html | 44 ++++++++++++++- layouts/index.html | 22 +++----- layouts/partials/footer/copyright.html | 15 ++++-- layouts/partials/footer/index.html | 4 ++ layouts/partials/footer/social.html | 16 ++++-- layouts/partials/head/index.html | 2 + layouts/partials/head/meta.html | 42 +++++++++++---- layouts/partials/head/styles.html | 22 ++++---- layouts/partials/header/avatar.html | 17 ++++-- layouts/partials/header/index.html | 8 +++ layouts/partials/header/nav.html | 22 ++++---- layouts/partials/header/theme-button.html | 47 ++++++++++++++++ layouts/partials/header/title.html | 8 +-- layouts/partials/list/default.html | 33 +++++++++--- layouts/partials/list/pagination.html | 23 ++++++++ layouts/partials/single/comments/disqus.html | 4 ++ layouts/partials/single/comments/giscus.html | 22 ++++++++ layouts/partials/single/comments/index.html | 11 ++++ layouts/partials/single/table-of-contents.html | 6 +++ layouts/partials/utils/icon.html | 7 +++ layouts/shortcodes/alert.html | 73 +++++++++++++++++++++++++ layouts/shortcodes/details.html | 75 ++++++++++++++++++++++++++ layouts/shortcodes/img.html | 35 +++++------- layouts/shortcodes/task-list.html | 1 + layouts/taxonomies/home.html | 32 +++++++---- 28 files changed, 534 insertions(+), 130 deletions(-) create mode 100644 layouts/partials/footer/index.html create mode 100644 layouts/partials/head/index.html create mode 100644 layouts/partials/header/index.html create mode 100644 layouts/partials/header/theme-button.html create mode 100644 layouts/partials/list/pagination.html create mode 100644 layouts/partials/single/comments/disqus.html create mode 100644 layouts/partials/single/comments/giscus.html create mode 100644 layouts/partials/single/comments/index.html create mode 100644 layouts/partials/single/table-of-contents.html create mode 100644 layouts/partials/utils/icon.html create mode 100644 layouts/shortcodes/alert.html create mode 100644 layouts/shortcodes/details.html create mode 100644 layouts/shortcodes/task-list.html (limited to 'layouts') diff --git a/layouts/404.html b/layouts/404.html index d042ff8..6bed926 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,12 +1,13 @@ {{ define "main" }}
-
-

{{ .Title }}

-
-
- Looks like you've followed a broken link or entered a URL that doesn't exist on this site. -
+
+

{{ i18n "404_title" }}

+
+ +
+

{{ i18n "404_text" }}

+
- -{{ end }} \ No newline at end of file + +{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 69be8f7..aa39a42 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,13 +1,20 @@ - - - {{- partial "head.html" . -}} - - - {{ partial "header.html" . }} -
- {{- block "main" . }}{{- end }} -
- {{- partial "footer.html" . -}} - + + + {{- partial "head/index" . -}} + + + +
+ {{ partial "header/index" . }} + {{ partial "header/theme-button" . }} +
+ +
+ {{- block "main" . -}} + {{- end }} +
+ + {{- partial "footer/index" . -}} + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 577852f..d366d53 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,17 +1,30 @@ {{ define "main" }} + {{ $pages := .Pages }} -{{ $paginator := .Paginate $pages }} +{{ $paginator := .Paginate $pages }} +
-

{{ if .Params.header }}{{ .Params.header }}{{ else }}{{ .Title }}{{ end }}

-{{ if .Content }}

{{ .Content }}

{{ end }} +

+ {{ if .Params.header }} + {{ .Params.header }} + {{ else }} + {{ .Title }} + {{ end }} +

+ + {{ with .Content }} + {{ . }} + {{ end }}
-
-{{ range $index, $pages := $paginator.Pages }} +
+ {{ range $index, $pages := $paginator.Pages }} {{ partial "list/default" . }} -{{ end }} + {{ end }}
-{{ partial "list/components/pagination" . }} +{{ if gt $paginator.TotalPages 1 }} + {{ partial "list/pagination" . }} +{{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 13aa7d0..80c3bee 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,3 +1,43 @@ {{ define "main" }} -{{ partial "single/default" . }} -{{ end }} \ No newline at end of file + +
+
+

{{ .Title }}

+ +
+ {{/* Publish date */}} + + + {{/* Categories */}} + {{ with (.GetTerms "categories") }} — + {{ range . }} + + {{ .LinkTitle }} + + {{ end }} + {{ end }} +
+
+ + {{ partial "single/table-of-contents" . }} + +
{{ .Content | emojify }}
+ + {{ partial "single/comments/index" . }} + + +
+ +{{ end }} diff --git a/layouts/index.html b/layouts/index.html index 7f31f64..7cf7b9d 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,17 +1,9 @@ -{{ define "main" }} -{{ if site.Params.isSinglePage }} -{{ partial "single/homepage" . }} -{{ else }} -{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} -{{ $paginator := .Paginate $pages }} -
-

Latest Posts

+{{ define "main" }} + +
+

{{ .Title }}

-
-{{ range $index, $pages := $paginator.Pages }} - {{ partial "list/default" . }} -{{ end }} -
-{{ partial "list/components/pagination" . }} -{{ end }} + +
{{ .Content }}
+ {{ end }} \ No newline at end of file diff --git a/layouts/partials/footer/copyright.html b/layouts/partials/footer/copyright.html index b24cc2c..d2c9828 100644 --- a/layouts/partials/footer/copyright.html +++ b/layouts/partials/footer/copyright.html @@ -1,3 +1,12 @@ -
- © {{ replace .Site.Copyright "{year}" now.Year }} — {{ .Site.Title }} with Lowkey -
\ No newline at end of file +
+ © {{ replace .Site.Copyright "{year}" now.Year }} — + {{ .Site.Title }} + with + + Lowkey + +
diff --git a/layouts/partials/footer/index.html b/layouts/partials/footer/index.html new file mode 100644 index 0000000..73f32ae --- /dev/null +++ b/layouts/partials/footer/index.html @@ -0,0 +1,4 @@ +
+ {{ partial "footer/copyright" . }} + {{ partial "footer/social" . }} +
\ No newline at end of file diff --git a/layouts/partials/footer/social.html b/layouts/partials/footer/social.html index 0b70dd6..ddf867c 100644 --- a/layouts/partials/footer/social.html +++ b/layouts/partials/footer/social.html @@ -1,5 +1,11 @@ -
-
    - {{ with site.Menus.social }}{{ range . }}
  • {{ .Name }}
  • {{ end }}{{ end }} -
-
\ No newline at end of file +
+
    + {{ with site.Menus.social }} + {{ range . }} +
  • + {{ .Name }} +
  • + {{ end }} + {{ end }} +
+
diff --git a/layouts/partials/head/index.html b/layouts/partials/head/index.html new file mode 100644 index 0000000..eb096b8 --- /dev/null +++ b/layouts/partials/head/index.html @@ -0,0 +1,2 @@ +{{- partial "head/meta" . -}} +{{- partial "head/styles" . -}} diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 23a770a..329d9bf 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,12 +1,32 @@ - - - +{{ $favicon := resources.GetMatch .Site.Params.favicon }} + + + + {{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }}{{ end }} - - - -{{ with .OutputFormats.Get "rss" -}} -{{ printf ` -` .Rel .MediaType.Type .Permalink site.Title | safeHTML }} -{{ end }} \ No newline at end of file + + + + + + +{{ if .Site.Config.Services.GoogleAnalytics.ID }} + + + + +{{ end }} diff --git a/layouts/partials/head/styles.html b/layouts/partials/head/styles.html index 68577ce..cfab45a 100644 --- a/layouts/partials/head/styles.html +++ b/layouts/partials/head/styles.html @@ -1,13 +1,17 @@ -{{/* Resources */}} -{{- $tailwind := resources.Get "css/tailwind.css" | postCSS (dict "config" "./config/postcss.config.js") -}} +{{/* Resources */}} +{{- $tailwind := resources.Get "css/tailwind.css" | postCSS (dict "config" "./config/postcss.config.js") -}} -{{/* Processor */}} -{{- $styles := slice $tailwind | resources.Concat "css/app.css" -}} +{{/* MathJax */}} + + -{{/* Output */}} +{{/* Processor */}} +{{- $styles := slice $tailwind | resources.Concat "css/app.css" -}} + +{{/* Output */}} {{- if eq hugo.Environment "development" -}} - -{{- else -}} -{{- $styles := $styles | minify | fingerprint | resources.PostProcess -}} - + +{{- else -}} + {{- $styles := $styles | minify | fingerprint | resources.PostProcess -}} + {{- end -}} diff --git a/layouts/partials/header/avatar.html b/layouts/partials/header/avatar.html index e3c1021..5c9447d 100644 --- a/layouts/partials/header/avatar.html +++ b/layouts/partials/header/avatar.html @@ -1,7 +1,14 @@ -{{ $avatar := resources.GetMatch .Site.Params.avatar }} +{{ $avatar := resources.GetMatch .Site.Params.avatar }} {{ $tiny := ($avatar.Fill "80x80 q90") }} -
- - {{ .Site.Title }} - + + diff --git a/layouts/partials/header/index.html b/layouts/partials/header/index.html new file mode 100644 index 0000000..43debba --- /dev/null +++ b/layouts/partials/header/index.html @@ -0,0 +1,8 @@ +
+ {{ partial "header/avatar" . }} + +
+ {{ partial "header/title" . }} + {{ partial "header/nav" . }} +
+
diff --git a/layouts/partials/header/nav.html b/layouts/partials/header/nav.html index c0c20b3..94b073d 100644 --- a/layouts/partials/header/nav.html +++ b/layouts/partials/header/nav.html @@ -1,10 +1,14 @@ \ No newline at end of file +
    + {{ $currentPage := . }} + {{ range site.Menus.main }} + {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }} + {{- $page_url := $currentPage.Permalink | absLangURL }} +
  • + + {{ .Name }} + +
  • + {{ end }} +
+ diff --git a/layouts/partials/header/theme-button.html b/layouts/partials/header/theme-button.html new file mode 100644 index 0000000..0a8313b --- /dev/null +++ b/layouts/partials/header/theme-button.html @@ -0,0 +1,47 @@ + + + \ No newline at end of file diff --git a/layouts/partials/header/title.html b/layouts/partials/header/title.html index d6e6ba3..11bc434 100644 --- a/layouts/partials/header/title.html +++ b/layouts/partials/header/title.html @@ -1,7 +1,3 @@ - {{ if .IsHome }} -

{{ .Site.Title }}

- {{ else }} -

{{ .Site.Title }}

- {{ end }} -
\ No newline at end of file +

{{ .Site.Title }}

+ diff --git a/layouts/partials/list/default.html b/layouts/partials/list/default.html index a965ce5..f3fd20e 100644 --- a/layouts/partials/list/default.html +++ b/layouts/partials/list/default.html @@ -1,11 +1,28 @@ \ No newline at end of file +
+ + + diff --git a/layouts/partials/list/pagination.html b/layouts/partials/list/pagination.html new file mode 100644 index 0000000..2e9487c --- /dev/null +++ b/layouts/partials/list/pagination.html @@ -0,0 +1,23 @@ +{{ $paginator := .Paginator }} + +
+ +
+ {{ if $paginator.HasPrev }} + + {{ partial "utils/icon" "arrow-left" }} + Newer Posts + + {{ end }} +
+ + +
+ {{ if $paginator.HasNext }} + + Older Posts + {{ partial "utils/icon" "arrow-right" }} + + {{ end }} +
+
diff --git a/layouts/partials/single/comments/disqus.html b/layouts/partials/single/comments/disqus.html new file mode 100644 index 0000000..b794098 --- /dev/null +++ b/layouts/partials/single/comments/disqus.html @@ -0,0 +1,4 @@ +
+ {{/* https://gohugo.io/templates/internal/#disqus */}} + {{- template "_internal/disqus.html" . -}} +
\ No newline at end of file diff --git a/layouts/partials/single/comments/giscus.html b/layouts/partials/single/comments/giscus.html new file mode 100644 index 0000000..00cfec1 --- /dev/null +++ b/layouts/partials/single/comments/giscus.html @@ -0,0 +1,22 @@ +
+ +
\ No newline at end of file diff --git a/layouts/partials/single/comments/index.html b/layouts/partials/single/comments/index.html new file mode 100644 index 0000000..5a4a1c3 --- /dev/null +++ b/layouts/partials/single/comments/index.html @@ -0,0 +1,11 @@ +{{ if .IsPage }} + + {{ if .Site.Params.giscus.enable }} + {{ partial "single/comments/giscus" . }} + {{ end }} + + + {{ if .Site.Params.disqusShortname }} + {{ partial "single/comments/disqus" . }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/single/table-of-contents.html b/layouts/partials/single/table-of-contents.html new file mode 100644 index 0000000..b8489bc --- /dev/null +++ b/layouts/partials/single/table-of-contents.html @@ -0,0 +1,6 @@ +{{ if and .TableOfContents .Params.tableOfContents }} + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/utils/icon.html b/layouts/partials/utils/icon.html new file mode 100644 index 0000000..7f72418 --- /dev/null +++ b/layouts/partials/utils/icon.html @@ -0,0 +1,7 @@ +{{- $iconFile := resources.GetMatch (printf "icons/%s.svg" .) -}} + +{{- if $iconFile -}} + {{- $iconFile.Content | safeHTML -}} +{{- else -}} + {{- errorf "Error: icon '%s.svg' is not found under 'assets/icons' folder" . -}} +{{- end -}} \ No newline at end of file diff --git a/layouts/shortcodes/alert.html b/layouts/shortcodes/alert.html new file mode 100644 index 0000000..3a55964 --- /dev/null +++ b/layouts/shortcodes/alert.html @@ -0,0 +1,73 @@ +{{ $severity := .Get 0 }} +{{ $title := .Get 1 }} + +
+ {{ if $title }} +

{{ $title }}

+ {{ end }} +

+ {{ if eq $severity "info" }} + + + + {{ else if eq $severity "warning" }} + + + + {{ else if eq $severity "error" }} + + + + {{ else if eq $severity "success" }} + + + + + {{ end }} + {{.Inner}} +

+
diff --git a/layouts/shortcodes/details.html b/layouts/shortcodes/details.html new file mode 100644 index 0000000..ca524f7 --- /dev/null +++ b/layouts/shortcodes/details.html @@ -0,0 +1,75 @@ +{{- /* +Renders an HTML details element. + +@param {string} [class] The value of the element's class attribute. +@param {string} [name] The value of the element's name attribute. +@param {string} [summary] The content of the child summary element. +@param {string} [title] The value of the element's title attribute. +@param {bool} [open=false] Whether to initially display the content of the details element. + +@reference https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details + +@examples + + {{< details >}} + A basic collapsible section. + {{< /details >}} + + {{< details summary="Custom Summary Text" >}} + Showing custom `summary` text. + {{< /details >}} + + {{< details summary="Open Details" open=true >}} + Contents displayed initially by using `open`. + {{< /details >}} + + {{< details summary="Styled Content" class="my-custom-class" >}} + Content can be styled with CSS by specifying a `class`. + + Target details element: + + ```css + details.my-custom-class { } + ``` + + Target summary element: + + ```css + details.my-custom-class > summary > * { } + ``` + + Target inner content: + + ```css + details.my-custom-class > :not(summary) { } + ``` + {{< /details >}} + + {{< details summary="Grouped Details" name="my-details" >}} + Specifying a `name` allows elements to be connected, with only one able to be open at a time. + {{< /details >}} + +*/}} + +{{- /* Get arguments. */}} +{{- $class := or (.Get "class") "" }} +{{- $name := or (.Get "name") "" }} +{{- $summary := or (.Get "summary") "Details" }} +{{- $title := or (.Get "title") "" }} +{{- $open := false }} +{{- if in (slice "false" false 0) (.Get "open") }} + {{- $open = false }} +{{- else if in (slice "true" true 1) (.Get "open") }} + {{- $open = true }} +{{- end }} + +{{- /* Render. */}} +
+ {{ $summary | .Page.RenderString }} + {{ .Inner | .Page.RenderString (dict "display" "block") -}} +
\ No newline at end of file diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index a0673a3..45ce3da 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -1,23 +1,16 @@ -{{/* Image Resources */}} -{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL ))}} -{{ $alt := .Get "alt"}} +{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL )) }} +{{ $alt := .Get "alt" }} +{{ $caption := .Get "caption" }} +{{ $captionPosition := .Get "caption-position" }} -{{/* Image Processing */}} -{{ $command := .Get "size-method" }} -{{ $options := .Get "size-format" }} -{{ if eq $command "Fit"}} - {{ $img = $img.Fit $options }} -{{ else if eq $command "Resize"}} - {{ $img = $img.Resize $options }} -{{ else if eq $command "Fill"}} - {{ $img = $img.Fill $options }} -{{ else if eq $command "Crop"}} - {{ $img = $img.Crop $options }} -{{ end }} - -{{/* Position */}} -{{ $position := .Get "position" }} - -
- +
+ {{ . }} + + {{ with $caption }} +
+ {{ . }} +
+ {{ end }}
\ No newline at end of file diff --git a/layouts/shortcodes/task-list.html b/layouts/shortcodes/task-list.html new file mode 100644 index 0000000..fe4ffe7 --- /dev/null +++ b/layouts/shortcodes/task-list.html @@ -0,0 +1 @@ + diff --git a/layouts/taxonomies/home.html b/layouts/taxonomies/home.html index 6a7dce5..0ee22c5 100644 --- a/layouts/taxonomies/home.html +++ b/layouts/taxonomies/home.html @@ -1,17 +1,29 @@ -{{ define "main" }} -{{ $pages := .Pages }} +{{ define "main" }} +
-

{{ if .Params.header }}{{ .Params.header }}{{ else }}{{ .Title }}{{ end }}

-{{ if .Content }}

{{ .Content }}

{{ end }} +

+ {{ if .Params.header }} + {{ .Params.header }} + {{ else }} + {{ .Title }} + {{ end }} +

+ + {{ with .Content }} + {{ . }} + {{ end }}
-
-
- {{ end }} -- cgit v1.3