A static site generator written in Haskell
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728
  1. module Read where
  2. import System.Directory ( listDirectory )
  3. import System.FilePath ( FilePath )
  4. import Build ( buildRawPost )
  5. import Post ( RawPost )
  6. import Utils ( makeFullFilePath )
  7. readPostTemplate :: FilePath -> IO String
  8. readPostTemplate root = readFile $ root ++ "/templates/_post.html"
  9. readIndexTemplate :: FilePath -> IO String
  10. readIndexTemplate root = readFile $ root ++ "/templates/_index.html"
  11. readRSSTemplate :: FilePath -> IO String
  12. readRSSTemplate root = readFile $ root ++ "/templates/_rss.xml"
  13. readPostContents :: String -> Bool -> IO [RawPost]
  14. readPostContents root drafts = do
  15. postsPath <- makeFullFilePath root "posts"
  16. draftsPath <- makeFullFilePath root "drafts"
  17. postPaths <- listDirectory postsPath
  18. draftPaths <- listDirectory draftsPath
  19. absoluteDraftPaths <- mapM (makeFullFilePath draftsPath) draftPaths
  20. absolutePostPaths <- mapM (makeFullFilePath postsPath) postPaths
  21. mapM buildRawPost
  22. (absolutePostPaths ++ if drafts then absoluteDraftPaths else [])