35 lines
786 B
Haskell
35 lines
786 B
Haskell
{-# 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]
|
|
}
|
|
|
|
otherUrl :: ArticlesList -> String
|
|
otherUrl (ArticlesList {full, tagged}) =
|
|
if full
|
|
then url tagged
|
|
else url tagged </> "all.html"
|
|
where
|
|
url = maybe "/" ("/" </>)
|
|
|
|
otherLink :: ArticlesList -> String
|
|
otherLink (ArticlesList {full}) =
|
|
if full
|
|
then "See only latest"
|
|
else "See all"
|
|
|
|
pageTitle :: ArticlesList -> String
|
|
pageTitle (ArticlesList {full, tagged}) =
|
|
(if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) tagged
|