mirror of https://gitlab.com/curben/blog
refactor(sitemap): de-duplicate date formatting
This commit is contained in:
parent
c0c8c846d1
commit
8c8dfef58a
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
const micromatch = require('micromatch')
|
const micromatch = require('micromatch')
|
||||||
const template = require('./template')
|
const template = require('./template')
|
||||||
const moment = require('moment')
|
|
||||||
|
|
||||||
const isMatch = (path, patterns) => {
|
const isMatch = (path, patterns) => {
|
||||||
if (patterns && patterns.length) {
|
if (patterns && patterns.length) {
|
||||||
|
@ -31,12 +30,6 @@ module.exports = function (locals) {
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return b.date - a.date
|
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
|
// configuration dictionary
|
||||||
const xmlConfig = {
|
const xmlConfig = {
|
||||||
|
|
|
@ -15,7 +15,6 @@ module.exports = function (config) {
|
||||||
})
|
})
|
||||||
|
|
||||||
env.addFilter('formatDate', str => {
|
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)
|
return moment(str).format('YYYY-MM-DD[T00:00:00.000Z]').substring(0, 10)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue