Building Pages from an API

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)?



I don’t know why you’d want to.


Great, thanks. How are you adding the data in CSS?

I am currently trying

{{ $string_test }}

  :root {
    --theme-color-test: {{$string_test}}
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 }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.