From ff552f44b1ef0d7fbeb8c1611fa6c8de8564e262 Mon Sep 17 00:00:00 2001 From: Rostyslav Hnatyshyn Date: Mon, 23 Sep 2024 22:48:38 -0700 Subject: [PATCH] sorted articles by date --- site.hs | 19 +++++++++---------- templates/post-list.html | 2 +- templates/pub-list.html | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/site.hs b/site.hs index 97199d5..9fb106c 100644 --- a/site.hs +++ b/site.hs @@ -31,18 +31,10 @@ main = hakyllWith config $ do route idRoute compile compressCssCompiler - match ("posts/*" .||. "publications/*") $ do - route $ setExtension "html" - compile $ - pandocCompiler - >>= loadAndApplyTemplate "templates/post.html" postCtx - >>= loadAndApplyTemplate "templates/default.html" postCtx - >>= relativizeUrls - match "index.html" $ do route idRoute compile $ do - posts <- loadAll "posts/*" + posts <- recentFirst =<< loadAll "posts/*" pubs <- recentFirst =<< loadAll "publications/*" let indexCtx = listField "publications" postCtx (return pubs) <> listField "posts" postCtx (return posts) `mappend` defaultContext @@ -52,6 +44,13 @@ main = hakyllWith config $ do >>= loadAndApplyTemplate "templates/default.html" indexCtx >>= relativizeUrls + match ("posts/*" .||. "publications/*") $ do + route $ setExtension "html" + compile $ + pandocCompiler + >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= relativizeUrls + match "gallery.html" $ do route idRoute compile $ do @@ -73,4 +72,4 @@ main = hakyllWith config $ do -------------------------------------------------------------------------------- postCtx :: Context String -postCtx = modificationTimeField "modded" "%B %e, %Y" `mappend` defaultContext +postCtx = mconcat [modificationTimeField "modded" "%B %e, %Y", dateField "parsed-date" "%B %e, %Y", defaultContext] diff --git a/templates/post-list.html b/templates/post-list.html index 9ddd043..d1ed07c 100644 --- a/templates/post-list.html +++ b/templates/post-list.html @@ -2,7 +2,7 @@ $if(posts)$ $for(posts)$
  • - $title$ - $modded$ + $title$ - $parsed-date$
  • $endfor$ $endif$ diff --git a/templates/pub-list.html b/templates/pub-list.html index 79de7f4..ace967b 100644 --- a/templates/pub-list.html +++ b/templates/pub-list.html @@ -2,7 +2,7 @@ $if(publications)$ $for(publications)$
  • - $title$ - $published$ + $title$ - $parsed-date$
  • $endfor$ $endif$