hablo/src/Blog/Path.hs

30 lines
880 B
Haskell

{-# LANGUAGE NamedFieldPuns #-}
module Blog.Path (
Path(..)
, build
) where
import Arguments (Arguments)
import qualified Arguments as Arguments (Arguments(..))
import Files (File(..), absolute, filePath)
data Path = Path {
articlesPath :: FilePath
, commentsAt :: Maybe String
, pagesPath :: Maybe FilePath
, remarkableConfig :: Maybe FilePath
, root :: FilePath
}
build :: Arguments -> IO Path
build arguments = do
articlesPath <- filePath . Dir $ Arguments.articlesPath arguments
pagesPath <- mapM (filePath . Dir) $ Arguments.pagesPath arguments
remarkableConfig <- mapM (filePath . File) $ Arguments.remarkableConfig arguments
root <- absolute . Dir $ Arguments.sourceDir arguments
return $ Path {
articlesPath, commentsAt, pagesPath, remarkableConfig, root
}
where
commentsAt = Arguments.commentsAt arguments