Skip to content

Instantly share code, notes, and snippets.

@w00fz
Forked from akoebbe/default.json.twig
Last active October 12, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w00fz/1b18d22dd77b28baa66ec835becb5ee5 to your computer and use it in GitHub Desktop.
Save w00fz/1b18d22dd77b28baa66ec835becb5ee5 to your computer and use it in GitHub Desktop.
{% set items = [] %}
{% for child in page.collection() %}
{% set items = items|merge([{ frontmatter: child.header, content: child.content} ]) %}
{% endfor %}
{% set payload = {
name: page.header.title,
route: page.route,
type: page.template,
items: items,
content: {
body: page.content
}
} %}
{{ payload|json_encode|raw }}
{
"name": "Home",
"route": "/",
"type": "home",
"items": [
{"frontmatter": {"title": "Foobar"}, "content": ""},
{"frontmatter": {"title": "Foobar"}, "content": ""},
{"frontmatter": {"title": "Title 1"}, "content": ""},
{"frontmatter": {"title": "Title 2"}, "content": ""}
],
"content": {
"body": "<p>Content stuff here</p>"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment