Add support for generating an XML sitemap
This commit is contained in:
parent
1c5939d863
commit
8c3a562c7d
4 changed files with 16 additions and 3 deletions
|
@ -4,5 +4,6 @@
|
|||
/favicon.ico FaviconR GET
|
||||
/keybase.txt KeybaseR GET
|
||||
/robots.txt RobotsR GET
|
||||
/sitemap.xml SitemapR GET
|
||||
|
||||
/ HomeR GET
|
||||
|
|
|
@ -47,6 +47,7 @@ dependencies:
|
|||
- case-insensitive
|
||||
- wai
|
||||
- libravatar >=0.4 && <0.5
|
||||
- yesod-sitemap >=1.4 && <1.5
|
||||
|
||||
# The library contains all of our application code. The executable
|
||||
# defined below is just a thin wrapper.
|
||||
|
|
|
@ -128,6 +128,7 @@ instance Yesod App where
|
|||
isAuthorized FaviconR _ = return Authorized
|
||||
isAuthorized KeybaseR _ = return Authorized
|
||||
isAuthorized RobotsR _ = return Authorized
|
||||
isAuthorized SitemapR _ = return Authorized
|
||||
isAuthorized (StaticR _) _ = return Authorized
|
||||
|
||||
-- This function creates static content files in the static folder
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
module Handler.Common where
|
||||
|
||||
import Data.FileEmbed (embedFile)
|
||||
import Yesod.Sitemap
|
||||
|
||||
import Import
|
||||
|
||||
-- These handlers embed files in the executable at compile time to avoid a
|
||||
|
@ -21,6 +23,14 @@ getKeybaseR :: Handler TypedContent
|
|||
getKeybaseR = return $ TypedContent typePlain
|
||||
$ toContent $(embedFile "config/keybase.txt")
|
||||
|
||||
getRobotsR :: Handler TypedContent
|
||||
getRobotsR = return $ TypedContent typePlain
|
||||
$ toContent $(embedFile "config/robots.txt")
|
||||
getRobotsR :: Handler Text
|
||||
getRobotsR = robots SitemapR
|
||||
|
||||
getSitemapR :: Handler TypedContent
|
||||
getSitemapR = sitemap $ do
|
||||
yield SitemapUrl
|
||||
{ sitemapLoc = HomeR
|
||||
, sitemapLastMod = Nothing
|
||||
, sitemapChangeFreq = Just Daily
|
||||
, sitemapPriority = Nothing
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue