diff --git a/src/components/ProductHome.astro b/src/components/ProductHome.astro index 42419b0..0c65069 100644 --- a/src/components/ProductHome.astro +++ b/src/components/ProductHome.astro @@ -9,6 +9,12 @@ // Styles use Starlight's tokens only, so the block takes each site's palette. import { PRODUCTS, STARTS } from '../data/products.mjs'; +// A mention of another Intentius project is a link. +const PROJECT = /\b(behold|chant|choudoufu|plunge|plywood|terragucci)\b/; +const PROJECTS = new Set(['behold', 'chant', 'choudoufu', 'plunge', 'plywood', 'terragucci']); +const linked = (text: string, self: string) => text.split(PROJECT).map((part) => + PROJECTS.has(part) && part !== self ? { name: part, href: `https://intentius.io/${part}/` } : part); + interface Props { id: string; version?: string; @@ -23,7 +29,7 @@ const starts = Object.entries(product.starts).map(([key, href]) => { return { key, label: STARTS[key], href }; }); -const lines = product.first.cmd.map((line) => { +const lines = (product.first?.cmd ?? []).map((line) => { if (!line.includes('{version}')) return line; if (!version) throw new Error(`ProductHome: ${id} has {version} in its first command, so the site must pass version`); return line.replaceAll('{version}', version); @@ -35,10 +41,10 @@ const hid = `ph-${product.id}`;

{product.name}

{product.oneLiner}

-
-

{product.changes}

-

{product.fits}

-
+ {(product.changes || product.fits) &&
+ {product.changes &&

{linked(product.changes, id).map((b) => typeof b === 'string' ? b : {b.name})}

} + {product.fits &&

{linked(product.fits, id).map((b) => typeof b === 'string' ? b : {b.name})}

} +
} {starts.length > 0 && ( )} + {product.first && (

First command

Needs: {product.first.needs}.

{lines.join('\n')}

The full steps

+ )}