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

Change/Fix: Include "theme-css/*.scss" files #429

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions layouts/partials/css.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,35 @@
<!-- Fallback font for symbols (such as "🛈"). --
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+Symbols+2">

<!-- SASS -->
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss") | append (resources.Match "css/*.scss") -}}
{{- range $sass -}}

{{- $targetFile := printf "%s.scss" . -}}

{{- if $inServerMode -}}
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts -}}
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}">
{{ else }}
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts | minify | fingerprint -}}
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}">
{{- end -}}
<!-- Process and include Sass files. -->
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss")
| append (resources.Match "theme-css/*.scss")
| append (resources.Match "css/*.scss") -}}

{{- range $sass -}}
{{ with . }} <!-- Skips nil elements from appending empty resources.Match slices. -->
{{- $targetFile := printf "%s.scss" . -}}
{{- if $inServerMode -}}
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts -}}
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}">
{{ else }}
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts | minify | fingerprint -}}
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}">
{{- end -}}
{{- end -}}
{{- end -}}

<!-- Process and include plain CSS files. -->
{{- $themeCssFiles := resources.Match "theme-css/*.css" -}}
{{- $userCssFiles := resources.Match "css/*.css" -}}
{{- $cssFiles := $themeCssFiles | append $userCssFiles }}

{{- range $cssFiles -}}

{{ if $inServerMode -}}
{{ $custom_style := . | resources.ExecuteAsTemplate . $page -}}
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}">
{{ else }}
{{ $custom_style := . | resources.ExecuteAsTemplate . $page | minify | fingerprint -}}
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}" integrity="{{ $custom_style.Data.Integrity }}">
{{- end -}}

{{ if $inServerMode -}}
{{ $custom_style := . | resources.ExecuteAsTemplate . $page -}}
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}">
{{ else }}
{{ $custom_style := . | resources.ExecuteAsTemplate . $page | minify | fingerprint -}}
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}" integrity="{{ $custom_style.Data.Integrity }}">
{{- end -}}
Comment on lines +48 to +54
Copy link
Member

@stefanv stefanv Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this indentation is because of the generated HTML—with this change, the generated file with have spaces before the <link> tags.
I'm OK with keeping it as-is, but my emacs also doesn't indent that way by default.
Perhaps you have settings I can adopt?

Copy link
Contributor Author

@alphapapa alphapapa Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I indented these lines manually for clarity in the source code (the {{- end -}} repeated 3 lines in a row, with different opening lines for each block, is hard to follow). But just let me know how you want this to be done.

{{- end -}}