Am I missing an obvious way to loop through data to create pages?
Context: I’m mostly familiar with how 11ty allows you to create files from data: Pagination — Eleventy and I’m looking for something similar with hyperctl
What I’ve tried (very hacky!!)
Working on reading and creating pages from data returned from a database (very simple CMS setup using pocketbase)
sample data:
{
"items": [
{
"collectionId": "pbc_38771238272",
"collectionName": "blog",
"content": "<h1>This is a test</h1>\r\n<p>Hello there!</p>",
"created": "2025-07-09 08:25:15.844Z",
"description": "Testing testing",
"draft": false,
"id": "test1",
"json": null,
"slug": "blog-test-1",
"title": "Test 1",
"updated": "2025-07-09 08:25:38.817Z"
}
],
"page": 1,
"perPage": 1000,
"totalItems": 1,
"totalPages": 1,
"namespace": "blog"
}
When it comes to creating content from this, I found a VERY hacky way…
- Set up a “Blog Post” content-type
- Writing the fetched JSON data to a file at
data/blog.json(usingcurlandjq) - Read the JSON with
jq, feeding ahyperctl new page --content-type "Blog Post"command tobashto write files tocontent/blog/**/index.md(see scary solution below, I haven’t even tested if this works with more than one object, probably needs to be reworked if I had set up more posts) - Now, the hyper
buildorservercommands will handle creating all the pages
Scary bash code:
Copy at your own risk …
bash <(jq -r '.items[] | "hyperctl new page --title \(.title|@sh) --content-type \"Blog Post\" -d \(.description|@sh) --content \(.content|@sh)"' ./data/blog.json)