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
|
module Handler.Common where
|
||||||
|
|
||||||
import Data.FileEmbed (embedFile)
|
import Data.FileEmbed (embedFile)
|
||||||
|
import Database.Esqueleto ( (^.) )
|
||||||
|
import qualified Database.Esqueleto as E
|
||||||
import Yesod.Sitemap
|
import Yesod.Sitemap
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
@ -31,6 +33,9 @@ getRobotsR = robots SitemapR
|
||||||
|
|
||||||
getSitemapR :: Handler TypedContent
|
getSitemapR :: Handler TypedContent
|
||||||
getSitemapR = do
|
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]
|
entries <- runDB $ selectList [] [Desc EntryPublished]
|
||||||
sitemap $ do
|
sitemap $ do
|
||||||
yield SitemapUrl
|
yield SitemapUrl
|
||||||
|
@ -39,20 +44,19 @@ getSitemapR = do
|
||||||
, sitemapChangeFreq = Just Daily
|
, sitemapChangeFreq = Just Daily
|
||||||
, sitemapPriority = Nothing
|
, sitemapPriority = Nothing
|
||||||
}
|
}
|
||||||
yieldMany $ kindToSitemapUrl <$> allEntryKinds
|
yieldMany $ sitemapUrl . CategoryR . E.unValue <$> categories
|
||||||
|
yieldMany $ sitemapUrl . EntriesR <$> allEntryKinds
|
||||||
yieldMany $ entryToSitemapUrl <$> entries
|
yieldMany $ entryToSitemapUrl <$> entries
|
||||||
|
|
||||||
kindToSitemapUrl :: EntryKind -> SitemapUrl (Route App)
|
sitemapUrl :: a -> SitemapUrl a
|
||||||
kindToSitemapUrl kind = SitemapUrl
|
sitemapUrl loc = SitemapUrl
|
||||||
{ sitemapLoc = EntriesR kind
|
{ sitemapLoc = loc
|
||||||
, sitemapLastMod = Nothing
|
, sitemapLastMod = Nothing
|
||||||
, sitemapChangeFreq = Nothing
|
, sitemapChangeFreq = Nothing
|
||||||
, sitemapPriority = Nothing
|
, sitemapPriority = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
entryToSitemapUrl :: Entity Entry -> SitemapUrl (Route App)
|
entryToSitemapUrl :: Entity Entry -> SitemapUrl (Route App)
|
||||||
entryToSitemapUrl entry = SitemapUrl
|
entryToSitemapUrl entry = (sitemapUrl $ entryR entry)
|
||||||
{ sitemapLoc = entryR entry
|
{ sitemapLastMod = Just . entryUpdated . entityVal $ entry
|
||||||
, sitemapLastMod = Just . entryUpdated . entityVal $ entry
|
|
||||||
, sitemapChangeFreq = Nothing
|
|
||||||
, sitemapPriority = Nothing
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue