diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Hakyll/File.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index 5f5e58b..c535b11 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -6,6 +6,7 @@ module Text.Hakyll.File , toURL , makeDirectories , getRecursiveContents + , havingExtension , isCacheValid , directory ) where @@ -47,6 +48,12 @@ getRecursiveContents topdir = do return (concat paths) where isProper = not . (== '.') . head +-- | A filter that takes all file names with a given extension. Prefix the +-- extension with a dot: +-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"] +havingExtension :: String -> [FilePath] -> [FilePath] +havingExtension extension = filter ((==) extension . takeExtension) + -- | Perform an IO action on every file in a given directory. directory :: (FilePath -> IO ()) -> FilePath -> IO () directory action dir = getRecursiveContents dir >>= mapM_ action |