about uscontact

How to Keep CreatedAt and UpdatedAt after Deploy in NuxtJS

Category:
Author: zemna
Date: April 24, 2021
Share this:

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.

Share this:

Leave a Reply

Your email address will not be published.

ZEMNA.NET

Professional software development agency estalished in Indonesia. We offers website setup, web application development, fulfillment service, and etc.
Follow us
Follow us to get latest news and tutorials.
2022 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
magnifiercrossmenu