Skip to content

Instantly share code, notes, and snippets.

@akoebbe
Last active October 12, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akoebbe/caad90606f633c24325c0ceeba304c75 to your computer and use it in GitHub Desktop.
Save akoebbe/caad90606f633c24325c0ceeba304c75 to your computer and use it in GitHub Desktop.
{% set payload = {frontmatter: page.header, content: page.content} %}
{{ payload|json_encode|raw }}
{% set items = {} %}
{% for child in page.collection() %}
{% set child_output %}
{% include 'default.json.twig' with {page: child} %}
{% endset %}
{% set items = items|merge({ (loop.index0): child_output}) %}
{% 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\":\"Team\"},\"content\":\"<p>Content<\\/p>\"} "
],
"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