gallery/make-pages/IndexPage.hs

40 lines
713 B
Haskell
Raw Normal View History

2020-07-16 10:29:32 -04:00
module IndexPage (make) where
import qualified Data.Text.Lazy as Lazy
import Data.Text.Lazy.Builder (Builder, toLazyText)
import BuilderQQ
import Info
make :: [GalleryInfo] -> Lazy.Text
make ginfos = toLazyText $ make' ginfos
make' :: [GalleryInfo] -> Builder
make' ginfos = [b|@0
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<title>gallery list</title>
<header>
<h1>gallery list</h1>
</header>
<main>
<ul class=gallery-list>
$4.items
</ul>
</main>
|]
where
items = map makeItem ginfos
makeItem :: GalleryInfo -> Builder
makeItem (GalleryInfo {title, prefix}) = [b|@4
<li>
<a href="$@prefix">
$*title
</a>
|]