sampu/src/Fragments/Base.hs

52 lines
1.4 KiB
Haskell

module Fragments.Base where
import Core.Rendering
import Data.Text
import Data.String (fromString)
import Lucid
baseDoc :: String -> Html () -> Html ()
baseDoc title bodyContent = doctypehtml_ $ do
head_ $ do
title_ $ fromString title
link_ [rel_ "stylesheet", type_ "text/css", href_ "/style.css"]
script_ [src_ "/htmx.min.js"] none
body_ bodyContent
baseNav :: Html ()
baseNav = div_ [class_ "navContainer"] $ do
ul_ [class_ "mainNav"] $ do
li_ $ a_ [href_ "/"] "Home"
li_ $ a_ [href_ "/posts"] "Posts"
li_ $ a_ [href_ "/contact"] "Contact"
li_ $ a_ [href_ "/feed"] "Feed"
basePage :: String -> Html () -> Html()
basePage title body = baseDoc title $ baseNav <> body
baseHome :: Html () -> Html ()
baseHome content = div_ [class_ "main"] content
basePost :: Html () -> Html ()
basePost content = div_ [class_ "main"] content
postIndex :: [FilePath] -> Html ()
postIndex postNames = div_ [class_ "main"] $ do
h1_ [class_ "title"] "All Posts"
ul_ [class_ "postList"] $ do
mapM_
(\x -> li_ $ a_ [href_ (pack $ "/posts/" ++ x)] (fromString x))
postNames
baseContact :: Html () -> Html ()
baseContact content = div_ [class_ "main"] content
baseFeed :: Html ()
baseFeed = div_ [class_ "main"] $ do
h2_ "Oops, I haven't been implemented yet."
h3_ "Check back in a couple days!"
none :: Text
none = mempty