Skip to content

Commit 24b1a25

Browse files
TMHSDigitalclaude
andcommitted
Add "free alternatives to ..." pages with recorded licences (#189)
Developers search for free alternatives to well-known paid products, and the results are listicles with no licence detail. Six generated pages answer those searches from the catalog instead: - site/alternatives.json defines each page: a title, one human-written context sentence that says what the paid product is (no claims about it), and the match: ids, or categories with tags or subcategories, less an exclude list. Pages: Synty low-poly packs, Mixamo, Quixel Megascans, Aseprite, Substance Painter, stock music subscriptions. - site/lib/alternatives-page.mjs lists only active entries, with the same cards (licence, commercial verdict, verified date), head and CollectionPage structured data as category pages. - The build writes dist/alternatives/<slug>/, adds them to the sitemap, and links each from the category pages it lists entries in. It fails on an unknown id or category, a bad or duplicate slug, or a page with fewer than three matches. - Tests cover matching, the checks, category links and the sitemap. Fixes #189 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 81e93c4 commit 24b1a25

6 files changed

Lines changed: 227 additions & 8 deletions

File tree

‎site/alternatives.json‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"_comment": "\"Free alternatives to ...\" pages (#189), one per common search, written to dist/alternatives/<slug>/. Each lists the active entries that match: any id in `ids`, or an entry in one of `categories` that carries one of `tags` or `subcategories`, less any id in `exclude`. Name the paid product only to describe the search; `context` says what it is and what to look for here, with no claims about it. The build fails when a page matches fewer than three active entries.",
3+
"pages": [
4+
{
5+
"slug": "synty-low-poly-packs",
6+
"title": "Free alternatives to Synty low-poly packs",
7+
"context": "Synty sells themed low-poly 3D packs (towns, dungeons, sci-fi) for game engines. These catalog sources offer free low-poly 3D kits and characters in a similar flat, stylised look; each card shows the licence as read at the source.",
8+
"categories": ["3d", "characters"],
9+
"tags": ["low-poly", "modular"],
10+
"subcategories": ["modular"]
11+
},
12+
{
13+
"slug": "mixamo",
14+
"title": "Free alternatives to Mixamo",
15+
"context": "Mixamo is Adobe's online service for rigging characters and applying motion-capture animations. These catalog sources are free animation libraries, motion capture and rigging tools you can download and use directly.",
16+
"categories": ["animation", "tools"],
17+
"tags": ["mocap", "retarget", "auto-rig", "locomotion"],
18+
"subcategories": ["mocap", "retarget", "rigs"],
19+
"exclude": ["mixamo"]
20+
},
21+
{
22+
"slug": "quixel-megascans",
23+
"title": "Free alternatives to Quixel Megascans",
24+
"context": "Megascans is a library of scanned 3D assets and surfaces, now sold through Fab. These catalog sources offer free PBR textures, scanned models and HDRI skies.",
25+
"categories": ["3d", "environment"],
26+
"tags": ["pbr", "photogrammetry", "seamless"],
27+
"subcategories": ["textures", "materials", "photogrammetry", "hdri"]
28+
},
29+
{
30+
"slug": "aseprite",
31+
"title": "Free alternatives to Aseprite",
32+
"context": "Aseprite is a paid pixel-art and sprite animation editor. These catalog sources are free pixel-art editors and sprite tools; each tool's own licence is separate from the art you make with it.",
33+
"categories": ["tools"],
34+
"tags": ["sprite-editor"],
35+
"subcategories": ["pixel"]
36+
},
37+
{
38+
"slug": "substance-painter",
39+
"title": "Free alternatives to Substance Painter",
40+
"context": "Substance 3D Painter is Adobe's paid tool for painting textures onto 3D models. These catalog sources are free texturing, material and painting tools.",
41+
"ids": ["material-maker", "materialize", "normalpainter", "xnormal", "krita", "blender"]
42+
},
43+
{
44+
"slug": "stock-music-subscriptions",
45+
"title": "Free alternatives to stock music subscriptions",
46+
"context": "Subscription libraries license music for videos and games for a monthly fee. These catalog sources offer free music for games; several ask for credit, and each card shows what the licence asks.",
47+
"categories": ["audio"],
48+
"tags": ["chiptune", "loops"],
49+
"subcategories": ["music", "loops", "jingles"]
50+
}
51+
]
52+
}

‎site/build.mjs‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { filmstripHtml, groupedEntriesHtml } from "./lib/cards.mjs";
2121
import { guidePageHtml } from "./lib/guide-page.mjs";
2222
import { renderGuide } from "./lib/guide-render.mjs";
2323
import { categoryPageHtml } from "./lib/category-page.mjs";
24+
import { alternativesFor, alternativesForCategory, alternativesPageHtml, checkAlternatives } from "./lib/alternatives-page.mjs";
2425
import { filmstripPick, isAttributionLicence, previewCredit, thumbRelPath } from "./lib/thumbs.mjs";
2526
import { summaryFromBody } from "./lib/frontmatter.mjs";
2627
import { readCatalog, idMatchesFile } from "./lib/entry-files.mjs";
@@ -54,6 +55,7 @@ const CONFIG_PATH = path.join(__dirname, "config.json");
5455
const VOCAB_PATH = path.join(__dirname, "license-vocabulary.json");
5556
const SPDX_ALLOWED_PATH = path.join(__dirname, "spdx-allowed.json");
5657
const FORMATS_PATH = path.join(__dirname, "format-vocabulary.json");
58+
const ALTERNATIVES_PATH = path.join(__dirname, "alternatives.json");
5759
const THUMBS_MANIFEST = path.join(__dirname, "thumbs.json");
5860
// Social preview image: a first-party screenshot of this site, kept with the
5961
// other first-party stills (the validator allows binaries there) and copied
@@ -337,20 +339,33 @@ function writeEntryPages({ entries, bodies, config, stats, stamp, hasCard, now,
337339
}
338340

339341
/** Writes dist/category/<id>/index.html for every configured category with a visible entry. */
340-
function writeCategoryPages({ entries, config, stats, stamp, hasCard, now }) {
342+
function writeCategoryPages({ entries, config, stats, stamp, hasCard, now, altDefs = [] }) {
341343
const written = [];
342344
for (const [cat, meta] of Object.entries(config.categories)) {
343345
const group = entries.filter((e) => e.category === cat);
344346
if (!group.length) continue;
345347
writeOut(
346348
path.join("category", cat, "index.html"),
347-
categoryPageHtml({ cat, meta, entries: group, site: config.site, stamp, total: stats.listed, hasCard, now })
349+
categoryPageHtml({ cat, meta, entries: group, site: config.site, stamp, total: stats.listed, hasCard, now, alternatives: alternativesForCategory(altDefs, entries, cat) })
348350
);
349351
written.push(`category/${cat}/index.html`);
350352
}
351353
return { written };
352354
}
353355

356+
/** Writes dist/alternatives/<slug>/index.html for every page in alternatives.json (#189). */
357+
function writeAlternativesPages({ entries, config, stats, stamp, hasCard, now, altDefs }) {
358+
const written = [];
359+
for (const def of altDefs) {
360+
writeOut(
361+
path.join("alternatives", def.slug, "index.html"),
362+
alternativesPageHtml({ def, entries: alternativesFor(def, entries), categories: config.categories, site: config.site, stamp, total: stats.listed, hasCard, now })
363+
);
364+
written.push(`alternatives/${def.slug}/index.html`);
365+
}
366+
return { written };
367+
}
368+
354369
/**
355370
* docs/ guides as guide/<id>/ pages. Links to entries go to their pages,
356371
* links to another guide go to its page, anything else to GitHub.
@@ -605,7 +620,7 @@ function main() {
605620
.filter((cat) => visible.some((e) => e.category === cat))
606621
.map((id) => ({ id, lastmod: stamp }));
607622
const modified = lastCommitDates();
608-
writeOut("sitemap.xml", sitemapXml({ site: config.site, entries: visible, stacks, stamp, modified, categories: categoriesInSitemap, guides: config.guides }));
623+
writeOut("sitemap.xml", sitemapXml({ site: config.site, entries: visible, stacks, stamp, modified, categories: categoriesInSitemap, guides: config.guides, alternatives: JSON.parse(fs.readFileSync(ALTERNATIVES_PATH, "utf8")).pages.map((p) => ({ slug: p.slug, lastmod: stamp })) }));
609624
writeOut("robots.txt", robotsTxt(config.site));
610625
// Installable, and the catalog works offline after one visit (#111).
611626
writeOut("manifest.webmanifest", `${JSON.stringify(webManifest(config.site), null, 2)}\n`);
@@ -628,7 +643,14 @@ function main() {
628643
writeOut(path.join("entry", entry.id, "changes.xml"), changesFeedXml({ entry, events: changes.get(entry.id) || [], siteUrl: config.site.siteUrl, generatedAt: payload.generatedAt }));
629644
}
630645
const stackPages = writeStackPages({ stacks, entries, config, stats, stamp, hasCard, now });
631-
const categoryPages = writeCategoryPages({ entries: visible, config, stats, stamp, hasCard, now });
646+
const altDefs = JSON.parse(fs.readFileSync(ALTERNATIVES_PATH, "utf8")).pages;
647+
const altErrors = checkAlternatives(altDefs, visible, config.categories);
648+
if (altErrors.length) {
649+
console.error(`Build failed:\n - ${altErrors.join("\n - ")}`);
650+
process.exit(1);
651+
}
652+
const categoryPages = writeCategoryPages({ entries: visible, config, stats, stamp, hasCard, now, altDefs });
653+
const altPages = writeAlternativesPages({ entries: visible, config, stats, stamp, hasCard, now, altDefs });
632654
const guidePages = writeGuidePages({ entries, config, stats, stamp, hasCard, modified });
633655
const pageErrors = [
634656
...stackErrors,
@@ -667,7 +689,7 @@ function main() {
667689
`Built ${entries.length} entries → site/dist (${stats.active} active, ${stats.commercialOk} commercial-ok, ${stats.commercialVaries} per-file)`
668690
);
669691
console.log(
670-
`Prerendered ${visible.length} entry rows into index.html; wrote ${pages.written.length} entry pages, ${stackPages.written.length} stack pages, ${categoryPages.written.length} category pages, ${guidePages.written.length} guide pages, sitemap.xml, robots.txt, 404.html, freshness/index.html`
692+
`Prerendered ${visible.length} entry rows into index.html; wrote ${pages.written.length} entry pages, ${stackPages.written.length} stack pages, ${categoryPages.written.length} category pages, ${altPages.written.length} alternatives pages, ${guidePages.written.length} guide pages, sitemap.xml, robots.txt, 404.html, freshness/index.html`
671693
);
672694
console.log(`${writes()} of ${produced.size} output files changed${clean ? " (clean build)" : ""}; ${((Date.now() - started) / 1000).toFixed(1)}s`);
673695
}

‎site/lib/alternatives-page.mjs‎

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* "Free alternatives to ..." pages (#189): one per common search, defined in
3+
* site/alternatives.json, listing the active catalog entries that answer it
4+
* with their recorded licence verdicts. Pure.
5+
*/
6+
import { groupedEntriesHtml } from "./cards.mjs";
7+
import { baseHeadHtml, breadcrumbLd, clipText, entryPageUrl, esc, SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, PAGE_MODULES, siteHeaderHtml, siteFooterHtml } from "./shared.mjs";
8+
import { scriptJson } from "./entry-page.mjs";
9+
10+
/** Fewer matches than this and the page is not worth a search result; the build fails. */
11+
export const MIN_ALTERNATIVES = 3;
12+
13+
export function alternativesPageUrl(site, slug) {
14+
return `${String(site.siteUrl).replace(/\/+$/, "")}/alternatives/${slug}/`;
15+
}
16+
17+
/**
18+
* The active entries a page lists: any id in `ids`, or an entry in one of
19+
* `categories` carrying one of `tags` or `subcategories`, less `exclude`.
20+
* Only `active` entries: a page meant for search traffic shows settled
21+
* licences only.
22+
*/
23+
export function alternativesFor(def, entries) {
24+
const ids = new Set(def.ids || []);
25+
const exclude = new Set(def.exclude || []);
26+
const cats = new Set(def.categories || []);
27+
const tags = new Set(def.tags || []);
28+
const subs = new Set(def.subcategories || []);
29+
return entries.filter(
30+
(e) =>
31+
e.status === "active" &&
32+
!exclude.has(e.id) &&
33+
(ids.has(e.id) || (cats.has(e.category) && ((e.tags || []).some((t) => tags.has(t)) || (e.subcategories || []).some((s) => subs.has(s)))))
34+
);
35+
}
36+
37+
/** Problems with alternatives.json against the catalog: unknown ids or categories, duplicate slugs, too few matches. */
38+
export function checkAlternatives(defs, entries, categories) {
39+
const errors = [];
40+
const known = new Set(entries.map((e) => e.id));
41+
const slugs = new Set();
42+
for (const def of defs) {
43+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(String(def.slug))) errors.push(`alternatives.json: slug "${def.slug}" must be lower-case kebab-case`);
44+
if (slugs.has(def.slug)) errors.push(`alternatives.json: duplicate slug "${def.slug}"`);
45+
slugs.add(def.slug);
46+
if (!def.title || !def.context) errors.push(`alternatives.json: "${def.slug}" needs a title and a context sentence`);
47+
for (const id of [...(def.ids || []), ...(def.exclude || [])]) if (!known.has(id)) errors.push(`alternatives.json: "${def.slug}" names unknown entry "${id}"`);
48+
for (const c of def.categories || []) if (!(c in categories)) errors.push(`alternatives.json: "${def.slug}" names unknown category "${c}"`);
49+
const n = alternativesFor(def, entries).length;
50+
if (n < MIN_ALTERNATIVES) errors.push(`alternatives.json: "${def.slug}" matches ${n} active entries; it needs at least ${MIN_ALTERNATIVES}`);
51+
}
52+
return errors;
53+
}
54+
55+
/** The alternatives pages that list entries of a category, for that category page's links. */
56+
export function alternativesForCategory(defs, entries, cat) {
57+
return defs.filter((def) => alternativesFor(def, entries).some((e) => e.category === cat));
58+
}
59+
60+
/** schema.org CollectionPage, the entries as an ItemList, like a category page. */
61+
export function alternativesJsonLd({ def, description, entries, site }) {
62+
const url = alternativesPageUrl(site, def.slug);
63+
return {
64+
"@context": "https://schema.org",
65+
"@type": "CollectionPage",
66+
name: def.title,
67+
description,
68+
url,
69+
isPartOf: { "@type": "WebSite", name: site.title, url: site.siteUrl },
70+
breadcrumb: breadcrumbLd([
71+
{ name: site.title, url: site.siteUrl },
72+
{ name: def.title, url },
73+
]),
74+
mainEntity: {
75+
"@type": "ItemList",
76+
numberOfItems: entries.length,
77+
itemListElement: entries.map((e, i) => ({ "@type": "ListItem", position: i + 1, name: e.name, url: entryPageUrl(site, e.id) })),
78+
},
79+
};
80+
}
81+
82+
export function alternativesPageHtml({ def, entries, categories, site, stamp, total, hasCard, now }) {
83+
const url = alternativesPageUrl(site, def.slug);
84+
const n = entries.length;
85+
const sources = `${n} free ${n === 1 ? "source" : "sources"}`;
86+
const description = clipText(`${def.title}: ${sources} for games, each licence read at the source and dated.`, SEO_DESCRIPTION_MAX);
87+
const title = `${def.title} | ${site.title}`;
88+
const repo = site.repo;
89+
// Grouped by category in the catalog's order, as on the home page.
90+
const used = Object.fromEntries(Object.entries(categories).filter(([cat]) => entries.some((e) => e.category === cat)));
91+
const grid = groupedEntriesHtml(entries, used, { root: "../../", repo, now, limit: false, headingLevel: 2, titleLevel: 3 });
92+
return `<!DOCTYPE html>
93+
<html lang="en">
94+
<head>
95+
<meta charset="utf-8" />
96+
<meta name="viewport" content="width=device-width, initial-scale=1" />
97+
<title>${esc(clipText(title, SEO_TITLE_MAX))}</title>
98+
<meta name="description" content="${esc(description)}" />
99+
${baseHeadHtml({ site, title, description, url, hasCard, root: "../../", modules: PAGE_MODULES.category })}
100+
<script type="application/ld+json">${scriptJson(alternativesJsonLd({ def, description, entries, site }))}</script>
101+
</head>
102+
<body>
103+
<a class="skip-link" href="#entry-grid">Skip to the list</a>
104+
${siteHeaderHtml({ root: "../../", repo })}
105+
<main class="section category-page" id="content">
106+
<nav class="breadcrumb" aria-label="Breadcrumb">
107+
<a href="../../#catalog">Catalog</a> <span aria-hidden="true">/</span>
108+
<span aria-current="page">${esc(def.title)}</span>
109+
</nav>
110+
<h1>${esc(def.title)}</h1>
111+
<p class="section-blurb">${esc(def.context)}</p>
112+
<p class="section-blurb">${esc(sources)}, active entries only. Licences are as the catalog read them at the source on each entry's verified date; re-check the live source before shipping.</p>
113+
<div class="entry-list" id="entry-grid">
114+
${grid}
115+
</div>
116+
</main>
117+
${siteFooterHtml({ root: "../../", stamp, total })}
118+
<script type="module" src="../../category.js"></script>
119+
<script type="module" src="../../shortlist.js"></script>
120+
</body>
121+
</html>
122+
`;
123+
}

‎site/lib/category-page.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function categoryJsonLd({ cat, label, description, entries, site }) {
2929
};
3030
}
3131

