Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

How to Keep CreatedAt and UpdatedAt after Deploy in NuxtJS

If you using git, createdAt and updatedAt data for your content using @nuxt/content module will be always reset to deployment date in your live server.

If you using git, createdAt and updatedAt data for your content using @nuxt/content module will be always reset to deployment date in your live server.

This is because git does not file metadata.

We can use git history based on your commit date.

Install nuxt-content-git package from npm

nuxt-content-git is additional module for @nuxt/content that replaces or adds createdAt and updatedAt dates based on the git history.

npm install nuxt-content-git --save

Configure nuxt-content-git in nuxt.config.js

Add nuxt-content-git to modules before @nuxt/content in your nuxt.config.js file.

export default {
  // ...
  modules: [
      'nuxt-content-git',
      '@nuxt/content',
    ],
  // ...
}

Finish

Lets deploy and check createdAt and updatedAt date for your content.

Leave a Reply

Your email address will not be published. Required fields are marked *