Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
site map, #138
Browse files Browse the repository at this point in the history
  • Loading branch information
giggio committed Oct 26, 2013
1 parent 17db729 commit 0a27655
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
29 changes: 29 additions & 0 deletions app/routes/home.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,32 @@ module.exports = class HomeRoutes
(req, res) ->
filePath = path.join publicDir, file
res.sendfile filePath

sitemap: ->
sm = require 'sitemap'
map =
hostname: 'https://www.atelies.com.br/',
cacheTime: 12 * 60 * 60 * 1000 # twice a day, in miliseconds
urls: [
{ url: '', changefreq: 'always', priority: 0.6 }
{ url: 'faq', changefreq: 'monthly', priority: 0.1 }
{ url: "about", changefreq: 'monthly', priority: 0.1 }
{ url: "terms", changefreq: 'monthly', priority: 0.1 }
{ url: "faq", changefreq: 'monthly', priority: 0.1 }
{ url: "technology", changefreq: 'monthly', priority: 0.1 }
{ url: "iWantToBuy", changefreq: 'monthly', priority: 0.1 }
{ url: "iWantToSell", changefreq: 'monthly', priority: 0.1 }
{ url: "contribute", changefreq: 'monthly', priority: 0.1 }
{ url: "donating", changefreq: 'monthly', priority: 0.1 }
]
Store.find().select('slug').exec (err, stores) ->
unless err?
map.urls.push { url: store.slug, changefreq: 'weekly', priority: 0.7 } for store in stores
Product.find().select('slug storeSlug').exec (err, products) ->
unless err?
map.urls.push { url: product.url(), changefreq: 'weekly', priority: 0.7 } for product in products
sitemap = sm.createSitemap map
(req, res) ->
sitemap.toXML (xml) ->
res.header 'Content-Type', 'application/xml'
res.send xml
1 change: 1 addition & 0 deletions app/routes/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports.route = (app) ->
app.post "/api/error", home.errorCreate
app.get "/humans.txt", home.staticFile 'humans.txt'
app.get "/robots.txt", home.staticFile 'robots.txt'
app.get "/sitemap.xml", home.sitemap()
#home client routes
app.get "/searchProducts/:searchTerm?", home.index domain
app.get "/searchStores/:searchTerm?", home.index domain
Expand Down
8 changes: 6 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"gm": "~1.13.3",
"marked": "~0.2.9",
"grunt-wait": "~0.1.0",
"prerender-node": "~0.1.3"
"prerender-node": "~0.1.3",
"sitemap": "~0.7.0"
},
"devDependencies": {
"grunt-coffeelint": "0.0.x",
Expand Down

0 comments on commit 0a27655

Please sign in to comment.