@vuepress/plugin-last-updated
If you use the default theme, you don't need to install this plugin, because the plugin is already included in the of VuePress, and you should use the themeConfig.lastUpdated option directly.
Options
- Type:
(timestamp: number, lang: string) => string
- Default:
undefined
By default, this plugin produces a 13-bit timestamp for each page, you can also pass in a transformer to convert it to any format that you want.
const moment = require('moment');
module.exports = {
plugins: [
[
{
transformer: (timestamp, lang) => {
const moment = require('moment')
moment.locale(lang)
return moment(timestamp).fromNow()
}
]
}
TIP
Note that in VuePress, we follow this spec: W3C > Language tags in HTML and XML, so en-US
uses hyphens (-
) instead of underscores (_
). Please make sure that the library you are using follows this spec, otherwise please convert it yourself.