diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-02-10 15:08:26 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-02-10 15:08:26 +0100 |
commit | 1075096df7268111b2de83f0c52af15921be4ca4 (patch) | |
tree | 4f184bd754a83c65fe6437cce420e609384b04e5 /src | |
parent | 3532d5f1001c9942f815a1d9411f51a2051a1f96 (diff) | |
download | hakyll-1075096df7268111b2de83f0c52af15921be4ca4.tar.gz |
Add sortByBaseName function for pages
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Web/Page.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs index c7de026..549badc 100644 --- a/src/Hakyll/Web/Page.hs +++ b/src/Hakyll/Web/Page.hs @@ -10,6 +10,7 @@ module Hakyll.Web.Page , toMap , pageRead , addDefaultFields + , sortByBaseName ) where import Prelude hiding (id) @@ -19,6 +20,8 @@ import System.FilePath (takeBaseName, takeDirectory) import Data.Monoid (Monoid, mempty) import Data.Map (Map) import qualified Data.Map as M +import Data.List (sortBy) +import Data.Ord (comparing) import Hakyll.Core.Identifier import Hakyll.Core.Compiler @@ -71,3 +74,10 @@ addDefaultFields = (getRoute &&& id >>^ uncurry addRoute) . setField "path" p where p = toFilePath i + +-- | Sort posts based on the basename of the post. This is equivalent to a +-- chronologival sort, because of the @year-month-day-title.extension@ naming +-- convention in Hakyll. +-- +sortByBaseName :: [Page a] -> [Page a] +sortByBaseName = sortBy $ comparing $ takeBaseName . getField "path" |