Paginate all content in a site chronologically

Hi all, could anyone point me in the right direction here?

I’m looking to write a content representation for a quasi-single-page site where I fetch all content ordered chronologically regardless of the content’s parent page type.

What I’d like to do is send a query string to the content representation endpoint, e.g. /all.json?page=1 and get back the 50 most-recent content pieces sorted by date.

So from a content folder strutured like this: content/projects, content/journal, contend/shop items I could fetch a JSON response object which would look something like this:
{
project: { … },
journal: { … },
journal: { … },
shop item: { … },
project: { … },
}

One idea I’ve had is to do away with the notion of different ‘page’ types entirely and just keep everything under one page type, e.g. content/everything. I think this would allow me to leverage Kirby’s built-in pagination mechanisms, but it certainly makes adding fields conditionally a lot tricker.

Any ideas would be appreciated! :slightly_smiling_face:

You can fetch all content regardless of what page type it is as long as each page contains a date to sort by.

$site->index()

to the rescue (might be a performance problem on huge sites)

Thanks I didn’t know about this method!

Re: performance, I previously statically generated the site so response times weren’t an issue, but this time I’m looking to just server-side render so I figure requesting the data in paginated batches is the way to go.

Ths $site->index() method can retrieve all pages, also results can be searched and filtered.

$site->index() | Kirby CMS (getkirby.com)