summaryrefslogtreecommitdiff
path: root/site.hs
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-10-27 09:41:03 +0800
committerrekado <rekado@elephly.net>2013-10-27 09:41:03 +0800
commitd898dc56d389a1ca7165c982599a0e594eb86539 (patch)
tree4d7a96389498bf38b9e89ee33b1c8c410c733cae /site.hs
parentc66dc2f0db2137874ecab6a4f41b902dc738d6ea (diff)
handle tags
Diffstat (limited to 'site.hs')
-rw-r--r--site.hs17
1 files changed, 17 insertions, 0 deletions
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 &ldquo;" ++ tag ++ "&rdquo;"
+
+ 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