chichiwang / tamsui

An Express/React universal application boilerplate
https://tamsui.dev/
MIT License
0 stars 1 forks source link

Create hook: `useRouteHead` and use it to apply page-specific titles #146

Closed chichiwang closed 4 months ago

chichiwang commented 4 months ago

Description

Linked to Issue: #126 Create a hook useRouteHead that leverages React Router's useMatches and useLocation hooks to fetch a property head from a PageHandle object passed through the router.

This is used to pass page-specific titles and head tags to the <Head /> component based on the route. If a route head is found containing a title attribute, that will be used to set the title, otherwise it will use a default title string.

Documentation is created in app/hooks/README.md for this new useRouteHead hook.

This PR creates PageHandles for the routes /documentation, /error, and * containing titles.

Changes

Steps to QA