aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/Main.hs')
-rw-r--r--frontend/app/Main.hs22
1 files changed, 15 insertions, 7 deletions
diff --git a/frontend/app/Main.hs b/frontend/app/Main.hs
index 37230ad..f5ec4b6 100644
--- a/frontend/app/Main.hs
+++ b/frontend/app/Main.hs
@@ -23,8 +23,9 @@ data Model
deriving (Show, Eq)
data LoadedState = LoadedState
- { page :: Maybe (Either String Page),
- schemaVersion :: Version
+ { collections :: [String],
+ schemaVersion :: Version,
+ page :: Maybe (Either String Page)
}
deriving (Show, Eq)
@@ -69,8 +70,10 @@ updateModel (Init uri) Loading =
Loading <# do
page <- Just <$> initialPage (parseURI uri)
schemaVersion' <- fetchSchemaVersion
+ collections' <- fetchCollections
pure $ SetLoaded do
schemaVersion <- schemaVersion'
+ collections <- collections'
pure LoadedState {..}
updateModel (Init _) m = noEff m
updateModel (SetLoaded (Left err)) Loading = noEff (Failed err)
@@ -98,7 +101,7 @@ viewModel (Loaded s) =
div_ [] $
[ viewCss,
viewHeader s,
- nav_ [] [viewCollections],
+ nav_ [] [viewCollections s],
main_ [] $
[ HandlePage <$> maybe (text "..") (either err viewPage) s.page
]
@@ -208,12 +211,17 @@ viewBranch s =
select_ [] [option_ [] [text "main"]]
]
-viewCollections :: View Action
-viewCollections =
+viewCollections :: LoadedState -> View Action
+viewCollections s =
section_ [] $
[ span_ [] [text "collections"],
ol_ [] $
- [ li_ [] [a_ [href_ "#collection/posts"] [text "posts"]],
- li_ [] [a_ [href_ "#collection/posts1"] [text "posts1"]]
+ [ li_
+ []
+ [ a_
+ [href_ (toMisoString ("#collection/" <> collection))]
+ [text (toMisoString collection)]
+ ]
+ | collection <- s.collections
]
]