Skip to content

Let a category label link to its own page, not its section's - #90

Merged
ssavutu merged 1 commit into
mainfrom
fix/category-link-precedence
Aug 13, 2026
Merged

Let a category label link to its own page, not its section's#90
ssavutu merged 1 commit into
mainfrom
fix/category-link-precedence

Conversation

@ssavutu

@ssavutu ssavutu commented Aug 13, 2026

Copy link
Copy Markdown
Member

What

Makes taxonomyStore resolve a category label to a link using the same precedence the CMS uses: a row's own title first, aliases only for titles no row claims.

Why

indexTaxonomy built its map from category_aliases alone, first writer wins. /v1/taxonomy comes back ordered by kind, so every section is written before every subsection — which meant a section's alias beat a subsection's own title. An alias exists so a section can absorb a category that has no page of its own; it should never outrank that category once it has one.

This was a stopgap from when most WordPress sub-categories had no row at all. DrexelTriangle/triangle-cms#215 gives them rows, so the shortcut is now actively wrong.

How

Two tiers in indexTaxonomy: canonical_title claims a title first, then aliases fill the rest. This mirrors RefreshCategoryAliases in the CMS. Matching it is the point — the CMS sends a resolved slug on every category, and the fallback here shouldn't disagree with it about where a label leads. The map is renamed aliasesowners, since it's no longer an alias map.

Testing

eslint clean, astro check 0 errors / 0 warnings. There's no test runner in this repo, so I verified by running the old and new index functions side by side over the real /v1/taxonomy payload plus the 48 rows the CMS seed adds:

  • Steady state: nothing moves. All 101 in-use categories resolve identically, because the CMS-sent slug is routable and getCategoryHref short-circuits before reaching the map.
  • The fallback path is where it differs, which an edge-cached article response carrying a pre-seed slug will hit:
category before after
Men's Lacrosse /sports /mens-lacrosse
Editorial /opinion /editorial
Podcasts /columns /podcasts
Arts & Entertainment /entertainment /entertainment

Genuine aliases are unaffected — the last row is a category with no page of its own, and it still resolves to the section that absorbs it.

Ordering

Independent of DrexelTriangle/triangle-cms#215; either can ship first.

🤖 Generated with Claude Code

The map that turns a category label into a link was built from
category_aliases alone, first writer wins. /v1/taxonomy comes back ordered
by kind, so every section is written before every subsection, and a
section's alias beat a subsection's own title. An alias exists so a section
can absorb a category that has no page of its own; it should never outrank
that category once it has one.

Index canonical_title first and let aliases fill only the titles no row
claims, which is the precedence the CMS applies to the same question in
RefreshCategoryAliases. Matching it is the point: the CMS sends a resolved
slug on every category, and the fallback here should not disagree with it
about where a label leads.

On today's data nothing moves -- the CMS-sent slug is routable, so
getCategoryHref short-circuits before reaching the map. The difference
shows when it does not, which an edge-cached response carrying a pre-seed
slug will do: "Men's Lacrosse" resolves to /mens-lacrosse rather than
/sports. Genuine aliases are unaffected, and "Arts & Entertainment" still
resolves to /entertainment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ssavutu
ssavutu merged commit 5f549e7 into main Aug 13, 2026
1 check passed
@ssavutu
ssavutu deleted the fix/category-link-precedence branch August 13, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant