Closed ryami333 closed 4 years ago
Do you mean the recursive $site->index()
of all pages? This is currently not supported by the API and to be honest I don't think it will be added soon (few use-cases considering the low performance of such a lookup). However you have two options:
@lukasbestle already pointed out some good options.
Your own API route is very simple to create for this use-case:
// site/plugins/index-api/index.php
Kirby::plugin('ryami333/index-api', [
'api' => [
'routes' => [
[
'pattern' => 'pages',
'method' => 'GET',
'action' => function () {
return $this->site()->index();
}
]
]
]
]);
This will create a new /api/pages endpoint that will give you all pages at once.
Hi there, could we please have a new Rest API endpoint (GET "/pages") to list all pages?
My use-case is static-site-generation, where all data needs to be known ahead of time. For my use-case, I need a "parent lookup table", and I can't build that without being able to query all of the pages dynamically (ie. without knowing their specific slugs). Would also be necessary for generating sitemaps, building main-menus etc etc. Necessary for all the same reasons as the existence of the
$pages
variable in Kirby.