32-
export function categoryPageHtml({ cat, meta, entries, site, stamp, total, hasCard, now }) {
32+
export function categoryPageHtml({ cat, meta, entries, site, stamp, total, hasCard, now, alternatives = [] }) {
3333
const label = meta.label || cat;
3434
const blurb = meta.blurb || "";
3535
const url = categoryPageUrl(site, cat);
@@ -62,7 +62,8 @@ export function categoryPageHtml({ cat, meta, entries, site, stamp, total, hasCa
6262
<h1>${esc(label)}</h1>
6363
<p class="section-blurb">${esc(sources)} · ${esc(blurb)}</p>
6464
<p class="category-search"><a href="../../?cat=${encodeURIComponent(cat)}#catalog">Search and filter on the catalog page</a> · <a href="feed.xml">Feed of new ${esc(label)} sources</a></p>
65-
<div class="entry-list" id="entry-grid">
65+
${alternatives.length ? ` <p class="category-search">Free alternatives: ${alternatives.map((a) => `<a href="../../alternatives/${esc(a.slug)}/">${esc(a.title.replace(/^Free alternatives to /, ""))}</a>`).join(" · ")}</p>
66+
` : ""} <div class="entry-list" id="entry-grid">
6667
${grid}
6768
</div>
6869
</main>

‎site/lib/exports.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function commitDatesFromLog(out) {
3737
* catalog date (`verified`, `walked`) and the file's last commit date from
3838
* `modified` (repo path => YYYY-MM-DD), falling back to the build date.
3939
*/
40-
export function sitemapXml({ site, entries, stacks = [], stamp, modified = new Map(), categories = [], guides = [] }) {
40+
export function sitemapXml({ site, entries, stacks = [], stamp, modified = new Map(), categories = [], guides = [], alternatives = [] }) {
4141
const base = String(site.siteUrl).replace(/\/+$/, "");
4242
const latest = (...dates) => dates.filter(Boolean).sort().pop() || stamp;
4343
const url = (loc, lastmod) => ` <url><loc>${esc(loc)}</loc><lastmod>${esc(lastmod)}</lastmod></url>`;
@@ -47,6 +47,7 @@ export function sitemapXml({ site, entries, stacks = [], stamp, modified = new M
4747
url(`${base}/audit/`, stamp),
4848
...categories.map((c) => url(`${base}/category/${c.id}/`, c.lastmod || stamp)),
4949
...guides.map((g) => url(`${base}/guide/${g.id}/`, modified.get(g.path) || stamp)),
50+
...alternatives.map((a) => url(`${base}/alternatives/${a.slug}/`, a.lastmod || stamp)),
5051
...stacks.map((s) => url(`${base}/stack/${s.meta.id}/`, latest(s.meta.walked, modified.get(s.rel)))),
5152
...entries.map((e) => url(`${base}/entry/${e.id}/`, latest(e.verified, modified.get(e.path)))),
5253
];

‎site/lib/lib.test.mjs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,26 @@ await section("needs-review open question (#211)", async () => {
26222622
eq("singleton report: counts unique tags", report.unique, 3);
26232623
eq("singleton report: lists one-off tags", report.singles.join(), "b,c");
26242624
eq("singleton report: flags a share over a fifth", report.over, true);
2625+
// #189: "free alternatives to ..." pages list active matches only.
2626+
const alt = await import("./alternatives-page.mjs");
2627+
const altEntries = [
2628+
{ id: "a", name: "A", status: "active", category: "3d", tags: ["low-poly"], subcategories: [] },
2629+
{ id: "b", name: "B", status: "needs-review", category: "3d", tags: ["low-poly"], subcategories: [] },
2630+
{ id: "c", name: "C", status: "active", category: "audio", tags: ["low-poly"], subcategories: [] },
2631+
{ id: "d", name: "D", status: "active", category: "3d", tags: [], subcategories: ["modular"] },
2632+
{ id: "e", name: "E", status: "active", category: "tools", tags: [], subcategories: [] },
2633+
{ id: "x", name: "X", status: "active", category: "3d", tags: ["low-poly"], subcategories: [] },
2634+
];
2635+
const altDef = { slug: "s", title: "Free alternatives to S", context: "c", categories: ["3d"], tags: ["low-poly"], subcategories: ["modular"], ids: ["e"], exclude: ["x"] };
2636+
eq("alternatives: active matches by tag, subcategory and id, less exclude", alt.alternativesFor(altDef, altEntries).map((e) => e.id).join(), "a,d,e");
2637+
eq("alternatives: a valid page passes", alt.checkAlternatives([altDef], altEntries, { "3d": {}, tools: {} }).length, 0);
2638+
has("alternatives: too few matches fails", alt.checkAlternatives([{ ...altDef, ids: [], subcategories: [] }], altEntries, { "3d": {} }).join(), "needs at least 3");
2639+
has("alternatives: an unknown id fails", alt.checkAlternatives([{ ...altDef, ids: ["nope"] }], altEntries, { "3d": {} }).join(), 'unknown entry "nope"');
2640+
has("alternatives: a bad slug fails", alt.checkAlternatives([{ ...altDef, slug: "Bad Slug" }], altEntries, { "3d": {} }).join(), "kebab-case");
2641+
eq("alternatives: linked from the categories it lists", alt.alternativesForCategory([altDef], altEntries, "tools").length, 1);
2642+
eq("alternatives: not from a category it does not list", alt.alternativesForCategory([altDef], altEntries, "audio").length, 0);
2643+
const altSitemap = (await import("./exports.mjs")).sitemapXml({ site: { siteUrl: "https://x.test/s/" }, entries: [], stamp: "2026-11-18", alternatives: [{ slug: "s" }] });
2644+
has("alternatives: in the sitemap", altSitemap, "<loc>https://x.test/s/alternatives/s/</loc>");
26252645
// #117: every entry page has its own social card.
26262646
const { entryCardRef, entryCardHtml } = await import("./og-card.mjs");
26272647
const { baseHeadHtml } = await import("./shared.mjs");

0 commit comments

Comments
 (0)