Breaking content directory down by year/month to improve performance

 'action'  => function ( $year, $month, $all ) {
    if ( $page = page($year . '/' . $month . '/' . $all) ) {
       return $page->render( [], 'application/json' );
    }
  }

Note that you needuse a second route that works the other way round and finds the page in the folders.