mirror of
https://github.com/starshardstudio/peafowl.git
synced 2024-11-27 15:34:18 +00:00
Add anime identifiers
This commit is contained in:
parent
21ff234466
commit
f5dc4778f9
6 changed files with 212 additions and 27 deletions
105
_cms.ts
105
_cms.ts
|
@ -181,7 +181,7 @@ cms.collection(
|
|||
name: "identifiers",
|
||||
type: "choose-list",
|
||||
label: "Identifiers",
|
||||
description: "Details that unequivocabily and globally identify the game. Shouldn't be edited manually.",
|
||||
description: "Details that unequivocabily and globally identify the game. Edit manually at your own risk.",
|
||||
fields: [
|
||||
{
|
||||
name: "steam",
|
||||
|
@ -193,22 +193,30 @@ cms.collection(
|
|||
name: "appid",
|
||||
type: "text",
|
||||
label: "AppID",
|
||||
description: "The AppID that the game has on Steam. Usually ends with a 0. Can be obtained from the store page link, after the /app/ segment.",
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
type: "text",
|
||||
label: "Name",
|
||||
description: "The title of the game, as it appears on Steam."
|
||||
description: "The AppID that the game has on Steam. Usually ends with a 0. Can be obtained from the store page link after the /app/ segment.",
|
||||
},
|
||||
{
|
||||
name: "synced_on",
|
||||
type: "date",
|
||||
label: "Last sync",
|
||||
description: "The date of the last sync."
|
||||
description: "The date of the last sync via `deno task import-steam`."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "wikidata",
|
||||
type: "object",
|
||||
label: "Wikidata",
|
||||
description: "The game, stored as a Wikidata item.",
|
||||
fields: [
|
||||
{
|
||||
name: "q",
|
||||
type: "number",
|
||||
label: "Wikidata identifier",
|
||||
description: "The ID that the item has on Wikidata. The number following the `Q`.",
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -316,15 +324,84 @@ cms.collection(
|
|||
label: "Mastered on",
|
||||
description: "The date on which you've achieved mastery of the anime.",
|
||||
},
|
||||
/*
|
||||
{
|
||||
name: "identifiers",
|
||||
type: "choose-list",
|
||||
label: "Identifiers",
|
||||
description: "Details that unequivocabily and globally identify the anime. Shouldn't be edited manually.",
|
||||
fields: []
|
||||
description: "Details that unequivocabily and globally identify the anime. Edit manually at your own risk.",
|
||||
fields: [
|
||||
{
|
||||
name: "mal",
|
||||
type: "object",
|
||||
label: "MyAnimeList",
|
||||
description: "The anime, as it is stored on MyAnimeList.",
|
||||
fields: [
|
||||
{
|
||||
name: "id",
|
||||
type: "text",
|
||||
label: "MAL ID",
|
||||
description: "The anime ID that the anime has on MyAnimeList. Can be obtained from the anime page link after the `/anime/` segment.",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "anidb",
|
||||
type: "object",
|
||||
label: "AniDB",
|
||||
description: "The anime, as it is stored on AniDB.",
|
||||
fields: [
|
||||
{
|
||||
name: "aid",
|
||||
type: "text",
|
||||
label: "AID",
|
||||
description: "The anime ID that the anime has on AniDB. Can be obtained from the anime page link, after the `/anime/` segment, or from the `aid` query parameter.",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "annid",
|
||||
type: "object",
|
||||
label: "Anime News Network",
|
||||
description: "The anime, as it is stored on Anime News Network.",
|
||||
fields: [
|
||||
{
|
||||
name: "id",
|
||||
type: "text",
|
||||
label: "ANN ID",
|
||||
description: "The anime ID that the anime has on AniDB. Can be obtained from the anime page link from the `id` query parameter.",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "anilist",
|
||||
type: "object",
|
||||
label: "Anilist",
|
||||
description: "The anime, as it is stored on Anilist.",
|
||||
fields: [
|
||||
{
|
||||
name: "id",
|
||||
type: "text",
|
||||
label: "Anilist ID",
|
||||
description: "The anime ID that the anime has on Anilist. Can be obtained from the anime page link after the `/anime/` segment.",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "wikidata",
|
||||
type: "object",
|
||||
label: "Wikidata",
|
||||
description: "The anime, stored as a Wikidata item.",
|
||||
fields: [
|
||||
{
|
||||
name: "q",
|
||||
type: "text",
|
||||
label: "Wikidata identifier",
|
||||
description: "The ID that the item has on Wikidata. The number following the `Q`.",
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
*/
|
||||
{
|
||||
name: "content",
|
||||
type: "markdown",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {formatDateIso} from "../_utils/date.ts"
|
||||
import {AnimeData, AnimeProgress, animeProgressToClassName, animeProgressToIconDef, animeProgressToTitle} from "../_utils/anime.ts"
|
||||
import {AnimeData, AnimeIdentifier, AnimeProgress, animeProgressToClassName, animeProgressToIconDef, animeProgressToTitle} from "../_utils/anime.ts"
|
||||
import {ReviewInfo} from "../_components/ReviewInfo.tsx"
|
||||
|
||||
|
||||
|
@ -102,6 +102,73 @@ export default function(data: AnimeData, helpers: Lume.Helpers) {
|
|||
</ReviewInfo.MetadataRow>
|
||||
) : null
|
||||
|
||||
const milestonesSeparator = ((data.identifiers?.length ?? 0) > 0) ? <hr/> : null
|
||||
|
||||
const identifiersRows = data.identifiers?.map((identifier: AnimeIdentifier, index: number) => {
|
||||
switch(identifier.type) {
|
||||
case "wikidata":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`review-identifier-wikidata`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-barcode`}/> Wikidata</span>}
|
||||
>
|
||||
<a href={`https://www.wikidata.org/wiki/Q${identifier.q}`}>
|
||||
Q{identifier.q}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
case "anidb":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`anime-identifier-anidb`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-database`}/> AniDB</span>}
|
||||
>
|
||||
<a href={`https://anidb.net/anime/${identifier.aid}`}>
|
||||
{identifier.aid}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
case "mal":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`anime-identifier-mal`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-list-check`}/> MyAnimeList</span>}
|
||||
>
|
||||
<a href={`https://myanimelist.net/anime/${identifier.id}`}>
|
||||
{identifier.id}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
case "ann":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`anime-identifier-ann`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-circles-overlap`}/> Anime News Network</span>}
|
||||
>
|
||||
<a href={`https://www.animenewsnetwork.com/encyclopedia/anime.php?id=${identifier.id}`}>
|
||||
{identifier.id}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
case "anilist":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`anime-identifier-anilist`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-circles-overlap`}/> Anilist</span>}
|
||||
>
|
||||
<a href={`https://anilist.co/anime/${identifier.id}/`}>
|
||||
{identifier.id}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<main id={"anime-main"}>
|
||||
<ReviewInfo
|
||||
|
@ -118,6 +185,8 @@ export default function(data: AnimeData, helpers: Lume.Helpers) {
|
|||
{startedOnRow}
|
||||
{completedOnRow}
|
||||
{masteredOnRow}
|
||||
{milestonesSeparator}
|
||||
{identifiersRows}
|
||||
</>}
|
||||
>
|
||||
{data.children}
|
||||
|
|
|
@ -119,6 +119,18 @@ export default function(data: GameData, helpers: Lume.Helpers) {
|
|||
|
||||
const identifiersRows = data.identifiers?.map((identifier: GameIdentifier, index: number) => {
|
||||
switch(identifier.type) {
|
||||
case "wikidata":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
key={index}
|
||||
className={`review-identifier-wikidata`}
|
||||
label={<span><i className={`fa-sharp fa-regular fa-barcode`}/> Wikidata</span>}
|
||||
>
|
||||
<a href={`https://www.wikidata.org/wiki/Q${identifier.q}`}>
|
||||
Q{identifier.q}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
case "steam":
|
||||
return (
|
||||
<ReviewInfo.MetadataRow
|
||||
|
@ -127,7 +139,7 @@ export default function(data: GameData, helpers: Lume.Helpers) {
|
|||
label={<span><i className={`fa-brands fa-steam`}/> Steam</span>}
|
||||
>
|
||||
<a href={`https://store.steampowered.com/app/${identifier.appid}/`}>
|
||||
{identifier.name ?? identifier.appid}
|
||||
{identifier.appid}
|
||||
</a>
|
||||
</ReviewInfo.MetadataRow>
|
||||
)
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
import { ReviewData } from "./review.ts";
|
||||
import { ReviewData, ReviewIdentifier, ReviewWikidataIdentifier } from "./review.ts";
|
||||
|
||||
export interface AnimeAnidbIdentifier extends ReviewIdentifier {
|
||||
type: "anidb";
|
||||
aid: string;
|
||||
}
|
||||
|
||||
export interface AnimeMalIdentifier extends ReviewIdentifier {
|
||||
type: "mal";
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface AnimeAnnIdentifier extends ReviewIdentifier {
|
||||
type: "ann";
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface AnimeAnilistIdentifier extends ReviewIdentifier {
|
||||
type: "anilist";
|
||||
id: string;
|
||||
}
|
||||
|
||||
export type AnimeIdentifier = ReviewWikidataIdentifier | AnimeAnidbIdentifier | AnimeMalIdentifier | AnimeAnnIdentifier | AnimeAnilistIdentifier;
|
||||
|
||||
export interface AnimeData extends ReviewData {
|
||||
name_original: string;
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
import { ReviewData } from "./review.ts";
|
||||
import { ReviewData, ReviewIdentifier, ReviewWikidataIdentifier } from "./review.ts";
|
||||
|
||||
export interface GameBaseIdentifier {
|
||||
type: string;
|
||||
export interface GameSteamIdentifier extends ReviewIdentifier {
|
||||
type: "steam";
|
||||
appid: string;
|
||||
synced_on?: string;
|
||||
}
|
||||
|
||||
export interface GameSteamIdentifier extends GameBaseIdentifier {
|
||||
type: "steam";
|
||||
appid: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export type GameIdentifier = GameSteamIdentifier;
|
||||
export type GameIdentifier = ReviewWikidataIdentifier | GameSteamIdentifier;
|
||||
|
||||
export interface GameData extends ReviewData {
|
||||
active?: boolean;
|
||||
|
|
|
@ -2,6 +2,16 @@ import {Rating} from "./rating.ts"
|
|||
import {GlobalData} from "./site.ts"
|
||||
|
||||
|
||||
export interface ReviewIdentifier {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface ReviewWikidataIdentifier extends ReviewIdentifier {
|
||||
type: "wikidata",
|
||||
q: string,
|
||||
}
|
||||
|
||||
|
||||
export interface ReviewData extends GlobalData {
|
||||
name?: string,
|
||||
name_sort?: string,
|
||||
|
|
Loading…
Reference in a new issue