diff --git a/src/ArticlesList.hs b/src/ArticlesList.hs new file mode 100644 index 0000000..d260640 --- /dev/null +++ b/src/ArticlesList.hs @@ -0,0 +1,44 @@ +{-# 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" +-} diff --git a/src/Dom.hs b/src/Dom.hs index dfc996a..b05bbfb 100644 --- a/src/Dom.hs +++ b/src/Dom.hs @@ -17,7 +17,7 @@ import System.FilePath.Posix ((), (<.>)) type HtmlGenerator = HtmlT (ReaderT Blog IO) class Page a where - content :: Monad m => a -> HtmlT m () + content :: a -> HtmlGenerator () instance Page Article where content (Article {fullContents, urlPath}) =