0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Removed duplicate calls to moment()

- the return type of `getLastModifiedForDatum` is a moment object, and
  we're just wrapping it again in another moment call
- moment is very heavy so we shouldn't do it unnecessarily
- this makes boot time 1% quicker of heavy sites
This commit is contained in:
Daniel Lockyer 2024-10-08 17:12:41 +01:00 committed by Daniel Lockyer
parent f798955bc9
commit b49210f4dd

View file

@ -95,6 +95,9 @@ class BaseSiteMapGenerator {
this.lastModified = Date.now();
}
/**
* @returns {moment.Moment}
*/
getLastModifiedForDatum(datum) {
if (datum.updated_at || datum.published_at || datum.created_at) {
const modifiedDate = datum.updated_at || datum.published_at || datum.created_at;
@ -126,7 +129,7 @@ class BaseSiteMapGenerator {
node = {
url: [
{loc: url},
{lastmod: moment(this.getLastModifiedForDatum(datum)).toISOString()}
{lastmod: this.getLastModifiedForDatum(datum).toISOString()}
]
};