Skip to content

Commit 32f8a86

Browse files
alphapapastefanv
andauthored
Allow sites to use local Sass files (#413)
* Change: Allow sites to use local Sass files This processes ".scss" files in the "assets/css" directory, allowing downstream sites to use Sass as well as plain CSS. * Also compile SCSS as templates * Be explicit about style sheet extensions * SCSS files are also templated * Fix small typo introduced in css layout * Fix rings.svg location --------- Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
1 parent 2f5c837 commit 32f8a86

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

assets/theme-css/fresh.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
position: absolute;
1212
left: 50%;
1313
top: 50%;
14-
background-image: url(../../images/loaders/rings.svg);
14+
background-image: url(../images/loaders/rings.svg);
1515
background-size: 80px 80px;
1616
background-repeat: no-repeat;
1717
background-position: 50%;

doc/content/getstarted.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ Example `config.yaml` files can be seen in [scientific-python.org](https://githu
7272

7373
### CSS
7474

75-
To customize styles, add CSS files to the `./assets/css/` directory.
76-
It's recommended to put your customizations in a file named `custom.css`, but other `css` files added there will also be loaded.
75+
To customize styles, add CSS (`.css`) and Sass (`.scss`) files to the `./assets/css/` directory.
76+
It's recommended to put your customizations in a file named `custom.css`, but other `.css` and `.scss` files added there will also be loaded.
7777

78-
CSS files are compiled as Hugo templates, i.e. configuration variables from the `config.yaml` file can be accessed as `{{ .Site.Params.VARIABLE }}`.
78+
CSS and SCSS files are compiled as Hugo templates, i.e. configuration variables from the `config.yaml` file can be accessed as `{{ .Site.Params.VARIABLE }}`.
7979

8080
### JavaScript
8181

layouts/partials/css.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{{- $serverOpts := cond ($inServerMode) (dict "enableSourceMap" true) (dict "outputStyle" "compressed") -}}
66
{{- $sassCompiler := dict "transpiler" "dartsass" -}}
77
{{- $cssOpts := collections.Merge $sassCompiler $serverOpts -}}
8-
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss") -}}
98

109
<!-- Fonts -->
1110
{{- $fontName := .Site.Params.font.name | default "Open Sans" -}}
@@ -23,13 +22,16 @@
2322
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+Symbols+2">
2423
2524
<!-- SASS -->
25+
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss") | append (resources.Match "css/*.scss") -}}
2626
{{- range $sass -}}
2727

28+
{{- $targetFile := printf "%s.scss" . -}}
29+
2830
{{- if $inServerMode -}}
29-
{{ $css := resources.Get . | toCSS $cssOpts -}}
31+
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts -}}
3032
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}">
3133
{{ else }}
32-
{{ $css := resources.Get . | toCSS $cssOpts | minify | fingerprint -}}
34+
{{ $css := resources.Get . | resources.ExecuteAsTemplate $targetFile $page | toCSS $cssOpts | minify | fingerprint -}}
3335
<link rel="stylesheet" type="text/css" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}">
3436
{{- end -}}
3537

@@ -41,13 +43,11 @@
4143

4244
{{- range $cssFiles -}}
4345

44-
{{- $targetFile := printf "css/%s" . -}}
45-
4646
{{ if $inServerMode -}}
47-
{{ $custom_style := . | resources.ExecuteAsTemplate $targetFile $page -}}
47+
{{ $custom_style := . | resources.ExecuteAsTemplate . $page -}}
4848
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}">
4949
{{ else }}
50-
{{ $custom_style := . | resources.ExecuteAsTemplate $targetFile $page | minify | fingerprint -}}
50+
{{ $custom_style := . | resources.ExecuteAsTemplate . $page | minify | fingerprint -}}
5151
<link rel="stylesheet" href="{{ $custom_style.RelPermalink }}" integrity="{{ $custom_style.Data.Integrity }}">
5252
{{- end -}}
5353

0 commit comments

Comments
 (0)