📖 Blog script with Haskell

Posted on May 25, 2018
    import Prelude hiding (readFile, writeFile, concat)
    import System.Directory
    import System.FilePath
    import Data.Text.Lazy hiding (filter, map, reverse)
    import Data.Text.Lazy.IO
    import Text.Markdown
    import Text.Blaze.Html.Renderer.Text

    main = do
      files <- getDirectoryContents "."
      let mds = filter ((== ".md") . takeExtension) files
      content <- mapM (readFile) mds
      let htmls = reverse $ map (renderHtml . markdown def) content

      header <- readFile "header.html"
      footer <- readFile "footer.html"

      writeFile "index.html" $ concat $ header:htmls ++ [footer]

I'd eventually like to serve this from some Haskell webserver rather than manually generating static pages. Maybe also use this?