sort gallery by date

This commit is contained in:
Rhiannon Morris 2020-07-17 16:01:04 +02:00
parent aff4b7d89e
commit 0163e5f447

View file

@ -1,6 +1,9 @@
module GalleryPage (make) where
import Control.Exception
import Data.Function (on)
import Data.List (sortBy)
import Data.Ord (comparing)
import qualified Data.Text.Lazy as Lazy
import Data.Text.Lazy.Builder (Builder, toLazyText)
import System.FilePath ((</>), takeDirectory)
@ -17,7 +20,7 @@ make :: Text -> [(FilePath, Info)] -> Lazy.Text
make title infos = toLazyText $ make' title infos
make' :: Text -> [(FilePath, Info)] -> Builder
make' title infos = [b|@0
make' title infos' = [b|@0
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
@ -37,6 +40,8 @@ make' title infos = [b|@0
|]
where
items = map (uncurry makeItem) infos
infos = sortBy (cmpInfo `on` snd) infos'
cmpInfo = flip (comparing #date) <> comparing #title
makeItem :: FilePath -> Info -> Builder
makeItem file info = [b|@4