I rather thought as the about page to have the users as children, not the books, so:
class AboutPage extends Page {
public function children() {
$users = $this->kirby()->users();//->filterBy('role','editor');
$pages = [];
foreach ($users as $user) {
$pages[] = [
'slug' => Str::slug($user->name()),
'num' => 0,
'template' => 'team-member',
'model' => 'team-member',
'content' => [
'title' => $user->name(),
// author fields as required
]
];
}
return Pages::factory($pages, $this);
}
Then in the model for these children, the Teammember model, return the books for each author.
<?php
class TeammemberPage extends Page {
public function children() {
return page('books')->children()->listed()->filter(function($child) {
return $child->author()->yaml()[0] == $this->email();
});
}
}