diff --git a/assets/css/variables.css b/assets/css/variables.css new file mode 100644 index 0000000..5cc96ac --- /dev/null +++ b/assets/css/variables.css @@ -0,0 +1,30 @@ +/* Hugo template to derive CSS variables from site and page parameters */ + +/* Do not remove the following comment. It is used by Hugo to render CSS variables. +{{- $pageWidth := .Params.width | default .Site.Params.page.width -}} +{{- $maxPageWidth := cond (eq $pageWidth "wide") "90rem" (cond (eq $pageWidth "full") "100%" "80rem") -}} + +{{- $navbarWidth := .Site.Params.navbar.width -}} +{{- $maxNavbarWidth := cond (eq $navbarWidth "wide") "90rem" (cond (eq $navbarWidth "full") "100%" "80rem") -}} + +{{- $footerWidth := .Site.Params.footer.width -}} +{{- $maxFooterWidth := cond (eq $footerWidth "wide") "90rem" (cond (eq $footerWidth "full") "100%" "80rem") -}} +*/ + +:root { + --hextra-max-page-width: {{ $maxPageWidth }}; + --hextra-max-navbar-width: {{ $maxNavbarWidth }}; + --hextra-max-footer-width: {{ $maxFooterWidth }}; +} + +.hextra-max-page-width { + max-width: var(--hextra-max-page-width); +} + +.hextra-max-navbar-width { + max-width: var(--hextra-max-navbar-width); +} + +.hextra-max-footer-width { + max-width: var(--hextra-max-footer-width); +} diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 9c42586..f948971 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -122,7 +122,7 @@ params: width: wide page: - # full (100%), wide (90rem), normal (1280px) + # full (100%), wide (90rem), normal (80rem) width: normal theme: diff --git a/layouts/_default/list.html b/layouts/_default/list.html index ee041d6..653f6f1 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" .) }} {{ partial "toc.html" . }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6d52394..fe9f338 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }} {{ partial "toc.html" . }}
diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index ea4b982..41add74 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }} {{ partial "toc.html" (dict "Params" (dict "toc" false)) }}
diff --git a/layouts/_default/term.html b/layouts/_default/term.html index ed4c6a4..07ae191 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }} {{ partial "toc.html" (dict "Params" (dict "toc" false)) }}
diff --git a/layouts/blog/list.html b/layouts/blog/list.html index 16dfa6e..5b2cad1 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -1,6 +1,6 @@ {{ define "main" }} {{- $readMore := (T "readMore") | default "Read more →" -}} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 009f755..605fd50 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }} {{ partial "toc.html" . }}
diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 9b9ca94..3c80126 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" .) }} {{ partial "toc.html" . }}
diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 9b9ca94..3c80126 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" .) }} {{ partial "toc.html" . }}
diff --git a/layouts/hextra-home.html b/layouts/hextra-home.html index c0a27cf..8feb85f 100644 --- a/layouts/hextra-home.html +++ b/layouts/hextra-home.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }}
diff --git a/layouts/index.html b/layouts/index.html index c4a8239..6353140 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,5 +1,5 @@ {{ define "main" }} -
+
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }} {{ partial "toc.html" . }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6deeb18..4fd6911 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -6,19 +6,10 @@ {{- $copyright := (T "copyright") | default "© 2024 Hextra." -}} {{- $poweredBy := (T "poweredBy") | default "Powered by Hextra" -}} -{{- $footerWidth := "hx:max-w-screen-xl" -}} -{{- with .Site.Params.footer.width -}} - {{ if eq . "wide" -}} - {{ $footerWidth = "hx:max-w-[90rem]" -}} - {{ else if eq . "full" -}} - {{ $footerWidth = "max-w-full" -}} - {{ end -}} -{{- end -}} -
{{- if $footerSwitchesVisible -}} -
+ @@ -26,21 +17,19 @@
{{- end -}} {{- end -}} + + {{- if $copyrightSectionVisible -}} - {{- if $copyrightSectionVisible -}} -
-
- {{- if (.Site.Params.footer.displayPoweredBy | default true) }}
{{ template "theme-credit" $poweredBy }}
{{- end -}} - {{- if .Site.Params.footer.displayCopyright }}
{{ $copyright | markdownify }}
{{- end -}} -
+
+ {{- if (.Site.Params.footer.displayPoweredBy | default true) }}
{{ template "theme-credit" $poweredBy }}
{{- end -}} + {{- if .Site.Params.footer.displayCopyright }}
{{ $copyright | markdownify }}
{{- end -}}
- {{- end -}} +
+ {{- end -}}
{{- define "theme-credit" -}} diff --git a/layouts/partials/head-css.html b/layouts/partials/head-css.html deleted file mode 100644 index d4f999f..0000000 --- a/layouts/partials/head-css.html +++ /dev/null @@ -1,25 +0,0 @@ -{{- if and (not hugo.IsProduction) (eq hugo.Environment "theme") }} - {{- $styles := resources.Get "css/styles.css" }} - {{- $styles = $styles | postCSS (dict "inlineImports" true) }} - -{{- else }} - {{- $styles := resources.Get "css/compiled/main.css" -}} - - {{- if hugo.IsProduction }} - {{- $styles = $styles | minify | fingerprint }} - - - {{- else }} - - {{- end }} -{{- end }} - - - -{{- $custom := resources.Get "css/custom.css" }} -{{- if hugo.IsProduction -}} - {{- $custom = $custom | minify | fingerprint }} - -{{- else }} - -{{- end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 25ab330..8766abc 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -12,7 +12,7 @@ {{- if .IsHome -}} {{ .Site.Title -}} {{ else -}} - {{ with .Title }}{{ . }} – {{ end -}} + {{ with .Title }}{{ . }} –{{ end -}} {{ .Site.Title -}} {{ end -}} @@ -28,13 +28,26 @@ {{- template "_internal/schema.html" . -}} {{- template "_internal/twitter_cards.html" . -}} - {{- partialCached "head-css.html" . -}} + {{- $mainCss := resources.Get "css/compiled/main.css" -}} + {{- $customCss := resources.Get "css/custom.css" -}} + {{- $variablesCss := resources.Get "css/variables.css" | resources.ExecuteAsTemplate "css/variables.css" . -}} + + {{- if hugo.IsProduction }} + {{- $styles := slice $variablesCss $mainCss $customCss | resources.Concat "css/compiled/main.css" | minify | fingerprint }} + + + {{- else }} + {{- $styles := resources.Get "css/styles.css" | postCSS (dict "inlineImports" true) }} + + + + {{- end }} - {{- if and (eq hugo.Environment "production") .Site.Config.Services.GoogleAnalytics.ID }} + {{- if and hugo.IsProduction .Site.Config.Services.GoogleAnalytics.ID }} - {{ partial "google-analytics.html" . }} + {{ partial "google-analytics.html" . -}} {{- end }}