Show more alternate titles on anime detail pages
This commit is contained in:
parent
48e51c816f
commit
b806519b22
@ -45,7 +45,7 @@
|
|||||||
</aside>
|
</aside>
|
||||||
<article class="text">
|
<article class="text">
|
||||||
<h2 class="toph"><a rel="external" href="<?= $data['url'] ?>"><?= $data['title'] ?></a></h2>
|
<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>
|
<h3><?= $title ?></h3>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<br />
|
<br />
|
||||||
|
@ -195,6 +195,23 @@ final class Kitsu {
|
|||||||
return [];
|
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
|
* 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;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +252,8 @@ final class Model {
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'characters' => 'canonicalName,slug,image',
|
'characters' => 'canonicalName,slug,image',
|
||||||
'characterVoices' => 'mediaCharacter',
|
'characterVoices' => 'mediaCharacter',
|
||||||
'anime' => 'canonicalTitle,titles,slug,posterImage',
|
'anime' => 'canonicalTitle,abbreviatedTitles,titles,slug,posterImage',
|
||||||
'manga' => 'canonicalTitle,titles,slug,posterImage',
|
'manga' => 'canonicalTitle,abbreviatedTitles,titles,slug,posterImage',
|
||||||
'mediaCharacters' => 'role,media,character',
|
'mediaCharacters' => 'role,media,character',
|
||||||
'mediaStaff' => 'role,media,person',
|
'mediaStaff' => 'role,media,person',
|
||||||
],
|
],
|
||||||
|
@ -42,6 +42,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
|
|
||||||
$title = $item['canonicalTitle'];
|
$title = $item['canonicalTitle'];
|
||||||
$titles = Kitsu::filterTitles($item);
|
$titles = Kitsu::filterTitles($item);
|
||||||
|
$titles_more = Kitsu::getTitles($item);
|
||||||
|
|
||||||
$characters = [];
|
$characters = [];
|
||||||
$staff = [];
|
$staff = [];
|
||||||
@ -123,6 +124,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
'synopsis' => $item['synopsis'],
|
'synopsis' => $item['synopsis'],
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'titles' => $titles,
|
'titles' => $titles,
|
||||||
|
'titles_more' => $titles_more,
|
||||||
'trailer_id' => $item['youtubeVideoId'],
|
'trailer_id' => $item['youtubeVideoId'],
|
||||||
'url' => "https://kitsu.io/anime/{$item['slug']}",
|
'url' => "https://kitsu.io/anime/{$item['slug']}",
|
||||||
]);
|
]);
|
||||||
|
@ -97,6 +97,11 @@ class Anime extends AbstractType {
|
|||||||
*/
|
*/
|
||||||
public array $titles = [];
|
public array $titles = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $titles_more = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -23,10 +23,10 @@ final class AnimePage extends Anime {
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $characters;
|
public array $characters = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $staff;
|
public array $staff = [];
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user