Function to reading JSON, TOML, YAML data from page resources and site data.
Become a backer or sponsor to support our work.
The function accepts key
and page
parameters.
1{{ with partial "base/functions/data" (dict "key" "foobar" "page" .) }}
2 {{/* ... */}}
3{{ end }}
Please note that the page
variable should be .Page
in shortcodes.
key
Name | Context | Type | Required | Default | Since | Example |
---|---|---|---|---|---|---|
key | - | string | ✓ | - | - | - |
The name of data file without extension, dot (.
) represents the path separator.
page
Name | Context | Type | Required | Default | Since | Example |
---|---|---|---|---|---|---|
page | - | Page | ✓ | - | - | - |
The current page variable.
Let’s take content/example/index.md
page as an example, assume the key
is foo.bar
.
Path |
---|
/content/example/foo/bar.toml |
/content/example/foo/bar.yaml |
/content/example/foo/bar.yml |
/content/example/foo/bar.json |
/data/foo/bar.toml |
/data/foo/bar.yaml |
/data/foo/bar.yml |
/data/foo/bar.json |