mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
parent
fe321a15c6
commit
98a17d5116
2 changed files with 29 additions and 5 deletions
|
@ -16,12 +16,27 @@ module.exports = function handler(blogApp) {
|
|||
return sitemap.getSiteMapXml(type, page);
|
||||
};
|
||||
|
||||
blogApp.get('/sitemap.xml', function sitemapXML(req, res) {
|
||||
blogApp.get('/sitemap.xml', function sitemapXML(req, res, next) {
|
||||
var siteMapXml = sitemap.getIndexXml();
|
||||
|
||||
res.set({
|
||||
'Cache-Control': 'public, max-age=' + utils.ONE_HOUR_S,
|
||||
'Content-Type': 'text/xml'
|
||||
});
|
||||
res.send(sitemap.getIndexXml());
|
||||
|
||||
// CASE: returns null if sitemap is not initialized as below
|
||||
if (!siteMapXml) {
|
||||
sitemap.init()
|
||||
.then(function () {
|
||||
siteMapXml = sitemap.getIndexXml();
|
||||
res.send(siteMapXml);
|
||||
})
|
||||
.catch(function (err) {
|
||||
next(err);
|
||||
});
|
||||
} else {
|
||||
res.send(siteMapXml);
|
||||
}
|
||||
});
|
||||
|
||||
blogApp.get('/sitemap-:resource.xml', verifyResourceType, function sitemapResourceXML(req, res, next) {
|
||||
|
|
|
@ -683,7 +683,10 @@ describe('Frontend Routing', function () {
|
|||
.expect(200)
|
||||
.expect('Cache-Control', testUtils.cacheRules.hour)
|
||||
.expect('Content-Type', 'text/xml; charset=utf-8')
|
||||
.end(doEnd(done));
|
||||
.end(function (err, res) {
|
||||
res.text.should.match(/sitemapindex/);
|
||||
doEnd(done)(err, res);
|
||||
});
|
||||
});
|
||||
|
||||
it('should serve sitemap-posts.xml', function (done) {
|
||||
|
@ -691,7 +694,10 @@ describe('Frontend Routing', function () {
|
|||
.expect(200)
|
||||
.expect('Cache-Control', testUtils.cacheRules.hour)
|
||||
.expect('Content-Type', 'text/xml; charset=utf-8')
|
||||
.end(doEnd(done));
|
||||
.end(function (err, res) {
|
||||
res.text.should.match(/urlset/);
|
||||
doEnd(done)(err, res);
|
||||
});
|
||||
});
|
||||
|
||||
it('should serve sitemap-pages.xml', function (done) {
|
||||
|
@ -699,7 +705,10 @@ describe('Frontend Routing', function () {
|
|||
.expect(200)
|
||||
.expect('Cache-Control', testUtils.cacheRules.hour)
|
||||
.expect('Content-Type', 'text/xml; charset=utf-8')
|
||||
.end(doEnd(done));
|
||||
.end(function (err, res) {
|
||||
res.text.should.match(/urlset/);
|
||||
doEnd(done)(err, res);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Other pages and verify content
|
||||
|
|
Loading…
Add table
Reference in a new issue