Put category listings back into the sitemap.xml
This commit is contained in:
parent
1364a2e36b
commit
a880e66c31
1 changed files with 13 additions and 9 deletions
|
@ -7,6 +7,8 @@
|
|||
module Handler.Common where
|
||||
|
||||
import Data.FileEmbed (embedFile)
|
||||
import Database.Esqueleto ( (^.) )
|
||||
import qualified Database.Esqueleto as E
|
||||
import Yesod.Sitemap
|
||||
|
||||
import Import
|
||||
|
@ -31,6 +33,9 @@ getRobotsR = robots SitemapR
|
|||
|
||||
getSitemapR :: Handler TypedContent
|
||||
getSitemapR = do
|
||||
categories <- runDB . E.select . E.distinct . E.from $ \ec -> do
|
||||
E.orderBy [E.asc $ ec ^. EntryCategoryCategory]
|
||||
return $ ec ^. EntryCategoryCategory
|
||||
entries <- runDB $ selectList [] [Desc EntryPublished]
|
||||
sitemap $ do
|
||||
yield SitemapUrl
|
||||
|
@ -39,20 +44,19 @@ getSitemapR = do
|
|||
, sitemapChangeFreq = Just Daily
|
||||
, sitemapPriority = Nothing
|
||||
}
|
||||
yieldMany $ kindToSitemapUrl <$> allEntryKinds
|
||||
yieldMany $ sitemapUrl . CategoryR . E.unValue <$> categories
|
||||
yieldMany $ sitemapUrl . EntriesR <$> allEntryKinds
|
||||
yieldMany $ entryToSitemapUrl <$> entries
|
||||
|
||||
kindToSitemapUrl :: EntryKind -> SitemapUrl (Route App)
|
||||
kindToSitemapUrl kind = SitemapUrl
|
||||
{ sitemapLoc = EntriesR kind
|
||||
sitemapUrl :: a -> SitemapUrl a
|
||||
sitemapUrl loc = SitemapUrl
|
||||
{ sitemapLoc = loc
|
||||
, sitemapLastMod = Nothing
|
||||
, sitemapChangeFreq = Nothing
|
||||
, sitemapPriority = Nothing
|
||||
}
|
||||
|
||||
entryToSitemapUrl :: Entity Entry -> SitemapUrl (Route App)
|
||||
entryToSitemapUrl entry = SitemapUrl
|
||||
{ sitemapLoc = entryR entry
|
||||
, sitemapLastMod = Just . entryUpdated . entityVal $ entry
|
||||
, sitemapChangeFreq = Nothing
|
||||
, sitemapPriority = Nothing
|
||||
entryToSitemapUrl entry = (sitemapUrl $ entryR entry)
|
||||
{ sitemapLastMod = Just . entryUpdated . entityVal $ entry
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue