45 lines
1.1 KiB
Haskell
45 lines
1.1 KiB
Haskell
{-# LANGUAGE NamedFieldPuns #-}
|
|
module ArticlesList (
|
|
ArticlesList(..)
|
|
, otherLink
|
|
, otherUrl
|
|
, pageTitle
|
|
) where
|
|
|
|
import Article (Article)
|
|
import Data.Text (Text, pack)
|
|
import System.FilePath.Posix ((</>))
|
|
|
|
data ArticlesList = ArticlesList {
|
|
tagged :: Maybe String
|
|
, full :: Bool
|
|
, featured :: [Article]
|
|
}
|
|
|
|
otherUrl :: ArticlesList -> Text
|
|
otherUrl (ArticlesList {full, tagged}) =
|
|
if full
|
|
then pack $ url tagged
|
|
else pack $ url tagged </> "all.html"
|
|
where
|
|
url = maybe "/" ("/" </>)
|
|
|
|
otherLink :: ArticlesList -> Text
|
|
otherLink (ArticlesList {full}) = pack $
|
|
if full
|
|
then "See only latest"
|
|
else "See all"
|
|
|
|
pageTitle :: ArticlesList -> Text
|
|
pageTitle (ArticlesList {full, tagged}) = pack $
|
|
(if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) tagged
|
|
|
|
{-
|
|
pageTitle =
|
|
(if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) category
|
|
|
|
p_ $ if full
|
|
then a_ [href_ . pack $ url category] "See only latest"
|
|
else a_ [href_ . pack $ url category </> "all.html"] "See all"
|
|
-}
|