Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The updatedAt field of all the contents are changed on deployment. #913

Closed
TunNandaAung opened this issue Jun 27, 2021 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@TunNandaAung
Copy link

TunNandaAung commented Jun 27, 2021

When deploying a static site to netlify or vercel, the updatedAt field of all the contents are changed to the deployment time.
You can see in this example nuxt blog repository that the repo was last update on Jan 7 and the updatedAt field of the contents on the website are Jan 7 as well. This behavior also happens on latest version (v1.14.0).

Steps to reproduce

  • Clone this repository.
  • Deploy it on netlify or vercel.
@TunNandaAung TunNandaAung added the bug Something isn't working label Jun 27, 2021
@JoseeWouters
Copy link

I noticed the same for the createdAt date, which caused my pagination to go from 1 to 3 to 2. And in my RSS feed happened the same, (generating the feed with the Nuxt Feed module.

@LukaHarambasic
Copy link

I also was confused about this, but for me, it makes sense as during the build steps the files are copied/moved/recreated at the servers of netlify/vercel. To fix this, I added the attribute publishedAt and set the date manually.

@mrleblanc101
Copy link

I seem to have the same issue using GitHub Pages (with Github Actions).
Am I missing something ? Why doesn't it use the Git timestamp instead of the operating system created_at ?

With nuxt dev, the one with the missing image is last.
Capture d’écran, le 2022-07-11 à 01 31 57
On GitHub Pages, the one with a missing image is in the middle:
Capture d’écran, le 2022-07-11 à 01 31 58

With nuxt dev
file 1: "createdAt": "2022-06-23T03:57:36.719Z"
file 2: "createdAt": "2022-06-23T04:17:49.584Z"
file 3: "createdAt": "2022-07-11T01:15:46.009Z"

On GitHub Pages:
file 1: "createdAt": "2022-07-11T05:20:28.319Z"
file 2: "createdAt": "2022-07-11T05:20:28.319Z"
file 3: "createdAt": "2022-07-11T05:20:28.319Z"

Here is my GitHub Action workflow it it helps, maybe I did something wrong:

name: ci

on:
    push:
        branches:
            - main
            - master
    pull_request:
        branches:
            - main
            - master

jobs:
    ci:
        runs-on: ${{ matrix.os }}

        strategy:
            matrix:
                os: [ubuntu-latest]
                node: [14]

        steps:
            - name: Checkout 🛎
              uses: actions/checkout@master

            - name: Setup node env 🏗
              uses: actions/setup-node@v2.1.5
              with:
                  node-version: ${{ matrix.node }}
                  check-latest: true

            - name: Cache node_modules 📦
              uses: actions/cache@v2.1.4
              with:
                  path: ~/.npm
                  key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
                  restore-keys: |
                      ${{ runner.os }}-node-

            - name: Install dependencies 👨🏻‍💻
              run: npm ci --prefer-offline --no-audit

            - name: Build Static
              run: npm run generate

            - name: Deploy
              uses: peaceiris/actions-gh-pages@v3
              with:
                  github_token: ${{ secrets.GITHUB_TOKEN }}
                  publish_dir: ./dist

@alexauvray
Copy link

Install the module with npm install nuxt-content-git and add it to your nuxt.config.js like this:

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

Note that it is important to add it before @nuxt/content, so @nuxt/content knows about the hooks that our helper module installs.

Ref : https://sebastianlandwehr.com/blog/nuxt-content-how-to-keep-createdat-and-updatedat-valid-after-cloning/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants