What I am envisioning is allowing the user to set an accent color for each unique taxonomy, which would require a loop creating the CSS or SCSS.
{{- range $taxonomyname, $taxonomy := .Site.Taxonomies }}
{{- range $taxonomy }}
{{- if .Page.Params.backgroundColor }}
.card {
&[data-taxonomy="{{ print .Page.Section "-" .Page.Title | urlize }}"] {
background-color: {{ .Page.Params.backgroundColor | default "var(--color-primary)" }};
}
}
{{- end }}
{{- end }}
{{- end }}
Ideally, this logic would exist in assets/scss/component/card.scss with @use "card" inside of assets/scss/components/_index.scss and then @use "component" inside of assets/scss/main.scss.
My goal was that the styles can stay in the correct location to ensure they load in that priority.
I tried a couple variations of this, but it didn’t seem to work as I thought it would:
Is there a way to do this (either as I intent, or simplier)? Or would I just be better creating a hugo.scss that gets processed and tagged on the end (dealing with any style conflicts later)?
I think the crux of the issue is that the loop needs to occur inside of the SCSS file. This could be done outside of Hugo but would require the term and accent color to be passed through.
My understanding is that vars cannot be nested, so the following wouldn’t be valid:
The use case is that content/[taxonomy]/[term].toml allows you to define data for the term, including any potential styling to data the is associated with that term. Everything is edited in one location, rather than editing there and config.toml.