mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Updated sitemaps to react to a partial resource update
refs https://github.com/TryGhost/Toolbox/issues/503 - The Dynamic URL service no longer generates "url.added" event when only a partial resource update happened - only non-url forming properties were modified. The sitemaps service still needs to know when to update the lastmod ("Last Modified") field associated with specific URL.
This commit is contained in:
parent
39ef1d20db
commit
714a6f6900
3 changed files with 19 additions and 0 deletions
|
@ -63,6 +63,12 @@ class BaseSiteMapGenerator {
|
||||||
return sitemapXml;
|
return sitemapXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateURL(datum) {
|
||||||
|
const url = this.nodeLookup[datum.id].url[0].loc;
|
||||||
|
this.removeUrl(url, datum);
|
||||||
|
this.addUrl(url, datum);
|
||||||
|
}
|
||||||
|
|
||||||
addUrl(url, datum) {
|
addUrl(url, datum) {
|
||||||
const node = this.createUrlNodeFromDatum(url, datum);
|
const node = this.createUrlNodeFromDatum(url, datum);
|
||||||
|
|
||||||
|
@ -100,6 +106,12 @@ class BaseSiteMapGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {String} url
|
||||||
|
* @param {Object} datum
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
createUrlNodeFromDatum(url, datum) {
|
createUrlNodeFromDatum(url, datum) {
|
||||||
let node;
|
let node;
|
||||||
let imgNode;
|
let imgNode;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const DomainEvents = require('@tryghost/domain-events');
|
||||||
|
const {URLResourceUpdatedEvent} = require('@tryghost/dynamic-routing-events');
|
||||||
const IndexMapGenerator = require('./index-generator');
|
const IndexMapGenerator = require('./index-generator');
|
||||||
const PagesMapGenerator = require('./page-generator');
|
const PagesMapGenerator = require('./page-generator');
|
||||||
const PostsMapGenerator = require('./post-generator');
|
const PostsMapGenerator = require('./post-generator');
|
||||||
|
@ -29,6 +31,10 @@ class SiteMapManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DomainEvents.subscribe(URLResourceUpdatedEvent, (event) => {
|
||||||
|
this[event.data.resourceType].updateURL(event.data);
|
||||||
|
});
|
||||||
|
|
||||||
events.on('url.added', (obj) => {
|
events.on('url.added', (obj) => {
|
||||||
this[obj.resource.config.type].addUrl(obj.url.absolute, obj.resource.data);
|
this[obj.resource.config.type].addUrl(obj.url.absolute, obj.resource.data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
"@tryghost/database-info": "0.3.14",
|
"@tryghost/database-info": "0.3.14",
|
||||||
"@tryghost/debug": "0.1.21",
|
"@tryghost/debug": "0.1.21",
|
||||||
"@tryghost/domain-events": "0.0.0",
|
"@tryghost/domain-events": "0.0.0",
|
||||||
|
"@tryghost/dynamic-routing-events": "0.0.0",
|
||||||
"@tryghost/email-analytics-provider-mailgun": "0.0.0",
|
"@tryghost/email-analytics-provider-mailgun": "0.0.0",
|
||||||
"@tryghost/email-analytics-service": "0.0.0",
|
"@tryghost/email-analytics-service": "0.0.0",
|
||||||
"@tryghost/email-content-generator": "0.0.0",
|
"@tryghost/email-content-generator": "0.0.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue