From 62055a6a54b60de9dda06d920c5233bf80acb9f6 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Fri, 1 Feb 2019 13:51:59 +0100 Subject: [PATCH] Use previous to generate links for articles and rename variable urlPath to filePath since it's actually the path of the file that's gonna be generated --- src/Dom.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Dom.hs b/src/Dom.hs index 1e543b2..be787fb 100644 --- a/src/Dom.hs +++ b/src/Dom.hs @@ -21,15 +21,15 @@ import System.Posix.Files (modificationTime) data Page = Page { category :: Maybe String , full :: Bool - , urlPath :: FilePath + , filePath :: FilePath , articlesFeatured :: [Article] } previewArticle :: Article -> Html () -previewArticle article = +previewArticle (Article {urlPath}) = article_ (do - h1_ "Some Article" - pre_ . toHtml $ filePath article + h1_ $ a_ [href_ urlPath] "Some Article" + pre_ $ toHtml urlPath ) showTag :: String -> Html () @@ -66,19 +66,19 @@ generateCollection (category, path, articlesFeatured) = do blog <- ask liftIO $ createDirectoryIfMissing False path forM_ (pages $ previewCount blog) $ \page -> - liftIO $ renderToFile (urlPath page) (render page blog) + liftIO $ renderToFile (filePath page) (render page blog) where pages articlesCount = [ Page { category , full = True - , urlPath = path "all.html" + , filePath = path "all.html" , articlesFeatured } , Page { category , full = False - , urlPath = path "index.html" + , filePath = path "index.html" , articlesFeatured = take articlesCount articlesFeatured } ]