feat: detect & link album mentions, not just artists (closes task/album-detection)
Source: task/album-detection (objective/linker-improvements) — project brief asks for artist OR album linking; MVP linked artists only.
- service/lib.js: pickAlbum (the exact-name gate, named for the album path) + linkResult now carries kind:"artist"|"album" (additive; defaults to artist so older clients keep working).
- service/resolver.js: one Spotify type=artist,album search per candidate, exact-match against either; returns {url,kind}; cache key includes the kind hint. resolveOne/resolveAll thread the LLM kind hint through.
- service/llm.js: parseClassification now returns Map(name -> "artist"|"album") so album-kind candidates route to the album path (.has() still works like the old Set).
- extension/extract.js: albumMatchesIn over two precise signals (quoted strings + album cue phrases "the album X", "X LP/EP"), folded into allMatchesIn.
- extension/content.js + styles.css: album links render italicised (.rsl-album) with an album tooltip; artist behavior unchanged.
- Tests: new pure-logic coverage in lib.test.js / llm.test.js / extract.test.cjs (album shaping, Map-kind routing, album candidate extraction). scripts/check.sh green.
- README.md + AGENTS.md: document album linking.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -48,19 +48,23 @@
|
||||
// ---- link building / rewriting --------------------------------------------
|
||||
// Per the user's "if on spotify, link that, else a Bandcamp Google-search fallback"
|
||||
// rule: one link to the primary platform, colour-coded so you can tell which at a glance.
|
||||
// `kind` ("artist" | "album", absent => "artist") adds an rsl-album class + an album word
|
||||
// in the tooltip so album links read as albums; the platform colour is unchanged.
|
||||
function makeLink(label, links) {
|
||||
const primary = links.primary || { platform: "spotify", url: links.spotify };
|
||||
const name = links.name || label;
|
||||
const platform = primary.platform;
|
||||
const kind = links.kind === "album" ? "album" : "artist";
|
||||
const noun = kind === "album" ? "album" : "artist";
|
||||
const a = document.createElement("a");
|
||||
a.className = `rsl-link rsl-${platform}`;
|
||||
a.className = `rsl-link rsl-${platform} rsl-${kind}`;
|
||||
a.textContent = label;
|
||||
a.href = primary.url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
a.title = platform === "spotify"
|
||||
? `Open ${name} on Spotify`
|
||||
: `Find ${name} on Bandcamp (Google search)`;
|
||||
? `Open ${name} (${noun}) on Spotify`
|
||||
: `Find ${name} (${noun}) on Bandcamp (Google search)`;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user