diff --git a/src/Blog/Path.hs b/src/Blog/Path.hs index f8ed96f..bac98c3 100644 --- a/src/Blog/Path.hs +++ b/src/Blog/Path.hs @@ -12,6 +12,7 @@ import Data.Aeson (ToJSON(..), (.=), pairs) import Data.Monoid ((<>)) import Files (File(..), filePath) import GHC.Generics (Generic) +import System.Directory (doesDirectoryExist) data Path = Path { articlesPath :: FilePath @@ -28,10 +29,16 @@ instance ToJSON Path where <> "pagesPath" .= pagesPath ) +getPagesPath :: Maybe FilePath -> IO (Maybe FilePath) +getPagesPath Nothing = do + checkPagesPath <- doesDirectoryExist "pages" + return $ if checkPagesPath then Just "pages" else Nothing +getPagesPath (Just p) = Just <$> (filePath $ Dir p) + build :: FilePath -> Arguments -> IO Path build root arguments = do articlesPath <- filePath . Dir $ Arguments.articlesPath arguments - pagesPath <- mapM (filePath . Dir) $ Arguments.pagesPath arguments + pagesPath <- getPagesPath $ Arguments.pagesPath arguments remarkableConfig <- mapM (filePath . File) $ Arguments.remarkableConfig arguments return $ Path { articlesPath, commentsAt, pagesPath, remarkableConfig, root