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.

Write.hs 1.0KB

12345678910111213141516171819202122232425
  1. module Write where
  2. import qualified Data.Text as T
  3. import System.Directory ( createDirectoryIfMissing
  4. , makeAbsolute
  5. )
  6. import System.FilePath ( joinPath )
  7. import Post ( RawPost )
  8. import Utils ( basename )
  9. writePost :: FilePath -> RawPost -> IO ()
  10. writePost buildPath (path, contents) = do
  11. outputDir <- makeAbsolute $ joinPath [buildPath, "posts", basename path]
  12. let outputFile = joinPath [outputDir, "index.html"]
  13. createDirectoryIfMissing False outputDir
  14. writeFile outputFile $ T.unpack contents
  15. writeIndexPage :: FilePath -> T.Text -> IO ()
  16. writeIndexPage buildPath page =
  17. writeFile (joinPath [buildPath, "index.html"]) (T.unpack page)
  18. writeRSSFeed :: FilePath -> T.Text -> IO ()
  19. writeRSSFeed buildPath feed =
  20. writeFile (joinPath [buildPath, "rss.xml"]) (T.unpack feed)