Allow hot-reload of config.json
This commit is contained in:
parent
31026a0d15
commit
9dfc790200
10 changed files with 90 additions and 51 deletions
17
src/utils/get-manga-title.ts
Normal file
17
src/utils/get-manga-title.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { languages, Manga } from '../types';
|
||||
|
||||
export const getMangaTitle = (manga: Manga) => {
|
||||
const languageToUse = languages.find((lang) => manga.attributes.title[lang]);
|
||||
|
||||
if (languageToUse) {
|
||||
return manga.attributes.title[languageToUse];
|
||||
}
|
||||
|
||||
// If no language is found, use the first one returned by the API
|
||||
const fallbackLanguage = Object.keys(manga.attributes.title)?.[0];
|
||||
if (fallbackLanguage) {
|
||||
return manga.attributes.title[fallbackLanguage] as string;
|
||||
}
|
||||
|
||||
return 'UNKNOWN TITLE';
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue