From d898dc56d389a1ca7165c982599a0e594eb86539 Mon Sep 17 00:00:00 2001 From: rekado Date: Sun, 27 Oct 2013 09:41:03 +0800 Subject: handle tags --- site.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/site.hs b/site.hs index a259816..e822518 100644 --- a/site.hs +++ b/site.hs @@ -25,6 +25,8 @@ myFeedConfiguration = FeedConfiguration -------------------------------------------------------------------------------- main :: IO () main = hakyllWith config $ do + tags <- buildTags "posts/*.markdown" (fromCapture "tags/*.html") + match "css/*" $ do route idRoute compile compressCssCompiler @@ -98,6 +100,21 @@ main = hakyllWith config $ do mostRecent <- fmap head . recentFirst =<< loadAllSnapshots "posts/*.markdown" "non-relative" makeItem (itemBody mostRecent) >>= relativizeUrls + + tagsRules tags $ \tag pattern -> do + let title = "Posts tagged “" ++ tag ++ "”" + + route idRoute + compile $ do + let ctx = constField "title" title `mappend` + field "posts" (\_ -> postList pattern recentFirst) `mappend` + defaultContext + + makeItem "" + >>= loadAndApplyTemplate "templates/archive.html" ctx + >>= loadAndApplyTemplate "templates/default.html" ctx + >>= relativizeUrls + match "templates/*" $ compile templateCompiler -- cgit v1.2.3