vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
12.89k stars 2.08k forks source link

LastupDateTime does not work correctly #4139

Closed ZtfCoder closed 2 months ago

ZtfCoder commented 2 months ago

Describe the bug

I compiled the product and pushed it to another repository through GitHub workflow. How can I make lastUpdating Time work correctly? Now, lastUpdating Time is always the latest time from another repository

Reproduction

no

Expected behavior

Correctly display lastUpdating Time

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 4.65 GB / 15.85 GB
  Binaries:
    Node: 18.20.3 - C:\Program Files\nodejs\node.EXE    
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD      
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD       
    pnpm: 8.10.0 - C:\Program Files\nodejs\pnpm.CMD
    bun: 1.1.21 - ~\.bun\bin\bun.EXE
  Browsers:
    Chrome: 127.0.6533.119
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    vitepress: ^1.3.1 => 1.3.1

Additional context

No response

Validations

ZtfCoder commented 2 months ago

https://github.com/ZtfCoder/blog ---use store https://github.com/ZtfCoder/ZtfCoder.github.io ---use view

ZhongxuYang commented 2 months ago

Same problem, I suspect it's caused by the behavior of some plugins/dependencies.

brc-dd commented 2 months ago

vitepress uses git timestamp for lastUpdated. If you're just copying and committing things from one repo to another, the last commit time of all the files will change.

ZtfCoder commented 2 months ago

How should I operate correctly

brc-dd commented 2 months ago

Ah, I just re-read your question. You just need to add fetch-depth: 0 to actions/checkout:

      - name: Checkout
        uses: actions/checkout@v4 
        with:
          persist-credentials: false
          fetch-depth: 0

https://github.com/ZtfCoder/blog/blob/master/.github/workflows/main.yml#L16

ZtfCoder commented 2 months ago

啊,我刚刚重新阅读了你的问题。您只需要添加到操作/结帐:fetch-depth: 0

      - name: Checkout
        uses: actions/checkout@v4 
        with:
          persist-credentials: false
          fetch-depth: 0

https://github.com/ZtfCoder/blog/blob/master/.github/workflows/main.yml#L16

Thank you, the last update time is now displayed correctly. Thank you very much!