1
1
mirror of https://github.com/srid/rib.git synced 2024-11-27 01:12:09 +03:00

Add singular version of buildHtmlMulti

buildHtml was incorrectly named; it should have actually been called
writeHtml. This commit also actually implements buildHtml, which is like
buildHtmlMulti but operating on a single file.
This commit is contained in:
Sridhar Ratnakumar 2019-12-31 21:25:29 -05:00
parent 916f671b3a
commit 7ec05a94af

View File

@ -9,10 +9,11 @@
-- See the source of `Rib.Simple.buildAction` for example usage.
module Rib.Shake
( -- * Basic helpers
readSource,
buildStaticFiles,
buildHtmlMulti,
buildHtml,
readSource,
writeHtml,
-- * Misc
RibSettings (..),
@ -95,18 +96,26 @@ buildHtmlMulti ::
buildHtmlMulti pats parser r = do
input <- ribInputDir
fs <- getDirectoryFiles' input pats
forP fs $ \k -> do
forP fs $ \k -> buildHtml k parser r
-- | Like buildHtmlMulti but operates on a single file.
buildHtml ::
Path Rel File ->
SourceReader repr ->
(Source repr -> Html ()) ->
Action (Source repr)
buildHtml k parser r = do
src <- readSource parser k
outfile <- liftIO $ replaceExtension ".html" k
writeFileCached outfile $ toString $ Lucid.renderText $ r src
writeHtml outfile $ r src
pure src
-- | Build a single HTML file with the given HTML value
-- | Write a single HTML file with the given HTML value
--
-- The HTML text value will be cached, so subsequent writes of the same value
-- will be skipped.
buildHtml :: Path Rel File -> Html () -> Action ()
buildHtml f = writeFileCached f . toString . Lucid.renderText
writeHtml :: Path Rel File -> Html () -> Action ()
writeHtml f = writeFileCached f . toString . Lucid.renderText
-- | Like writeFile' but uses `cacheAction`.
--