module Hakyll.Core.Configuration
( HakyllConfiguration (..)
, shouldIgnoreFile
, defaultHakyllConfiguration
) where
import System.FilePath (takeFileName)
import Data.List (isPrefixOf, isSuffixOf)
data HakyllConfiguration = HakyllConfiguration
{
destinationDirectory :: FilePath
,
storeDirectory :: FilePath
,
ignoreFile :: FilePath -> Bool
,
deployCommand :: String
,
inMemoryCache :: Bool
}
defaultHakyllConfiguration :: HakyllConfiguration
defaultHakyllConfiguration = HakyllConfiguration
{ destinationDirectory = "_site"
, storeDirectory = "_cache"
, ignoreFile = ignoreFile'
, deployCommand = "echo 'No deploy command specified'"
, inMemoryCache = True
}
where
ignoreFile' path
| "." `isPrefixOf` fileName = True
| "~" `isSuffixOf` fileName = True
| ".swp" `isSuffixOf` fileName = True
| otherwise = False
where
fileName = takeFileName path
shouldIgnoreFile :: HakyllConfiguration -> FilePath -> Bool
shouldIgnoreFile conf path =
destinationDirectory conf `isPrefixOf` path ||
storeDirectory conf `isPrefixOf` path ||
ignoreFile conf path