Open ahopkins opened 3 years ago
Funny, I also got the same error but with fr
lang.
The seo plugin is based on $page.lastUpdated
(added by @vuepress/plugin-last-updated) that can be a localized date:
And when the seo plugin encounters a date that can't be parsed through new Date()
, it fails.
Ideally, it would be great to have a new key $page.lastUpdatedTimestamp
with the timestamp
value. This way, the seo plugin could easily use it without any issue.
Opened https://github.com/vuejs/vuepress/pull/2843, hoping this will help.
As a workaround, you can do this:
@vuepress/theme-default
to always returns a timestamp:
// .vuepress/theme/index.js
module.exports = {
extend: '@vuepress/theme-default',
plugins: [
['@vuepress/last-updated', {
transformer(timestamp) {
return timestamp;
}
}],
'seo',
],
// ...
}
Create a new file theme/components/PageEdit.vue
, which will extends the original component but override lastUpdate
computed:
<template>
<footer class="page-edit">
<div
v-if="editLink"
class="edit-link"
>
<a
:href="editLink"
target="_blank"
rel="noopener noreferrer"
>{{ editLinkText }}</a>
<OutboundLink />
</div>
<div
v-if="lastUpdated"
class="last-updated"
>
<span class="prefix">{{ lastUpdatedText }}:</span>
<time class="time">{{ lastUpdated }}</time>
</div>
</footer>
</template>
This way, you don't have any issues anymore from the seo plugin, and the `last updated` date is still formatted correctly:
- with an english page (`en-US`):
![image](https://user-images.githubusercontent.com/2103975/117198156-f044f100-ade8-11eb-81b8-71ee68aed374.png)
- with a french page (`fr`) :
![image](https://user-images.githubusercontent.com/2103975/117198171-f76bff00-ade8-11eb-852f-c8a94419c8da.png)
Also affects es
, es-ES
and es-CL
.
To fix this you can add the following property in your themeConfig
:
themeConfig.sitemap.dateFormatter: (time) => new Date(time).toLocaleString("es-CL")
See here: https://github.com/sanic-org/sanic-guide/runs/2158958551?check_suite_focus=true
It seems like I am running into build issues, and I think this is related to the locale. I am build fine locally, but our CI and other contributors in China seem to be getting this error.
Any thoughts?