I think I figured it out…
I can now just place all blog items under the main blog page and create one big collection. And still use the nested structure.
This is what I did. I will do some additional testing. And the plugin needs some configurability. I will submit a repo and will eventually submit it to the plugin library once its stable enough.
Created a plugin that rewrites the default route:
public function onPagesInitialized(Event $event)
{
$pages = $event['pages'];
$collection = $pages->all(); // todo: get from plugin settings
$items = $collection->ofType('item');
foreach ($items as $item) {
$header = $item->header();
$date = isset($header->date) ? date('Y-m-d', strtotime($header->date)) : date('Y-m-d');
$date = substr(preg_replace('/-/', '/', $date), 0, 10);
$route = '/'.$date.'/'.$item->slug();
$header->routes['default'] = $route;
$item->route($route);
}
And additionally create an alias in site.yaml
:
routes:
'/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.*)': /blog/$1