· 2 min read
A profile filter on /about
/about can show only the skills for one kind of job: ?profile=web, support or mainframe (the ids from content/skills.yaml). A group left with no skills…
What we did
/aboutcan show only the skills for one kind of job:?profile=web,supportormainframe(the ids fromcontent/skills.yaml). A group left with no skills disappears, and so does its link in the side nav.- The picker is a radio group (
fieldset+legend"Show skills for"), with "Everything" first, and a count (13 of 93 skills,role="status"). On wide screens it sticks with the nav, so I can switch halfway down the page. - Like the Awesome filters: the profile is read from the URL in
onMountand written back withgoto(url, { shallow: true, replace: true }). "Everything" removes the param. An unknown?profile=shows everything. - The logo marquee isn't filtered: it's decoration, and a profile with few logos would leave gaps in the loop.
What I learned
- One
$state(profile), everything else$derivedfrom it: the groups, the nav sections, the count. If I updated the nav by hand inpick(), I'd also have to do it inonMountand anywhere else that changes the profile, and forgetting one leaves the nav out of step with the windows. Store the least state, compute the rest. - TypeScript narrows
profileafterif (!profile), but not inside a callback (it could run later, whenprofilehas changed). Copying it into aconstfirst keeps the narrowing. - Radios for one choice,
aria-pressedtoggles for several. Radios come with arrow keys, one Tab stop for the group, and "radio button, 2 of 4" in a screen reader. - The input is hidden with
opacity: 0, notdisplay: none:display: nonetakes it out of the tab order and the accessibility tree. The label is what you see, styled withlabel:has(:checked)andlabel:has(:focus-visible). - The page is prerendered once, at build time, into one
about.htmlthat GitHub Pages serves for every query string. There's no?profile=while prerendering, so only the browser can read it (onMount). Without JS: every skill, every window open, no filter.
Links
Next
- The
/projects/cvtool: pick a profile, and the skills come from the YAML, strongest first.