site: hero auto-discovery, pick.json hero selection, amazonLink + shortlist fields
- src/lib/hero.ts: review heroes are now auto-discovered via import.meta.glob over reviews/*/hero.<ext>; only legacy non-hero-named assets remain as explicit overrides. New reviews need zero registration. - Pick of the day moves from a hardcoded HERO_SLUG in index.astro to src/data/pick.json (content edit, not code edit); dev set-pick API and the review-page button now write pick.json. Fallback: latest review. - Schemas: finds gain shortlist (bool) + amazonLink; reviews gain amazonLink. - Review + find pages render an 'Also on Amazon' affiliate link when amazonLink is set, with shared disclosure handling. - Both hero globs now include .avif (two June finds ship avif heroes).
This commit is contained in:
@@ -31,6 +31,9 @@ const linkLabel =
|
||||
item.data.linkText ?? new URL(item.data.link).hostname.replace(/^www\./, '');
|
||||
|
||||
const external = resolveExternalLink(item.data.link);
|
||||
const amazon = item.data.amazonLink
|
||||
? resolveExternalLink(item.data.amazonLink)
|
||||
: undefined;
|
||||
|
||||
const description =
|
||||
item.data.description ?? item.data.subtitle ?? `A find: ${item.data.name}.`;
|
||||
@@ -109,7 +112,20 @@ const breadcrumbs = buildBreadcrumbs([
|
||||
{external.isAffiliate && <span class="aff-badge">Affiliate</span>}
|
||||
</p>
|
||||
|
||||
{external.isAffiliate && (
|
||||
{amazon && (
|
||||
<p class="external">
|
||||
<a
|
||||
href={amazon.href}
|
||||
target="_blank"
|
||||
rel={amazon.isAffiliate ? AFFILIATE_REL : 'noopener noreferrer'}
|
||||
>
|
||||
Also on Amazon ↗
|
||||
</a>
|
||||
{amazon.isAffiliate && <span class="aff-badge">Affiliate</span>}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{(external.isAffiliate || amazon?.isAffiliate) && (
|
||||
<p class="aff-disclosure">{AFFILIATE_DISCLOSURE}</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ import { heroes } from '../lib/hero';
|
||||
import { bundleMosaic } from '../lib/bundle-mosaic';
|
||||
import { buildOgImage, buildItemList, WEBSITE, ORGANIZATION } from '../lib/seo';
|
||||
|
||||
const HERO_SLUG = 'continue-y-n-game';
|
||||
import pick from '../data/pick.json';
|
||||
|
||||
// Pick of the day. Set in src/data/pick.json; null falls back to the latest review.
|
||||
const HERO_SLUG: string | null = pick.hero;
|
||||
const INITIAL_GRID = 24;
|
||||
const BATCH_SIZE = 7;
|
||||
|
||||
@@ -69,7 +72,9 @@ const tiles: Tile[] = [...reviewTiles, ...bundleTiles].sort(
|
||||
const heroIndex = tiles.findIndex(
|
||||
(t) => t.kind === 'review' && t.href === `/reviews/${HERO_SLUG}/`
|
||||
);
|
||||
const hero = heroIndex >= 0 ? tiles[heroIndex] : reviewTiles[0];
|
||||
// Fall back to the newest review (tiles are sorted by date desc).
|
||||
const hero =
|
||||
heroIndex >= 0 ? tiles[heroIndex] : tiles.find((t) => t.kind === 'review');
|
||||
const rest = tiles.filter((t) => t !== hero);
|
||||
|
||||
const lastUpdated = tiles[0]?.date;
|
||||
|
||||
@@ -39,6 +39,9 @@ const linkLabel =
|
||||
(review.data.linkText ?? new URL(review.data.link).hostname.replace(/^www\./, ''));
|
||||
|
||||
const external = review.data.link ? resolveExternalLink(review.data.link) : undefined;
|
||||
const amazon = review.data.amazonLink
|
||||
? resolveExternalLink(review.data.amazonLink)
|
||||
: undefined;
|
||||
|
||||
const fromFindItem = review.data.fromFind
|
||||
? (await getCollection('find')).find((f) => f.id === review.data.fromFind)
|
||||
@@ -111,7 +114,20 @@ const categoryLabel =
|
||||
</p>
|
||||
)}
|
||||
|
||||
{external?.isAffiliate && (
|
||||
{amazon && (
|
||||
<p class="external">
|
||||
<a
|
||||
href={amazon.href}
|
||||
target="_blank"
|
||||
rel={amazon.isAffiliate ? AFFILIATE_REL : 'noopener noreferrer'}
|
||||
>
|
||||
Also on Amazon ↗
|
||||
</a>
|
||||
{amazon.isAffiliate && <span class="aff-badge">Affiliate</span>}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{(external?.isAffiliate || amazon?.isAffiliate) && (
|
||||
<p class="aff-disclosure">{AFFILIATE_DISCLOSURE}</p>
|
||||
)}
|
||||
|
||||
@@ -121,7 +137,7 @@ const categoryLabel =
|
||||
label="Make today's pick"
|
||||
action="set-pick"
|
||||
slug={review.id}
|
||||
confirm={`This will set ${review.data.name} as the homepage hero (rewrites HERO_SLUG in src/pages/index.astro).`}
|
||||
confirm={`This will set ${review.data.name} as the homepage hero (writes src/data/pick.json).`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user