forked from drowl87/hextra_mirror
feat: support wide and full page modes (#69)
* feat: add page width config and partial * feat: use page-width partial in layouts * chore: revert changes in navbar and footer * feat: customize footer width from site config * chore: update styles * docs: add page width * feat: allow overriding navbar width * fix: navbar width variable * docs: add instruction for navbar and footer
This commit is contained in:
parent
c799160e86
commit
b51bfa3177
@ -779,6 +779,9 @@ video {
|
|||||||
.max-w-\[min\(calc\(100vw-2rem\)\2c calc\(100\%\+20rem\)\)\] {
|
.max-w-\[min\(calc\(100vw-2rem\)\2c calc\(100\%\+20rem\)\)\] {
|
||||||
max-width: min(calc(100vw - 2rem),calc(100% + 20rem));
|
max-width: min(calc(100vw - 2rem),calc(100% + 20rem));
|
||||||
}
|
}
|
||||||
|
.max-w-full {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
.max-w-none {
|
.max-w-none {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
@ -180,3 +180,20 @@ Include both `favicon.ico` and `favicon.svg` files in your project to ensure you
|
|||||||
|
|
||||||
While `favicon.ico` is generally for older browsers, `favicon.svg` is supported by modern ones. The optional `favicon-dark.svg` can be included for a tailored experience in dark mode.
|
While `favicon.ico` is generally for older browsers, `favicon.svg` is supported by modern ones. The optional `favicon-dark.svg` can be included for a tailored experience in dark mode.
|
||||||
Feel free to use tools like [favicon.io](https://favicon.io/) or [favycon](https://github.com/ruisaraiva19/favycon) to generate these icons.
|
Feel free to use tools like [favicon.io](https://favicon.io/) or [favycon](https://github.com/ruisaraiva19/favycon) to generate these icons.
|
||||||
|
|
||||||
|
|
||||||
|
### Page Width
|
||||||
|
|
||||||
|
The width of the page can be customized by the `params.page.width` parameter in the config file:
|
||||||
|
|
||||||
|
```yaml {filename="hugo.yaml"}
|
||||||
|
params:
|
||||||
|
page:
|
||||||
|
# full (100%), wide (90rem), normal (1280px)
|
||||||
|
width: wide
|
||||||
|
```
|
||||||
|
|
||||||
|
There are three available options: `full`, `wide`, and `normal`.
|
||||||
|
By default, the page width is set to `normal`.
|
||||||
|
|
||||||
|
Similarly, the width of the navbar and footer can be customized by the `params.navbar.width` and `params.footer.width` parameters.
|
||||||
|
@ -30,7 +30,7 @@ languages:
|
|||||||
module:
|
module:
|
||||||
hugoVersion:
|
hugoVersion:
|
||||||
extended: true
|
extended: true
|
||||||
min: "0.111.0"
|
min: "0.112.0"
|
||||||
|
|
||||||
workspace: hugo.work
|
workspace: hugo.work
|
||||||
imports:
|
imports:
|
||||||
@ -93,13 +93,19 @@ params:
|
|||||||
logo:
|
logo:
|
||||||
path: images/logo.svg
|
path: images/logo.svg
|
||||||
dark: images/logo-dark.svg
|
dark: images/logo-dark.svg
|
||||||
# link: /
|
|
||||||
# width: 40
|
# width: 40
|
||||||
# height: 20
|
# height: 20
|
||||||
|
# link: /
|
||||||
|
width: wide
|
||||||
|
|
||||||
|
page:
|
||||||
|
# full (100%), wide (90rem), normal (1280px)
|
||||||
|
width: normal
|
||||||
|
|
||||||
footer:
|
footer:
|
||||||
displayCopyright: true
|
displayCopyright: true
|
||||||
displayPoweredBy: true
|
displayPoweredBy: true
|
||||||
|
width: normal
|
||||||
|
|
||||||
displayUpdatedDate: true
|
displayUpdatedDate: true
|
||||||
dateFormat: "January 2, 2006"
|
dateFormat: "January 2, 2006"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" .) }}
|
{{ partial "sidebar.html" (dict "context" .) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">
|
<main class="w-full min-w-0 max-w-6xl px-6 pt-4 md:px-12">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" .) }}
|
{{ partial "sidebar.html" (dict "context" .) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" .) }}
|
{{ partial "sidebar.html" (dict "context" .) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-screen-xl">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }}
|
||||||
<div class="w-full break-words flex flex-col min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-start pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<div class="w-full break-words flex flex-col min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-start pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<section class="flex max-w-[90rem] flex-col items-start gap-2 px-6 sm:px-4 pt-8 md:pt-12">
|
<section class="flex max-w-[90rem] flex-col items-start gap-2 px-6 sm:px-4 pt-8 md:pt-12">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<div class="mx-auto flex max-w-[90rem]">
|
<div class='mx-auto flex {{ partial "utils/page-width" . }}'>
|
||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="w-full break-words flex min-h-[calc(100vh-var(--navbar-height))] min-w-0 justify-center pb-8 pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
|
@ -2,17 +2,25 @@
|
|||||||
|
|
||||||
{{- $copyright := (T "copyright") | default "© 2023 Hextra." -}}
|
{{- $copyright := (T "copyright") | default "© 2023 Hextra." -}}
|
||||||
|
|
||||||
|
{{- $footerWidth := "max-w-screen-xl" -}}
|
||||||
|
{{- with .Site.Params.footer.width -}}
|
||||||
|
{{ if eq . "wide" -}}
|
||||||
|
{{ $footerWidth = "max-w-[90rem]" -}}
|
||||||
|
{{ else if eq . "full" -}}
|
||||||
|
{{ $footerWidth = "max-w-full" -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
<footer class="hextra-footer bg-gray-100 pb-[env(safe-area-inset-bottom)] dark:bg-neutral-900 print:bg-transparent">
|
<footer class="hextra-footer bg-gray-100 pb-[env(safe-area-inset-bottom)] dark:bg-neutral-900 print:bg-transparent">
|
||||||
{{- if $enableFooterSwitches }}
|
{{- if $enableFooterSwitches }}
|
||||||
<div class="mx-auto flex max-w-screen-xl gap-2 py-2 px-4">
|
<div class='mx-auto flex gap-2 py-2 px-4 {{ $footerWidth }}'>
|
||||||
{{- partial "language-switch.html" (dict "context" .) -}}
|
{{- partial "language-switch.html" (dict "context" .) -}}
|
||||||
{{- partial "theme-toggle.html" -}}
|
{{- partial "theme-toggle.html" -}}
|
||||||
</div>
|
</div>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<hr class="dark:border-neutral-800" />
|
<hr class="dark:border-neutral-800" />
|
||||||
<div
|
<div
|
||||||
class="mx-auto flex max-w-screen-xl justify-center py-12 pl-[max(env(safe-area-inset-left),1.5rem)] pr-[max(env(safe-area-inset-right),1.5rem)] text-gray-600 dark:text-gray-400 md:justify-start"
|
class='{{ $footerWidth }} mx-auto flex justify-center py-12 pl-[max(env(safe-area-inset-left),1.5rem)] pr-[max(env(safe-area-inset-right),1.5rem)] text-gray-600 dark:text-gray-400 md:justify-start'
|
||||||
>
|
>
|
||||||
<div class="flex w-full flex-col items-center sm:items-start">
|
<div class="flex w-full flex-col items-center sm:items-start">
|
||||||
{{- if (.Site.Params.footer.displayPoweredBy | default true) }}<div class="font-semibold">{{ template "theme-credit" . }}</div>{{ end }}
|
{{- if (.Site.Params.footer.displayPoweredBy | default true) }}<div class="font-semibold">{{ template "theme-credit" . }}</div>{{ end }}
|
||||||
|
@ -4,11 +4,19 @@
|
|||||||
{{- $logoHeight := .Site.Params.navbar.logo.height | default "20" -}}
|
{{- $logoHeight := .Site.Params.navbar.logo.height | default "20" -}}
|
||||||
{{- $logoDarkPath := .Site.Params.navbar.logo.dark | default $logoPath -}}
|
{{- $logoDarkPath := .Site.Params.navbar.logo.dark | default $logoPath -}}
|
||||||
|
|
||||||
|
{{- $navWidth := "max-w-[90rem]" -}}
|
||||||
|
{{- with .Site.Params.navbar.width -}}
|
||||||
|
{{ if eq . "normal" -}}
|
||||||
|
{{ $navWidth = "max-w-screen-xl" -}}
|
||||||
|
{{ else if eq . "full" -}}
|
||||||
|
{{ $navWidth = "max-w-full" -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
<div class="nav-container sticky top-0 z-20 w-full bg-transparent print:hidden">
|
<div class="nav-container sticky top-0 z-20 w-full bg-transparent print:hidden">
|
||||||
<div class="nav-container-blur pointer-events-none absolute z-[-1] h-full w-full bg-white dark:bg-dark shadow-[0_2px_4px_rgba(0,0,0,.02),0_1px_0_rgba(0,0,0,.06)] contrast-more:shadow-[0_0_0_1px_#000] dark:shadow-[0_-1px_0_rgba(255,255,255,.1)_inset] contrast-more:dark:shadow-[0_0_0_1px_#fff]"></div>
|
<div class="nav-container-blur pointer-events-none absolute z-[-1] h-full w-full bg-white dark:bg-dark shadow-[0_2px_4px_rgba(0,0,0,.02),0_1px_0_rgba(0,0,0,.06)] contrast-more:shadow-[0_0_0_1px_#000] dark:shadow-[0_-1px_0_rgba(255,255,255,.1)_inset] contrast-more:dark:shadow-[0_0_0_1px_#fff]"></div>
|
||||||
|
|
||||||
<nav class="mx-auto flex items-center justify-end gap-2 h-16 px-6 max-w-[90rem]">
|
<nav class="mx-auto flex items-center justify-end gap-2 h-16 px-6 {{ $navWidth }}">
|
||||||
<a class="flex items-center hover:opacity-75 ltr:mr-auto rtl:ml-auto" href="{{ $logoLink }}">
|
<a class="flex items-center hover:opacity-75 ltr:mr-auto rtl:ml-auto" href="{{ $logoLink }}">
|
||||||
{{- if (.Site.Params.navbar.displayLogo | default true) }}
|
{{- if (.Site.Params.navbar.displayLogo | default true) }}
|
||||||
<img class="block dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
|
<img class="block dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
|
||||||
|
27
layouts/partials/utils/page-width.html
Normal file
27
layouts/partials/utils/page-width.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{{/* Get page width from site configuration */}}
|
||||||
|
|
||||||
|
{{/* Default page width */}}
|
||||||
|
{{- $pageWidth := "" -}}
|
||||||
|
|
||||||
|
{{/* Get page width setting from page front matter or site params */}}
|
||||||
|
{{ with .Params.width -}}
|
||||||
|
{{ $pageWidth = . -}}
|
||||||
|
{{ else -}}
|
||||||
|
{{ with .Site.Params.page.width -}}
|
||||||
|
{{ $pageWidth = . -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{- with $pageWidth -}}
|
||||||
|
{{ if eq . "wide" -}}
|
||||||
|
{{ $pageWidth = "max-w-[90rem]" -}}
|
||||||
|
{{ else if eq . "full" -}}
|
||||||
|
{{ $pageWidth = "max-w-full" -}}
|
||||||
|
{{ else -}}
|
||||||
|
{{ $pageWidth = "max-w-screen-xl" -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{ else -}}
|
||||||
|
{{ $pageWidth = "max-w-screen-xl" -}}
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{ return $pageWidth }}
|
@ -14,6 +14,11 @@ module.exports = {
|
|||||||
content: [
|
content: [
|
||||||
'./**/hugo_stats.json',
|
'./**/hugo_stats.json',
|
||||||
],
|
],
|
||||||
|
safelist: [
|
||||||
|
'max-w-screen-xl',
|
||||||
|
'max-w-[90rem]',
|
||||||
|
'max-w-full'
|
||||||
|
],
|
||||||
theme: {
|
theme: {
|
||||||
screens: {
|
screens: {
|
||||||
sm: '640px',
|
sm: '640px',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user