Close the earlier lessons and build this from the brief. The terms come from
getTerms() and getTerm(slug) in lib/terms.js.
The brief
/lists every term as a link to its own page,/terms/<slug>.- Above the list: All · C · L · P · R · S. Each letter links to
/?letter=S, which shows only the terms starting with that letter. /terms/stateshows the word as a heading, its meaning, and a link More terms starting with S to/?letter=S.- An unknown term, such as
/terms/zzz, shows No such term with a link back to the glossary. - The header's Glossary link is marked as the current page, with
aria-current="page", on/only.
Acceptance checks: follow S, then State, then More terms starting
with S. Try /terms/zzz.
Runs with real Next.js on your computer: unzip, then
npm install and npm run dev. Hint 1: files
app/terms/[slug]/page.jsx, app/terms/[slug]/not-found.jsx, and a client
NavLinks.jsx for the header.
Hint 2: the letter
term.word.startsWith(letter) and term.word[0] give you everything you need.
Show one solution
Runs with real Next.js on your computer: unzip, then
npm install and npm run dev. Check yourself
- Which file serves
/terms/state, and how does it find outstate? - Why is a filter better in the URL than in state?
- When would you use
router.replaceinstead ofrouter.push?
Completion is saved in this browser only. It does not measure mastery.