I’m quite new to using Kirby. I’m looking to use the JSON Content Representation in conjunction with my front-end Nuxt app. I’ve been following along with the docs here:
However, I’m unsure how to completely remove the need for the .php template files, leaving just the .json.php files to identify the data I want to retrieve from Kirby.
Is there a way to make the $data array in just one file, removing the need to have an empty template file alongside the JSON one?
If i hit localhost:3000/about.json I only get some of the data back:
{
title: "About us",
text: {
html: "<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p> <p>The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy.</p>"
}
}
I’m expecting all the data from the array in the above post to be returned…
But with a standard about.php template, your request should go to /about not /about.json. There shouldn’t be an about.json.php template anymore.
Content representations only make sense, if you also use the standard PHP template, that’s why they are called representations. And that’s why the standard template is required.
So you have to either add an empty standard template, and use the json variant for your JSON stuff. Or remove the JSON template, and use the standard template for your JSON.