From e503367a1adff7a62f4d7773f06f071f910ffc5a Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:28:55 +0530 Subject: [PATCH] [BREAKING] Split-up css into sub-parts (#317) * Move styles into 3 different locations - core - common - hljs * Load all stylesheets in proper order --- assets/css/{ => common}/404.css | 0 assets/css/{ => common}/archive.css | 0 assets/css/{ => common}/footer.css | 0 assets/css/{ => common}/header.css | 0 assets/css/{ => common}/main.css | 0 assets/css/{ => common}/post-entry.css | 0 assets/css/{ => common}/post-single.css | 0 assets/css/{ => common}/profile-mode.css | 0 assets/css/{ => common}/search.css | 0 assets/css/{ => common}/terms.css | 0 assets/css/{ => core}/reset.css | 0 assets/css/{ => core}/theme-vars.css | 0 assets/css/{ => core}/zmedia.css | 0 assets/css/{ => hljs}/an-old-hope.min.css | 0 layouts/partials/head.html | 11 +++++++++-- 15 files changed, 9 insertions(+), 2 deletions(-) rename assets/css/{ => common}/404.css (100%) rename assets/css/{ => common}/archive.css (100%) rename assets/css/{ => common}/footer.css (100%) rename assets/css/{ => common}/header.css (100%) rename assets/css/{ => common}/main.css (100%) rename assets/css/{ => common}/post-entry.css (100%) rename assets/css/{ => common}/post-single.css (100%) rename assets/css/{ => common}/profile-mode.css (100%) rename assets/css/{ => common}/search.css (100%) rename assets/css/{ => common}/terms.css (100%) rename assets/css/{ => core}/reset.css (100%) rename assets/css/{ => core}/theme-vars.css (100%) rename assets/css/{ => core}/zmedia.css (100%) rename assets/css/{ => hljs}/an-old-hope.min.css (100%) diff --git a/assets/css/404.css b/assets/css/common/404.css similarity index 100% rename from assets/css/404.css rename to assets/css/common/404.css diff --git a/assets/css/archive.css b/assets/css/common/archive.css similarity index 100% rename from assets/css/archive.css rename to assets/css/common/archive.css diff --git a/assets/css/footer.css b/assets/css/common/footer.css similarity index 100% rename from assets/css/footer.css rename to assets/css/common/footer.css diff --git a/assets/css/header.css b/assets/css/common/header.css similarity index 100% rename from assets/css/header.css rename to assets/css/common/header.css diff --git a/assets/css/main.css b/assets/css/common/main.css similarity index 100% rename from assets/css/main.css rename to assets/css/common/main.css diff --git a/assets/css/post-entry.css b/assets/css/common/post-entry.css similarity index 100% rename from assets/css/post-entry.css rename to assets/css/common/post-entry.css diff --git a/assets/css/post-single.css b/assets/css/common/post-single.css similarity index 100% rename from assets/css/post-single.css rename to assets/css/common/post-single.css diff --git a/assets/css/profile-mode.css b/assets/css/common/profile-mode.css similarity index 100% rename from assets/css/profile-mode.css rename to assets/css/common/profile-mode.css diff --git a/assets/css/search.css b/assets/css/common/search.css similarity index 100% rename from assets/css/search.css rename to assets/css/common/search.css diff --git a/assets/css/terms.css b/assets/css/common/terms.css similarity index 100% rename from assets/css/terms.css rename to assets/css/common/terms.css diff --git a/assets/css/reset.css b/assets/css/core/reset.css similarity index 100% rename from assets/css/reset.css rename to assets/css/core/reset.css diff --git a/assets/css/theme-vars.css b/assets/css/core/theme-vars.css similarity index 100% rename from assets/css/theme-vars.css rename to assets/css/core/theme-vars.css diff --git a/assets/css/zmedia.css b/assets/css/core/zmedia.css similarity index 100% rename from assets/css/zmedia.css rename to assets/css/core/zmedia.css diff --git a/assets/css/an-old-hope.min.css b/assets/css/hljs/an-old-hope.min.css similarity index 100% rename from assets/css/an-old-hope.min.css rename to assets/css/hljs/an-old-hope.min.css diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 5ba46fe9..4e4099f8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -27,11 +27,18 @@ {{- end}} -{{- $common := (resources.Match "css/*.css") | resources.Concat "assets/css/common.css" }} +{{- $theme_vars := (resources.Get "css/core/theme-vars.css") }} +{{- $reset := (resources.Get "css/core/reset.css") }} +{{- $media := (resources.Get "css/core/zmedia.css") }} +{{- $hljs := (resources.Get "css/hljs/an-old-hope.min.css") }} +{{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }} + +{{- /* order is important */}} +{{- $core := (slice $theme_vars $reset $common $hljs $media) | resources.Concat "assets/css/core.css" }} {{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" }} {{- /* bundle all required css */}} {{- /* Add extended css after theme style */ -}} -{{- $stylesheet := (slice $common $extended) | resources.Concat "assets/css/stylesheet.css" | minify }} +{{- $stylesheet := (slice $core $extended) | resources.Concat "assets/css/stylesheet.css" | minify }} {{- if not .Site.Params.assets.disableFingerprinting }} {{- $stylesheet := $stylesheet | fingerprint -}}