hablo/src/ArticlesList.hs

35 lines
786 B
Haskell
Raw Normal View History

{-# LANGUAGE NamedFieldPuns #-}
module ArticlesList (
ArticlesList(..)
, otherLink
, otherUrl
, pageTitle
) where
import Article (Article)
import System.FilePath.Posix ((</>))
data ArticlesList = ArticlesList {
tagged :: Maybe String
, full :: Bool
, featured :: [Article]
}
2019-02-06 12:57:57 +01:00
otherUrl :: ArticlesList -> String
otherUrl (ArticlesList {full, tagged}) =
if full
2019-02-06 12:57:57 +01:00
then url tagged
else url tagged </> "all.html"
where
url = maybe "/" ("/" </>)
2019-02-06 12:57:57 +01:00
otherLink :: ArticlesList -> String
otherLink (ArticlesList {full}) =
if full
then "See only latest"
else "See all"
2019-02-06 12:57:57 +01:00
pageTitle :: ArticlesList -> String
pageTitle (ArticlesList {full, tagged}) =
(if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) tagged