mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 10:08:40 +01:00
fix(v2): link IGDB provider to game page by slug
The IGDB provider link built a text-search URL from the numeric ID, which returns no results. Point it at the canonical /games/<slug> page when the slug is present, falling back to the ID search otherwise. The URL builder now receives the DetailedRom so it can reach fields beyond the provider ID. Generated-By: PostHog Code Task-Id: 6843b623-ed80-454f-8373-8192f3c629b4
This commit is contained in:
@@ -133,7 +133,7 @@ const dataProviders = computed(() =>
|
||||
PROVIDERS.map((p) => {
|
||||
const id = providerId(props.rom, p);
|
||||
if (id === null) return null;
|
||||
return { name: p.name, href: p.url ? p.url(id) : null };
|
||||
return { name: p.name, href: p.url ? p.url(id, props.rom) : null };
|
||||
}).filter((e): e is { name: string; href: string | null } => e !== null),
|
||||
);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const entries = computed<Entry[]>(() => {
|
||||
accent: p.color,
|
||||
logo: p.logo,
|
||||
id,
|
||||
href: id !== null && p.url ? p.url(id) : null,
|
||||
href: id !== null && p.url ? p.url(id, props.rom) : null,
|
||||
};
|
||||
});
|
||||
// Linked first; the cards know how to dim themselves when unlinked.
|
||||
|
||||
@@ -13,8 +13,10 @@ export type Provider = {
|
||||
color: string;
|
||||
/** Optional favicon for the provider's identity. */
|
||||
logo: string | null;
|
||||
/** Optional URL builder; when null the card renders unlinked. */
|
||||
url: ((id: string | number) => string) | null;
|
||||
/** Optional URL builder; when null the card renders unlinked. The ROM is
|
||||
* passed so builders can reach fields beyond the provider ID (e.g. IGDB
|
||||
* links by slug, not by numeric ID). */
|
||||
url: ((id: string | number, rom: DetailedRom) => string) | null;
|
||||
};
|
||||
|
||||
export const PROVIDERS: Provider[] = [
|
||||
@@ -23,7 +25,13 @@ export const PROVIDERS: Provider[] = [
|
||||
name: "IGDB",
|
||||
color: "var(--r-color-provider-igdb)",
|
||||
logo: "/assets/scrappers/igdb.png",
|
||||
url: (id) => `https://www.igdb.com/search?type=1&q=${id}`,
|
||||
// IGDB game pages live at /games/<slug>; the numeric ID only feeds a text
|
||||
// search that returns nothing. Fall back to the ID search when the slug
|
||||
// (populated from the IGDB match) is missing.
|
||||
url: (id, rom) =>
|
||||
rom.slug
|
||||
? `https://www.igdb.com/games/${rom.slug}`
|
||||
: `https://www.igdb.com/search?type=1&q=${id}`,
|
||||
},
|
||||
{
|
||||
key: "moby_id",
|
||||
|
||||
Reference in New Issue
Block a user