I’m trying to replace some static values in content files with data from a curated JSON document, via shortcodes.
Data file: design-tokens/tokens.json
{
"COLOR_TEXT_LINK": "#098ae4",
"COLOR_TEXT_LINK_VISITED": "#098ae4",
"COLOR_TEXT_LINK_HOVER": "#004d81",
"COLOR_TEXT_LINK_ACTIVE": "#098ae4",
"COLOR_TEXT_LINK_DISABLED": "#333333"
}
Content file: buttons.md
{{% datapoint token="COLOR_TEXT_LINK" %}}
Shortcode file: datapoint.html
{{ $token := .Get "token" }}
{{ $data := getJSON "./design-tokens/tokens.json" }}
{{ range $data }}
{{ $token }}
{{ end }}
Produces this error:
Building sites … ERROR 2018/05/23 16:57:11 Cannot read json from resource ./design-tokens/tokens.json with error message unexpected end of JSON input
The idea here is that I’m maintaining my list of tokens in one file and they will always get replaced in the content with updated hex codes. The above may be overkill, or just incorrect syntax all around. After researching and trying many things, I’m resorting to asking here!