# @vuepress/plugin-last-updated (opens new window)

last-updated plugin for VuePress

If you use the default theme, you don't need to install this plugin, because the plugin is already included in the core of VuePress, and you should use the themeConfig.lastUpdated option directly.

If you use it at your custom theme, you'll need to handle the UI by yourself, and you can use $page.lastUpdated to access the date string.

# Usage

module.exports = {
  plugins: ['@vuepress/last-updated']
}

# Options

# transformer

  • 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.

e.g.

const moment = require('moment');

module.exports = {
  plugins: [
    [
      '@vuepress/last-updated',
      {
        transformer: (timestamp, lang) => {
          // Don't forget to install moment yourself
          const moment = require('moment')
          moment.locale(lang)
          return moment(timestamp).fromNow()
        }
      }
    ]
  ]
}

TIP

If you are running in i18n mode, you can also use the second argument lang to generate time strings for different languages.

Note that in VuePress, we follow this spec: W3C > Language tags in HTML and XML (opens new window), 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.

# dateOptions

  • Type: object
  • Default: undefined

You can also pass in an options object to customize the timestamp output. For more properties check Date.prototype.toLocaleString() (opens new window) options argument


module.exports = {
  plugins: [
    [
      '@vuepress/last-updated',
      {
        dateOptions:{
          hour12: false
        }
      }
    ]
  ]
}