From 8c8dfef58a8e3f960c63a7da816c7ab034bfea30 Mon Sep 17 00:00:00 2001 From: MDLeom <2809763-curben@users.noreply.gitlab.com> Date: Wed, 1 Jul 2020 08:27:26 +0100 Subject: [PATCH] refactor(sitemap): de-duplicate date formatting --- themes/chameleon/scripts/sitemap/generator.js | 7 ------- themes/chameleon/scripts/sitemap/template.js | 1 - 2 files changed, 8 deletions(-) diff --git a/themes/chameleon/scripts/sitemap/generator.js b/themes/chameleon/scripts/sitemap/generator.js index bb23f5d..a0b113a 100644 --- a/themes/chameleon/scripts/sitemap/generator.js +++ b/themes/chameleon/scripts/sitemap/generator.js @@ -2,7 +2,6 @@ const micromatch = require('micromatch') const template = require('./template') -const moment = require('moment') const isMatch = (path, patterns) => { if (patterns && patterns.length) { @@ -31,12 +30,6 @@ module.exports = function (locals) { .sort((a, b) => { return b.date - a.date }) - // https://github.com/pyyzcwg2833/hexo-generator-sitemap/commit/a92dbbb83cc39ff60d43faa5cd688a56574a3889 - .map((post) => ({ - ...post, - date: moment(post.date).format('YYYY-MM-DD[T00:00:00.000Z]'), - updated: post.updated ? moment(post.updated).format('YYYY-MM-DD[T00:00:00.000Z]') : false - })) // configuration dictionary const xmlConfig = { diff --git a/themes/chameleon/scripts/sitemap/template.js b/themes/chameleon/scripts/sitemap/template.js index 25a1370..213f39c 100644 --- a/themes/chameleon/scripts/sitemap/template.js +++ b/themes/chameleon/scripts/sitemap/template.js @@ -15,7 +15,6 @@ module.exports = function (config) { }) env.addFilter('formatDate', str => { - if (typeof str === 'string') return str.substring(0, 10) return moment(str).format('YYYY-MM-DD[T00:00:00.000Z]').substring(0, 10) })