diff options
author | rekado <rekado@elephly.net> | 2013-10-27 09:41:03 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-10-27 09:41:03 +0800 |
commit | d898dc56d389a1ca7165c982599a0e594eb86539 (patch) | |
tree | 4d7a96389498bf38b9e89ee33b1c8c410c733cae /site.hs | |
parent | c66dc2f0db2137874ecab6a4f41b902dc738d6ea (diff) |
handle tags
Diffstat (limited to 'site.hs')
-rw-r--r-- | site.hs | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |