On This Page
Pages Data
To get started with, let's review the kind of content you can get as data.
Schema
Each page will return data in the following schema:
- id - a unique kebabe-case transformation of the filename
- title (customizable) - inferred title based on the filename
- label (customizable) - inferred from the title if not configured
- route - the filename converted into a path as per file based routing
- data (customizable) - any custom frontmatter keys you've defined for your page
So for a page at src/pages/blog/first-post.md, this is the data you would get back:
---
author: Project Evergreen
published: 2024-01-01
---
# First Post
This is my first post.
{
"id": "blog-first-post",
"title": "First Post",
"label": "First Post",
"route": "/blog/first-post/",
"data": {
"author": "Project Evergreen",
"published": "2024-01-01"
}
}
Table of Contents
Additionally for markdown pages, you can add a frontmatter property called tocHeading
that will read all the HTML heading tags that match that number, and provide that as a subset of the data object. This is most useful for generating the table of contents for a page.
Taking our previous example, if we were to configure this for <h2>
tags:
---
author: Project Evergreen
published: 2024-01-01
tocHeading: 2
---
# First Post
This is my first post.
## Overview
Lorum Ipsum
## First Point
Something something...
We would get this additional content as data out:
{
"id": "blog-first-post",
"title": "First Post",
"label": "First Post",
"route": "/blog/first-post/",
"data": {
"author": "Project Evergreen",
"published": "2024-01-01",
"tocHeading": 2,
"tableOfContents": [
{
"content": "Overview",
"slug": "overview"
},
{
"content": "First Point",
"slug": "first-point"
}
]
}
}
External Content
Using our Source plugin, just as you can get your content as data out of Greenwood, so can you provide your own sources of content (as data) to Greenwood. This is great for pulling content from a headless CMS, database, or anything else you can imagine!