From 9d0d6ba249ed710b17cf4c00ab66be879179b973 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Sat, 14 Oct 2017 15:12:50 +1100 Subject: [PATCH] Add category pages to the sitemap --- src/Handler/Common.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Handler/Common.hs b/src/Handler/Common.hs index 31f62a6..a69eb82 100644 --- a/src/Handler/Common.hs +++ b/src/Handler/Common.hs @@ -31,6 +31,7 @@ getRobotsR = robots SitemapR getSitemapR :: Handler TypedContent getSitemapR = do + categories <- runDB $ selectList [] [Asc CategoryTag] entries <- runDB $ selectList [] [Desc EntryPublished] sitemap $ do yield SitemapUrl @@ -39,9 +40,18 @@ getSitemapR = do , sitemapChangeFreq = Just Daily , sitemapPriority = Nothing } + yieldMany $ categoryToSitemapUrl <$> categories yieldMany $ kindToSitemapUrl <$> allEntryKinds yieldMany $ entryToSitemapUrl <$> entries +categoryToSitemapUrl :: Entity Category -> SitemapUrl (Route App) +categoryToSitemapUrl (Entity catId cat) = SitemapUrl + { sitemapLoc = CategoryR $ categoryTag cat + , sitemapLastMod = Nothing + , sitemapChangeFreq = Nothing + , sitemapPriority = Nothing + } + kindToSitemapUrl :: EntryKind -> SitemapUrl (Route App) kindToSitemapUrl kind = SitemapUrl { sitemapLoc = EntriesR kind