mirror of
https://github.com/imfing/hextra.git
synced 2025-05-13 17:26:25 -04:00
refactor: update page width handling and CSS structure
- Changed the default page width from 1280px to 80rem in hugo.yaml. - Replaced dynamic page width partials with a new CSS class 'hextra-max-page-width' across multiple layout files for consistency. - Introduced a new head-config-css.html partial for managing CSS styles related to page width. - Removed the outdated page-width utility partial to streamline the codebase.
This commit is contained in:
parent
83fda0109f
commit
41ef0c7cd8
@ -122,7 +122,7 @@ params:
|
||||
width: wide
|
||||
|
||||
page:
|
||||
# full (100%), wide (90rem), normal (1280px)
|
||||
# full (100%), wide (90rem), normal (80rem)
|
||||
width: normal
|
||||
|
||||
theme:
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" .) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
{{ partial "toc.html" (dict "Params" (dict "toc" false)) }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
{{ partial "toc.html" (dict "Params" (dict "toc" false)) }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{ define "main" }}
|
||||
{{- $readMore := (T "readMore") | default "Read more →" -}}
|
||||
<div class="hx:mx-auto hx:flex {{ partial `utils/page-width` . }}">
|
||||
<div class="hx:mx-auto hx:flex hextra-max-page-width">
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
<main class="hx:w-full hx:min-w-0 hx:max-w-6xl hx:px-6 hx:pt-4 hx:md:px-12">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class="hx:mx-auto hx:flex {{ partial `utils/page-width` . }}">
|
||||
<div class="hx:mx-auto hx:flex hextra-max-page-width">
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" .) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" .) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }}
|
||||
<div class="hx:w-full hx:break-words hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:pb-8 hx:pt-8 hx:md:pt-12 hx:pl-[max(env(safe-area-inset-left),1.5rem)] hx:pr-[max(env(safe-area-inset-left),1.5rem)]">
|
||||
<div class="hx:flex hx:flex-col hx:items-start">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{ define "main" }}
|
||||
<div class='hx:mx-auto hx:flex {{ partial "utils/page-width" . }}'>
|
||||
<div class='hx:mx-auto hx:flex hextra-max-page-width'>
|
||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
|
||||
{{ partial "toc.html" . }}
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
|
15
layouts/partials/head-config-css.html
Normal file
15
layouts/partials/head-config-css.html
Normal file
@ -0,0 +1,15 @@
|
||||
{{- $pageWidth := .Site.Params.page.width | default .Params.width -}}
|
||||
{{- $maxPageWidth := cond (eq $pageWidth "wide") "90rem" (cond (eq $pageWidth "full") "100%" "80rem") -}}
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--hextra-max-page-width: {{ $maxPageWidth }};
|
||||
}
|
||||
|
||||
.hextra-max-page-width {
|
||||
width: 100%;
|
||||
max-width: var(--hextra-max-page-width);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
</style>
|
@ -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) }}
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
|
||||
{{- else }}
|
||||
{{- $styles := resources.Get "css/compiled/main.css" -}}
|
||||
|
||||
{{- if hugo.IsProduction }}
|
||||
{{- $styles = $styles | minify | fingerprint }}
|
||||
<link rel="preload" href="{{ $styles.RelPermalink }}" as="style" integrity="{{ $styles.Data.Integrity }}" />
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" integrity="{{ $styles.Data.Integrity }}" />
|
||||
{{- else }}
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<!-- Custom CSS -->
|
||||
{{- $custom := resources.Get "css/custom.css" }}
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $custom = $custom | minify | fingerprint }}
|
||||
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" integrity="{{ $custom.Data.Integrity }}" />
|
||||
{{- else }}
|
||||
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" />
|
||||
{{- end }}
|
@ -27,8 +27,33 @@
|
||||
{{- template "_internal/schema.html" . -}}
|
||||
{{- template "_internal/twitter_cards.html" . -}}
|
||||
|
||||
{{- partialCached "head-css.html" . -}}
|
||||
{{- partial "head-config-css.html" . -}}
|
||||
|
||||
{{- if and (not hugo.IsProduction) (eq hugo.Environment "theme") }}
|
||||
{{- $styles := resources.Get "css/styles.css" }}
|
||||
{{- $styles = $styles | postCSS (dict "inlineImports" true) }}
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
|
||||
{{- else }}
|
||||
{{- $styles := resources.Get "css/compiled/main.css" -}}
|
||||
|
||||
{{- if hugo.IsProduction }}
|
||||
{{- $styles = $styles | minify | fingerprint }}
|
||||
<link rel="preload" href="{{ $styles.RelPermalink }}" as="style" integrity="{{ $styles.Data.Integrity }}" />
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" integrity="{{ $styles.Data.Integrity }}" />
|
||||
{{- else }}
|
||||
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<!-- Custom CSS -->
|
||||
{{- $custom := resources.Get "css/custom.css" }}
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $custom = $custom | minify | fingerprint }}
|
||||
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" integrity="{{ $custom.Data.Integrity }}" />
|
||||
{{- else }}
|
||||
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" />
|
||||
{{- end }}
|
||||
|
||||
<!-- Google Analytics -->
|
||||
{{- if and (eq hugo.Environment "production") .Site.Config.Services.GoogleAnalytics.ID }}
|
||||
|
@ -1,27 +0,0 @@
|
||||
{{/* 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 = "hx:max-w-[90rem]" -}}
|
||||
{{ else if eq . "full" -}}
|
||||
{{ $pageWidth = "max-w-full" -}}
|
||||
{{ else -}}
|
||||
{{ $pageWidth = "hx:max-w-screen-xl" -}}
|
||||
{{ end -}}
|
||||
{{ else -}}
|
||||
{{ $pageWidth = "hx:max-w-screen-xl" -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ return $pageWidth }}
|
Loading…
x
Reference in New Issue
Block a user