From: sabadev Date: Tue, 16 Mar 2021 21:59:13 +0000 (-0400) Subject: Working on adding blog post lookups. X-Git-Url: http://sabadev.xyz:4321/?a=commitdiff_plain;h=7116d156a1009d75fd19a993cbb204ec3a79dc33;p=website.git Working on adding blog post lookups. --- diff --git a/.gitignore b/.gitignore index ae1a9aa..82c9e92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *~ tags* .vagrant/ +static/ diff --git a/src/Server.hs b/src/Server.hs index dc04496..4af5b38 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -1,11 +1,13 @@ module Server where +import Control.Monad.IO.Class (liftIO) import CssContentType import Lucid import RenderBlog (renderBlog) import Servant import Servant.HTML.Lucid (HTML(..)) import qualified Data.Text as T +import qualified Data.Text.IO as T app :: Application app = serve apiProxy api @@ -32,19 +34,24 @@ mainPage = pure $ with doctypehtml_ [lang_ "en"] $ do meta_ [charset_ "utf8"] meta_ [name_ "description", content_ "width=device-width"] link_ [rel_ "stylesheet", href_ "/dark"] - body_ $ do + body_ $ div_ [role_ "main"] $ do h1_ $ toHtml siteTitle blogPost :: Maybe BlogId -> Handler (Html ()) blogPost Nothing = mainPage -blogPost (Just blogId) = mainPage +blogPost (Just blogId) = findBlogPost blogId >>= pure . renderBlog + +findBlogPost :: BlogId -> Handler T.Text +findBlogPost = liftIO . T.readFile . (<>) "/static/" themes :: Server Themes themes = darkTheme :<|> lightTheme +-- TODO Modify this endpoint to take in a single hex colour value and produce a stylesheet from it. darkTheme :: Handler T.Text darkTheme = pure mempty +-- TODO Modify this endpoint to take in a single hex colour value and produce a stylesheet from it. The strategy used here should be the inverse of the one used by the dark path. lightTheme :: Handler T.Text lightTheme = pure mempty