aboutsummaryrefslogtreecommitdiff
path: root/site.hs
diff options
context:
space:
mode:
authorRonan Tremoureux <ronan.tremoureux@ext.uni.lu>2023-06-22 09:13:37 +0200
committerRonan Tremoureux <ronan.tremoureux@ext.uni.lu>2023-06-22 09:13:37 +0200
commit73d1920b6296bf73fbef87c9e8460cd5d2c2071e (patch)
treec5eb1d3c6eb61e9c565e9c46431de3bd6872d686 /site.hs
parentfa3612d3fc78d0d88750278f825d0d0cd830e9da (diff)
parente44c0d35b49d130a9ff8d7f0a244b76bf7d54259 (diff)
downloadreploy-73d1920b6296bf73fbef87c9e8460cd5d2c2071e.tar.gz
reploy-73d1920b6296bf73fbef87c9e8460cd5d2c2071e.tar.bz2
Merge branch 'mk-dont-source-assets' into 'master'
avoid source dirs Closes #4 See merge request R3-core/websites-dev/reploy!2
Diffstat (limited to 'site.hs')
-rw-r--r--site.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/site.hs b/site.hs
index f91c007..d3b7f15 100644
--- a/site.hs
+++ b/site.hs
@@ -3,7 +3,7 @@
-- | The main deployment script.
module Main where
-import Control.Monad ((>=>), join, unless, when)
+import Control.Monad ((>=>), filterM, join, unless, when)
import Control.Monad.Extra (whenM)
import Control.Monad.Trans.State.Lazy
import qualified Data.Aeson as AE
@@ -48,13 +48,19 @@ import FormatOpts
import Types
import Utils
+-- | Check if a given path should be sourced or not
+isSourceablePath :: FilePath -> Site Bool
+isSourceablePath fp = do
+ notSource <- use notSourceDirs
+ pure $ (&&) <$> hasSuffix ".md" . last <*> not . any (`elem` notSource) . init $
+ splitPath fp
+
-- | Load the pages from a directory and add them to `pages`.
sourcePages :: FilePath -> Site ()
sourcePages fp =
- io
- (map (fp </>) . filter (hasSuffix ".md" . last . splitPath) <$>
- getRecursiveContents (pure . const False) fp) >>=
- traverse_ loadPage
+ (io $ getRecursiveContents (pure . const False) fp) >>=
+ filterM isSourceablePath >>=
+ traverse_ (loadPage . (fp </>))
{- | Extract `PageInfo` about a single page and save it into `pages` in
- `SiteState`. -}