jswtch
1
Hello, I am building sites from data fetched from an API.
Is this article by Regis still the best way to do this?
Are there any upcoming changes to be aware of?
Can I fetch data to populate fields in the theme.toml
? Can I use the fetched data to set css variables (–my-var)?
Yes.
No.
I don’t know why you’d want to.
Yes.
jswtch
3
Great, thanks. How are you adding the data in CSS?
I am currently trying
{{ $string_test }}
<style>
:root {
--theme-color-test: {{$string_test}}
}
</style>
...
rest of template...
Where {{ $string_test }}
is something like hsla(247, 100%, 99%, 1)
from
{{ $data := getJSON $my_url }}
{{ $string_test := index $data.themeColors "my_color" }}
I am getting ZgotmplZ
.
How do I properly interpret these values as strings? Or is there a better way?
{{ $string_test := index $data.themeColors "my_color" | safeCSS }}
https://gohugo.io/functions/safecss/
system
Closed
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.