39 lines
1.1 KiB
Haskell
39 lines
1.1 KiB
Haskell
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
module ArticlesList (
|
|
ArticlesList(..)
|
|
, otherUrl
|
|
, pageTitle
|
|
) where
|
|
|
|
import Article (Article)
|
|
import Blog (Blog(..), get)
|
|
import Blog.Wording (render)
|
|
import Control.Monad.Reader (MonadReader)
|
|
import Data.Text (Text, pack)
|
|
import Files (absoluteLink)
|
|
import System.FilePath.Posix ((</>))
|
|
|
|
data ArticlesList = ArticlesList {
|
|
tagged :: Maybe String
|
|
, full :: Bool
|
|
, featured :: [Article]
|
|
}
|
|
|
|
otherUrl :: ArticlesList -> String
|
|
otherUrl (ArticlesList {full, tagged}) = absoluteLink $
|
|
(if full then id else (</> "all.html")) $ maybe "" id tagged
|
|
|
|
pageTitle :: (MonadReader Blog m) => ArticlesList -> m Text
|
|
pageTitle (ArticlesList {full, tagged}) = title (full, tagged) <$> Blog.get wording
|
|
where
|
|
title (True, Nothing) = render "allPage" []
|
|
title (True, Just tag) = render "allTaggedPage" [("tag", pack tag)]
|
|
title (False, Nothing) = render "latestPage" []
|
|
title (False, Just tag) = render "latestTaggedPage" [("tag", pack tag)]
|
|
|
|
|
|
|
|
|