A static site generator written in Haskell
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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)