Let a category label link to its own page, not its section's - #90
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
taxonomyStoreresolve 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
indexTaxonomybuilt its map fromcategory_aliasesalone, first writer wins./v1/taxonomycomes back ordered bykind, 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_titleclaims a title first, then aliases fill the rest. This mirrorsRefreshCategoryAliasesin 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 renamedaliases→owners, since it's no longer an alias map.Testing
eslintclean,astro check0 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/taxonomypayload plus the 48 rows the CMS seed adds:getCategoryHrefshort-circuits before reaching the map.Men's Lacrosse/sports/mens-lacrosseEditorial/opinion/editorialPodcasts/columns/podcastsArts & Entertainment/entertainment/entertainmentGenuine 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