sort gallery by date
This commit is contained in:
parent
aff4b7d89e
commit
0163e5f447
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
module GalleryPage (make) where
|
module GalleryPage (make) where
|
||||||
|
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
|
import Data.Function (on)
|
||||||
|
import Data.List (sortBy)
|
||||||
|
import Data.Ord (comparing)
|
||||||
import qualified Data.Text.Lazy as Lazy
|
import qualified Data.Text.Lazy as Lazy
|
||||||
import Data.Text.Lazy.Builder (Builder, toLazyText)
|
import Data.Text.Lazy.Builder (Builder, toLazyText)
|
||||||
import System.FilePath ((</>), takeDirectory)
|
import System.FilePath ((</>), takeDirectory)
|
||||||
|
@ -17,7 +20,7 @@ make :: Text -> [(FilePath, Info)] -> Lazy.Text
|
||||||
make title infos = toLazyText $ make' title infos
|
make title infos = toLazyText $ make' title infos
|
||||||
|
|
||||||
make' :: Text -> [(FilePath, Info)] -> Builder
|
make' :: Text -> [(FilePath, Info)] -> Builder
|
||||||
make' title infos = [b|@0
|
make' title infos' = [b|@0
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang=en>
|
<html lang=en>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
|
@ -37,6 +40,8 @@ make' title infos = [b|@0
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
items = map (uncurry makeItem) infos
|
items = map (uncurry makeItem) infos
|
||||||
|
infos = sortBy (cmpInfo `on` snd) infos'
|
||||||
|
cmpInfo = flip (comparing #date) <> comparing #title
|
||||||
|
|
||||||
makeItem :: FilePath -> Info -> Builder
|
makeItem :: FilePath -> Info -> Builder
|
||||||
makeItem file info = [b|@4
|
makeItem file info = [b|@4
|
||||||
|
|
Loading…
Reference in a new issue