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

This commit is contained in:
Tissevert 2019-02-01 13:51:59 +01:00
parent 375ea0f7b0
commit 62055a6a54
1 changed files with 7 additions and 7 deletions

View File

@ -21,15 +21,15 @@ import System.Posix.Files (modificationTime)
data Page = Page { data Page = Page {
category :: Maybe String category :: Maybe String
, full :: Bool , full :: Bool
, urlPath :: FilePath , filePath :: FilePath
, articlesFeatured :: [Article] , articlesFeatured :: [Article]
} }
previewArticle :: Article -> Html () previewArticle :: Article -> Html ()
previewArticle article = previewArticle (Article {urlPath}) =
article_ (do article_ (do
h1_ "Some Article" h1_ $ a_ [href_ urlPath] "Some Article"
pre_ . toHtml $ filePath article pre_ $ toHtml urlPath
) )
showTag :: String -> Html () showTag :: String -> Html ()
@ -66,19 +66,19 @@ generateCollection (category, path, articlesFeatured) = do
blog <- ask blog <- ask
liftIO $ createDirectoryIfMissing False path liftIO $ createDirectoryIfMissing False path
forM_ (pages $ previewCount blog) $ \page -> forM_ (pages $ previewCount blog) $ \page ->
liftIO $ renderToFile (urlPath page) (render page blog) liftIO $ renderToFile (filePath page) (render page blog)
where where
pages articlesCount = [ pages articlesCount = [
Page { Page {
category category
, full = True , full = True
, urlPath = path </> "all.html" , filePath = path </> "all.html"
, articlesFeatured , articlesFeatured
} }
, Page { , Page {
category category
, full = False , full = False
, urlPath = path </> "index.html" , filePath = path </> "index.html"
, articlesFeatured = take articlesCount articlesFeatured , articlesFeatured = take articlesCount articlesFeatured
} }
] ]