mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛Fixed sitemap duplicates after routes.yaml upload (#9957)
closes #9956 - sitemap reset was missing
This commit is contained in:
parent
f55a9ad412
commit
d699daeb35
4 changed files with 17 additions and 1 deletions
|
@ -154,6 +154,11 @@ class BaseSiteMapGenerator {
|
|||
delete this.nodeLookup[datum.id];
|
||||
delete this.nodeTimeLookup[datum.id];
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.nodeLookup = {};
|
||||
this.nodeTimeLookup = {};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BaseSiteMapGenerator;
|
||||
|
|
|
@ -32,6 +32,13 @@ class SiteMapManager {
|
|||
common.events.on('url.removed', (obj) => {
|
||||
this[obj.resource.config.type].removeUrl(obj.url.absolute, obj.resource.data);
|
||||
});
|
||||
|
||||
common.events.on('routers.reset', () => {
|
||||
this.pages && this.pages.reset();
|
||||
this.posts && this.posts.reset();
|
||||
this.users && this.users.reset();
|
||||
this.tags && this.tags.reset();
|
||||
});
|
||||
}
|
||||
|
||||
createIndexGenerator() {
|
||||
|
|
3
core/server/services/routing/bootstrap.js
vendored
3
core/server/services/routing/bootstrap.js
vendored
|
@ -1,5 +1,6 @@
|
|||
const debug = require('ghost-ignition').debug('services:routing:bootstrap');
|
||||
const _ = require('lodash');
|
||||
const common = require('../../lib/common');
|
||||
const settingsService = require('../settings');
|
||||
const StaticRoutesRouter = require('./StaticRoutesRouter');
|
||||
const StaticPagesRouter = require('./StaticPagesRouter');
|
||||
|
@ -17,6 +18,8 @@ module.exports.init = (options = {start: false}) => {
|
|||
registry.resetAllRouters();
|
||||
registry.resetAllRoutes();
|
||||
|
||||
common.events.emit('routers.reset');
|
||||
|
||||
siteRouter = new ParentRouter('SiteRouter');
|
||||
registry.setRouter('siteRouter', siteRouter);
|
||||
|
||||
|
|
|
@ -62,10 +62,11 @@ describe('Unit: sitemap/manager', function () {
|
|||
|
||||
it('can create a SiteMapManager instance', function () {
|
||||
should.exist(manager);
|
||||
Object.keys(eventsToRemember).length.should.eql(3);
|
||||
Object.keys(eventsToRemember).length.should.eql(4);
|
||||
should.exist(eventsToRemember['url.added']);
|
||||
should.exist(eventsToRemember['url.removed']);
|
||||
should.exist(eventsToRemember['router.created']);
|
||||
should.exist(eventsToRemember['routers.reset']);
|
||||
});
|
||||
|
||||
describe('trigger url events', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue