Is it possible to automatically generate json files containing all site configuration and page frontmatter metadata?
I tried a really simple version that only includes parameters using this template:
{
"SiteParams": {
{{- range $key, $val := .Site.Params }}
"{{ $key }}": "{{ $val }}"
{{- end }}
},
"PageParams": {
{{- range $key, $val := .Params }}
"{{ $key }}": "{{ $val }}"
{{- end }}
}
}
And using this as my site’s Params in config.yaml
:
params:
IndieWeb:
HeadRelAuthEndpoint: https://interpersonal.micahrl.com/indieauth/authorize/interpersonal-test
MicropubEndpoint: https://interpersonal.micahrl.com/micropub/interpersonal-test
TokenEndpoint: https://interpersonal.micahrl.com/indieauth/bearer/interpersonal-test
But when I add that as a custom output for my home page, it produces an output file like this:
{
"SiteParams": {
"indieweb": "map[headrelauthendpoint:https://interpersonal.micahrl.com/indieauth/authorize/interpersonal-test micropubendpoint:https://interpersonal.micahrl.com/micropub/interpersonal-test tokenendpoint:https://interpersonal.micahrl.com/indieauth/bearer/interpersonal-test]"
"mainSections": "[blog]"
"mainsections": "[blog]"
},
"PageParams": {
"draft": "false"
"iscjklanguage": "false"
"title": "Interpersonal test site"
}
}
Note that the dict in my config.yaml
turns into a string in the resulting json file. Is there a way to get it to become a dict in the json file too?
I could of course generate a json template that explicitly references all the values I want to use, but that’s more rigid. I’d also like to be able to include not just params, but all metadata in a page’s frontmatter and the site’s config.yaml.
The ultimately goal is to be able to fetch the JSON in the browser and use it on the client side. In this particular case, I want to use the IndieAuth and Micropub URLs in my site config in a Javascript Micropub client.
Thanks for any help.