From: sabadev Date: Wed, 17 Mar 2021 19:16:58 +0000 (-0400) Subject: Turned the main page definition into a markdown file. X-Git-Url: http://sabadev.xyz:4321/?a=commitdiff_plain;h=5029b6c001f746e09de2f2ecdc6e74cf97df444e;p=website.git Turned the main page definition into a markdown file. --- diff --git a/src/Server.hs b/src/Server.hs index bc53f56..30a52bd 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -22,11 +22,9 @@ apiProxy = Proxy type Api = Page :<|> Themes type Page = MainPage :<|> BlogPost --- TODO Turn MainPage into another BlogPost, and instead have some index.md file that I can look for. --- Perhaps have a config.json file to specify the index.md file and the static directory location. type MainPage = ThemeParam :> Get '[HTML] (Html ()) -type BlogPost = "blog" :> ThemeParam :> Capture "id" BlogId :> Get '[HTML] (Html ()) -type Themes = DarkTheme :<|> LightTheme +type BlogPost = ThemeParam :> Capture "id" BlogId :> Get '[HTML] (Html ()) +type Themes = "style" :> (DarkTheme :<|> LightTheme) type DarkTheme = "dark" :> Get '[CSS] C.Css type LightTheme = "light" :> Get '[CSS] C.Css type ThemeParam = QueryParam "light" Bool @@ -42,7 +40,7 @@ page :: Server Page page = mainPage :<|> blogPost mainPage :: UseLightTheme -> Handler (Html ()) -mainPage useLight = htmlContainer useLight $ h1_ $ toHtml siteTitle +mainPage = flip blogPost "index" blogPost :: UseLightTheme -> BlogId -> Handler (Html ()) blogPost useLight = htmlContainer useLight . renderBlog <=< findBlogPost @@ -90,7 +88,7 @@ makeLink :: UseLightTheme -> T.Text -> T.Text makeLink useLight link = let lightThemeOn = useLightTheme useLight in if lightThemeOn then link <> "?light=true" else link <> "?light=false" blogLink :: T.Text -> Maybe T.Text -blogLink = pure . (<>) "/blog/" <=< T.stripSuffix markdownExtension +blogLink = T.stripSuffix markdownExtension siteTitle :: T.Text siteTitle = "My Site" @@ -105,4 +103,4 @@ useLightTheme :: UseLightTheme -> Bool useLightTheme = fromMaybe False getTheme :: UseLightTheme -> T.Text -getTheme theme = let lightThemeOn = useLightTheme theme in if lightThemeOn then "/light" else "/dark" +getTheme theme = let lightThemeOn = useLightTheme theme in if lightThemeOn then "/style/light" else "/style/dark"