Created
April 22, 2022 19:01
-
-
Save aleclarson/1dea130b963f87d65a23c6dda140dab0 to your computer and use it in GitHub Desktop.
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
import { route } from 'saus' | |
// Default route | |
route(() => import('./routes/UnknownPage')) | |
// Catch route | |
route('error', () => import('./routes/ErrorPage')) | |
// | |
// Matched routes | |
// | |
route('/', () => import('./routes/HomePage')) | |
route('/blog/:slug', () => import('./routes/BlogPost'), { | |
// Inline a state module since only this page uses it. | |
inline: req => [ | |
blogPostModule.bind(req.slug), | |
], | |
}) | |
// Responds to GET /blog/[slug].json | |
.get('.json', req => blogPostModule.load(req.slug)) | |
// SSR-based search page (based on arbitrary user input) | |
// Dynamically rendered as an entry point for a search URL. | |
// For best UX, subsequent searches should use REST/RPC loading with CSR. | |
route('/search', () => import('./routes/SearchPage'), { | |
inline: req => [ | |
blogSearchModule.bind(req.searchParams.get('q')), | |
], | |
}) | |
// Responds to POST /search.json | |
.post('.json', req => blogSearchModule.load(req.input.q)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment