{-# LANGUAGE OverloadedStrings #-} module MdBlocks.Repository where import Data.Text.IO as T import System.Directory import MdBlocks.Parser import MdBlocks.Types loadBlocks :: FilePath -> IO [Block] loadBlocks fp = do txt <- T.readFile fp pure (parseFile fp txt) findMarkdownFiles :: FilePath -> IO [FilePath] findMarkdownFiles root = do xs <- listDirectory root pure [ root <> "/" <> x | x <- xs , takeExtension x == ".md" ] where takeExtension = reverse . takeWhile (/='.') . reverse