Skip to content

Teach routing with tag pages - #38

Merged
gpbsumido merged 5 commits into
ps/ng-06-rxjsfrom
ps/ng-07-routing
Nov 21, 2026
Merged

gpbsumido merged 5 commits into
ps/ng-06-rxjsfrom
ps/ng-07-routing

Conversation

@gpbsumido

@gpbsumido gpbsumido commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Seventh lesson in my Angular guide: routing. The feature slice is a page for every tag.

What shipped

Tag pages. /thoughts/tag/<tag> is prerendered for every tag, with its own title and canonical URL, and every tag pill links to it. /thoughts/tag/angular-guide is the reading list for this series. Prerendered routes went from 27 to 74.

It's a path param, not ?tag=. Prerendering writes one file per path, so a query-param page would be served the unfiltered list and then change under the reader during hydration.

Cards are links. Thoughts list cards were div role="button"s calling router.navigate(). Now the title is a real routerLink, and a stretched ::after keeps the whole card clickable. That is also what lets the tag pills be links, because a link can't sit inside a button.

Wildcard route. A ** route sits last in the table and redirects to the desktop. A mistyped URL used to fail the first navigation with NG04002.

Route input binding. The reader takes :slug as an input via withComponentInputBinding() instead of toSignal(route.paramMap). Its ActivatedRoute and RxJS imports are gone.

Lesson 07: routing (/thoughts/angular-07-routing)

  • Covers the material at three levels (simple, intermediate, expert), then pitfalls and interview Q&A:
    • route order
    • params as inputs
    • path vs query params
    • lazy loading
    • functional guards
    • server routes and getPrerenderParams
    • route reuse
  • The playground parses a URL with Angular's UrlSerializer and matches it against this site's real route table. A checkbox moves the wildcard to the front to show first-match-wins.
  • Lesson 04's text now notes that lesson 07 replaced the code it shows.

Version and changelog. 1.4.6, with a matching changelog entry.

Commits

  1. Add failing specs for tag pages, a wildcard route and lesson 07
  2. Bind the reader's slug as a route input
  3. Add prerendered tag pages and a wildcard route
  4. Write lesson 07 with a route-matching playground
  5. Bump to 1.4.6 with the lesson 07 changelog entry

Verification

  • RED first. With the not-yet-compiling SEO and lesson specs set aside, the RED commit had 7 failures, each for the right reason:
    • NG04002: Cannot match any routes. URL Segment: 'no-such-page'
    • the same for thoughts/tag/angular-guide
    • no tag server route
    • no tag links in the list or the reader
    • NG0303 for the missing tag input
  • New route spec. app.routes.spec.ts drives the real route table with the real appConfig through RouterTestingHarness.
  • Tests. ng test: 57 files, 406 tests, exit 0. They include a new axe check on the list. Axe also caught a role="status" on a <dd> in the lesson demo, which I moved to a wrapper.
  • Static checks. Lint and both tsc --noEmit configs are clean.
  • Production build. Exit 0, no budget warnings. 74 routes prerendered. thoughts/tag/angular-guide/index.html has the title "Thoughts tagged angular-guide", hrefs to all seven lessons, and a canonical of /thoughts/tag/angular-guide.
  • Bundle. Initial bundle 389.82 → 391.72 kB.

TO-DOs for this PR

  • Before/after screenshots of the Thoughts list (cards with linked tags), the angular-guide tag page, and the lesson 07 playground, light and dark. Chromium couldn't launch in the environment I built this in.

@gpbsumido
gpbsumido marked this pull request as ready for review November 21, 2026 15:17
@gpbsumido
gpbsumido added this pull request to stack #46 November 21, 2026 17:00
@gpbsumido
gpbsumido merged commit 530c68f into develop Nov 21, 2026
2 checks passed
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