Initial commit
[haskell-blog.git] / posts / haskellMake.md
1 ---
2 title: ðŸ“– Blog script with Haskell
3 date: 2018-05-25
4 ---
5
6 ```haskell
7     import Prelude hiding (readFile, writeFile, concat)
8     import System.Directory
9     import System.FilePath
10     import Data.Text.Lazy hiding (filter, map, reverse)
11     import Data.Text.Lazy.IO
12     import Text.Markdown
13     import Text.Blaze.Html.Renderer.Text
14
15     main = do
16       files <- getDirectoryContents "."
17       let mds = filter ((== ".md") . takeExtension) files
18       content <- mapM (readFile) mds
19       let htmls = reverse $ map (renderHtml . markdown def) content
20
21       header <- readFile "header.html"
22       footer <- readFile "footer.html"
23
24       writeFile "index.html" $ concat $ header:htmls ++ [footer]
25 ```
26
27 I'd eventually like to serve this from some Haskell webserver rather than manually generating static pages.
28 Maybe also use [this?](https://github.com/mrkkrp/ghc-syntax-highlighter)