Bundle all CSS into a single file

This commit is contained in:
James Panther 2022-06-17 11:26:11 +10:00
parent 25e68ccb23
commit 5ae1a23727
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
2 changed files with 15 additions and 17 deletions

View File

@ -10,11 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Alt text to author image ([#8](https://github.com/jpanther/lynx/pull/8))
- Expanded Emoji support in page titles
### Changed
- Upgrade to Tailwind v3.1.3 and Typography v0.5.2
- Adjusted contrast of certain text to improve accessibility
- All CSS is now bundled into a single file for better performance
## [1.1.0] - 2021-11-06

View File

@ -10,8 +10,8 @@
<title>{{ .Site.Title }}</title>
<meta name="title" content="{{ .Site.Title }}" />
{{- else -}}
<title>{{ .Title }} &middot; {{ .Site.Title }}</title>
<meta name="title" content="{{ .Title }} &middot; {{ .Site.Title }}" />
<title>{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}</title>
<meta name="title" content="{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}" />
{{- end }}
{{/* Metadata */}}
{{ with .Params.Description -}}
@ -32,25 +32,21 @@
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
{{ end -}}
{{/* Styles */}}
{{ $mainCSS := resources.Get "css/compiled/main.css" }}
{{ $mainStyles := $mainCSS | resources.Minify | resources.Fingerprint "sha512" }}
<link
type="text/css"
rel="stylesheet"
href="{{ $mainStyles.RelPermalink }}"
integrity="{{ $mainStyles.Data.Integrity }}"
/>
{{ $customCSS := resources.Get "css/custom.css" }}
{{ if $customCSS }}
{{ $customStyles := $customCSS | resources.Minify | resources.Fingerprint "sha512" }}
<link
type="text/css"
rel="stylesheet"
href="{{ $customStyles.RelPermalink }}"
integrity="{{ $customStyles.Data.Integrity }}"
/>
{{/* Asset bundles */}}
{{ $assets := newScratch }}
{{ $cssMain := resources.Get "css/compiled/main.css" }}
{{ $assets.Add "css" (slice $cssMain) }}
{{ $cssCustom := resources.Get "css/custom.css" }}
{{ if $cssCustom }}
{{ $assets.Add "css" (slice $cssCustom) }}
{{ end }}
{{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint "sha512" }}
<link
type="text/css"
rel="stylesheet"
href="{{ $bundleCSS.RelPermalink }}"
integrity="{{ $bundleCSS.Data.Integrity }}"
/>
{{/* Icons */}}
{{ if templates.Exists "partials/favicons.html" }}
{{ partialCached "favicons.html" .Site }}