Re-add characters to anime details page, see #27

This commit is contained in:
Timothy Warren 2020-07-29 11:00:54 -04:00
parent dbfdd1c239
commit 7275d81468
3 changed files with 23 additions and 21 deletions

View File

@ -11,10 +11,10 @@
<td class="align-right">Airing Status</td>
<td><?= $data['status'] ?></td>
</tr>
<tr>
<?php /* <tr>
<td>Show Type</td>
<td><?= $data['show_type'] ?></td>
</tr>
</tr> */ ?>
<tr>
<td>Episode Count</td>
<td><?= $data['episode_count'] ?? '-' ?></td>
@ -130,7 +130,7 @@
<article class="<?= $role === 'supporting' ? 'small-' : '' ?>character">
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
<div class="name">
<?= $helper->a($link, $char['name']); ?>
<?= $helper->a($link, $char['name']) ?>
</div>
<a href="<?= $link ?>">
<?= $helper->picture("images/characters/{$id}.webp") ?>

View File

@ -41,24 +41,6 @@ query ($slug: String!) {
slug
}
role
voices {
nodes {
id
licensor {
id
name
}
locale
person {
id
names {
alternatives
canonical
localized
}
}
}
}
}
pageInfo {
endCursor

View File

@ -46,6 +46,26 @@ final class AnimeTransformer extends AbstractTransformer {
$title = $base['titles']['canonical'];
$titles = Kitsu::filterLocalizedTitles($base['titles']);
if (count($base['characters']['nodes']) > 0)
{
$characters['main'] = [];
$characters['supporting'] = [];
foreach ($base['characters']['nodes'] as $rawCharacter)
{
$type = $rawCharacter['role'] === 'MAIN' ? 'main' : 'supporting';
$details = $rawCharacter['character'];
$characters[$type][$details['id']] = [
'image' => $details['image'],
'name' => $details['names']['canonical'],
'slug' => $details['slug'],
];
}
uasort($characters['main'], fn($a, $b) => $a['name'] <=> $b['name']);
uasort($characters['supporting'], fn($a, $b) => $a['name'] <=> $b['name']);
}
$data = [
'age_rating' => $base['ageRating'],
'age_rating_guide' => $base['ageRatingGuide'],