Show more alternate titles on anime detail pages
Some checks failed
timw4mail/HummingBirdAnimeClient/pipeline/head There was a failure building this commit
Some checks failed
timw4mail/HummingBirdAnimeClient/pipeline/head There was a failure building this commit
This commit is contained in:
parent
48e51c816f
commit
b806519b22
@ -45,7 +45,7 @@
|
||||
</aside>
|
||||
<article class="text">
|
||||
<h2 class="toph"><a rel="external" href="<?= $data['url'] ?>"><?= $data['title'] ?></a></h2>
|
||||
<?php foreach ($data['titles'] as $title): ?>
|
||||
<?php foreach ($data['titles_more'] as $title): ?>
|
||||
<h3><?= $title ?></h3>
|
||||
<?php endforeach ?>
|
||||
<br />
|
||||
|
@ -195,6 +195,23 @@ final class Kitsu {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of titles
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public static function getTitles(array $data): array
|
||||
{
|
||||
$raw = array_unique([
|
||||
$data['canonicalTitle'],
|
||||
...array_values($data['titles']),
|
||||
...array_values($data['abbreviatedTitles']),
|
||||
]);
|
||||
|
||||
return array_diff($raw,[$data['canonicalTitle']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out duplicate and very similar names from
|
||||
*
|
||||
@ -217,6 +234,17 @@ final class Kitsu {
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('abbreviatedTitles', $data))
|
||||
{
|
||||
foreach ($data['abbreviatedTitles'] as $alternateTitle)
|
||||
{
|
||||
if (self::titleIsUnique($alternateTitle, $valid))
|
||||
{
|
||||
$valid[] = $alternateTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
|
@ -252,8 +252,8 @@ final class Model {
|
||||
'fields' => [
|
||||
'characters' => 'canonicalName,slug,image',
|
||||
'characterVoices' => 'mediaCharacter',
|
||||
'anime' => 'canonicalTitle,titles,slug,posterImage',
|
||||
'manga' => 'canonicalTitle,titles,slug,posterImage',
|
||||
'anime' => 'canonicalTitle,abbreviatedTitles,titles,slug,posterImage',
|
||||
'manga' => 'canonicalTitle,abbreviatedTitles,titles,slug,posterImage',
|
||||
'mediaCharacters' => 'role,media,character',
|
||||
'mediaStaff' => 'role,media,person',
|
||||
],
|
||||
|
@ -42,6 +42,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
||||
|
||||
$title = $item['canonicalTitle'];
|
||||
$titles = Kitsu::filterTitles($item);
|
||||
$titles_more = Kitsu::getTitles($item);
|
||||
|
||||
$characters = [];
|
||||
$staff = [];
|
||||
@ -123,6 +124,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
||||
'synopsis' => $item['synopsis'],
|
||||
'title' => $title,
|
||||
'titles' => $titles,
|
||||
'titles_more' => $titles_more,
|
||||
'trailer_id' => $item['youtubeVideoId'],
|
||||
'url' => "https://kitsu.io/anime/{$item['slug']}",
|
||||
]);
|
||||
|
@ -97,6 +97,11 @@ class Anime extends AbstractType {
|
||||
*/
|
||||
public array $titles = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $titles_more = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -23,10 +23,10 @@ final class AnimePage extends Anime {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $characters;
|
||||
public array $characters = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $staff;
|
||||
public array $staff = [];
|
||||
}
|
Loading…
Reference in New Issue
Block a user