Closed maxacarvalho closed 4 years ago
can you give us the output of the page.lastUpdated
it self or have you a repo for us to reproduce the issue?
Thanks.
I think it caused by using @vuepress/last-updated
which you change the page.lastUpdated.
Such as:
[
'@vuepress/last-updated',
{
transformer: (timestamp, lang) => {
const moment = require('moment')
moment.locale(lang)
return moment(timestamp).fromNow()
}
}
]
Hi, first of all I beg your pardon because of the lack of update about this issue, I was dealing with a different project for the past few months and couldn't check the issue.
I found that it, probably, has to do with localisation. Since I require to use en-GB
as default language, the default output of the last-updated
plugin will be something like 18/02/2019, 09:54:26
which will then throw the RangeError: Invalid time value
exception when trying to new Date(page.lastUpdated).toISOString() // new Date(18/02/2019, 09:54:26).toISOString()
I added a fix like:
plugins: [
[
'@vuepress/last-updated',
{
transformer: (timestamp, lang) => {
const moment = require('moment')
moment.locale(lang)
return moment(timestamp).format("MMMM DD YYYY HH:mm")
}
}
],
['sitemap', { hostname: 'https://path-to-docs' }]
],
This issue could be solved with the localisation proposal, maybe using moment
as a dependency.
it fixed with dateFormatter
option in v2.3.0
"vuepress-plugin-sitemap": "^2.3.1",
bug still alive.
The following code is work too~
transformer: (timestamp, lang) => {
return new Date(timestamp).toLocaleDateString();
}
This works for me.
[
'sitemap',
{
hostname: 'xxx',
+ dateFormatter: lastUpdated => {
+ return new Date(lastUpdated.replace(/[上|下]午/g, '')).toISOString()
+ },
},
],
Hello,
Apparently, there's an issue related to the
page.lastUpdated
data.At
index.js:54
It throws an error like:
I'm using Vuepress version 1.x (
"vuepress": "^1.0.0-alpha.47"
)Thanks.