Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing custom templates from assets #269

Closed
iranzo opened this issue May 27, 2021 · 2 comments
Closed

Allowing custom templates from assets #269

iranzo opened this issue May 27, 2021 · 2 comments

Comments

@iranzo
Copy link

iranzo commented May 27, 2021

Hi,
Not sure if I got it wrong, but looks like:

{{ range .Site.Params.customCSS -}}
doesn't process assets folder as it's not using the get resource like it does for the standard css/style.css (https://gohugo.io/hugo-pipes/introduction/#asset-directory)

PaperMod, for example uses this approach:

https://github.com/adityatelange/hugo-PaperMod/blob/master/layouts/partials/head.html#L40

@iranzo
Copy link
Author

iranzo commented May 27, 2021

Something like this will enable the support (and probably easier than just adding a params.customCSS)

diff --git a/themes/mainroad/layouts/_default/baseof.html b/themes/mainroad/layouts/_default/baseof.html
index f4d4b6d..965c8f9 100644
--- a/themes/mainroad/layouts/_default/baseof.html
+++ b/themes/mainroad/layouts/_default/baseof.html
@@ -25,11 +25,22 @@
        <link rel="stylesheet" {{ printf `href="%s"` $googleFontsLink | safeHTMLAttr }}>
        {{- end }}
 
-       {{ $style := resources.Get "css/style.css" | resources.ExecuteAsTemplate "css/style.css" . -}}
-       <link rel="stylesheet" href="{{ $style.RelPermalink }}">
-       {{ range .Site.Params.customCSS -}}
-       <link rel="stylesheet" href="{{ . | relURL }}">
-       {{- end }}
+{{- /* Styles */}}
+{{- $theme_vars := (resources.Get "css/style.css") }}
+{{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }}
+
+
+{{- /* order is important */}}
+{{- $stylesheet := (slice $theme_vars $common) | resources.Concat "assets/css/core.css" | minify}}
+
+{{- if not .Site.Params.assets.disableFingerprinting }}
+{{- $stylesheet := $stylesheet | fingerprint }}
+<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet" as="style">
+{{- else }}
+<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style">
+{{- end }}
+

@Vimux
Copy link
Owner

Vimux commented May 27, 2021

No, thanks. I have no plans to change how it works, especially this way. Diff looks like copy-paste, it won't even work correctly, but I get it.

Duplicate #162 (sort of). You can suggest your ideas there.

@Vimux Vimux closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants