Do pipelines work with resources for a local page?
I’ve got a simple site like the following:
- content/
- posts/
- foo/
- bar.md
- bar.scss
- layouts/
- _default/
- baseof.html
- assets/
- main.scss
The body of bar.md is like:
---
title: Foo Bar
resources:
- src: "**/*.scss"
styles:
- main
- ./bar
---
Hello Foo Bar
And in my _default/baseof.html file (in my layouts directory) I’ve got something like the following:
...
<head>
...
{{ range .Params.styles }}
{{ $resource := false }}
{{ if hasPrefix . "./" }}
{{ $resource = $.Resources.GetMatch (printf "%s.scss" .) }}
{{ else }}
{{ $resource = resources.Get (printf "%s.scss" .) }}
{{ end }}
{{ if $resource }}
<link rel="stylesheet"
href="{{- ($resource | resources.ExecuteAsTemplate (printf "styles/%s" .) $.Site | toCSS | postCSS (dict "config" "etc/postcss.config.js") | minify | resources.Fingerprint).Permalink -}}" />
{{ else }}
{{ warnf "failed to find resource: %s" . }}
{{ end }}
{{ end }}
...
</head>
...
NOTE: the ellipses represent filler information that isn’t really important.
What I was trying to implement was a smart style system, if the stylesheet you
want to include was prefixed with a ./ it was loaded from the local pages
resources, otherwise it was loaded from the global resources directory.
Only I’ve found that none of the pipeline steps work with bar.scss, they work
fine with main.scss.
bar.scss is placed into the output document as is, without
being converted to css, minified or fingerprinted.
I can only surmise none of the pipeline features of regular resources are working
with page resources, is this expected?
S.N.
I’m on Hugo Static Site Generator v0.68.3/extended linux/amd64 BuildDate: unknown.
.