on master help sign in
Added a sortByBaseName function.
c49cc9aJasper Van der Jeugt
src/Text/Hakyll/File.hs+8−1
@@ -8,6 +8,7 @@ module Text.Hakyll.File
8 , removeSpaces
8 , removeSpaces
9 , makeDirectories
9 , makeDirectories
10 , getRecursiveContents
10 , getRecursiveContents
11+ , sortByBaseName
11 , havingExtension
12 , havingExtension
12 , isMoreRecent
13 , isMoreRecent
13 , directory
14 , directory
@@ -16,7 +17,7 @@ module Text.Hakyll.File
16import System.Directory
17import System.Directory
17import System.FilePath
18import System.FilePath
18import Control.Monad
19import Control.Monad
19−import Data.List (isPrefixOf)
20+import Data.List (isPrefixOf, sortBy)
20import Control.Monad.Reader (liftIO)
21import Control.Monad.Reader (liftIO)
21
22
22import Text.Hakyll.Hakyll
23import Text.Hakyll.Hakyll
@@ -100,6 +101,12 @@ getRecursiveContents topdir = do
100 where
101 where
101 isProper = not . (== '.') . head
102 isProper = not . (== '.') . head
102
103
104+-- | Sort a list of filenames on the basename.
105+sortByBaseName :: [FilePath] -> [FilePath]
106+sortByBaseName = sortBy compareBaseName
107+ where
108+ compareBaseName f1 f2 = compare (takeFileName f1) (takeFileName f2)
109+
103-- | A filter that takes all file names with a given extension. Prefix the
110-- | A filter that takes all file names with a given extension. Prefix the
104-- extension with a dot:
111-- extension with a dot:
105--
112--