Add three browse modes to index page: alphabetical, by tag, by course

- Add SortMode type (AlphaSort | TagSort | CourseSort) to Roux.Html
- Routes: / (alpha), /sorted/tags, /sorted/course
- AlphaSort: recipes sorted by title (from metadata) or filename
- TagSort: recipes grouped under tag headings, empty state when none
- CourseSort: recipes grouped by course/category metadata
- Navigation bar in index page with active-highlighted buttons
- Add metaCourse field to Metadata model (+ emptyMetadata update)
- Add nubOrd helper for deduplicating tag/course lists
- All 26 tests passing, hlint clean
This commit is contained in:
2026-05-19 08:16:58 -04:00
parent 6de6b6e2b2
commit b0926ee60d
4 changed files with 125 additions and 11 deletions
+7 -1
View File
@@ -41,7 +41,13 @@ app recipeDir = do
handleRequest :: [Idx.RecipeInfo] -> Wai.Application
handleRequest recipes request respond =
case Wai.pathInfo request of
[] -> respond (htmlResponse (Html.indexPage recipes))
-- Index page (default: alphabetical)
[] -> respond (htmlResponse (Html.indexPage Html.AlphaSort recipes))
-- Index page (sorted by tags)
["sorted", "tags"] -> respond (htmlResponse (Html.indexPage Html.TagSort recipes))
-- Index page (sorted by course/category)
["sorted", "course"] -> respond (htmlResponse (Html.indexPage Html.CourseSort recipes))
-- Recipe detail page
["recipes", rawPath] ->
case lookupRecipe (urlDecodePath rawPath) recipes of
Just info -> respond (htmlResponse (Html.recipePage info))