Docusaurus: Last updated on time / author is always same for every page?

Created on 23 May 2020  Â·  10Comments  Â·  Source: facebook/docusaurus

📚 Documentation

enableUpdateTime option enables _Last updated on DD/MM/YYYY_ feature. However this value is same for every page. I guess this was working fine in version 1 _(it's broken when we started using github actions tho..)_ But it's not working as expected in v2. Is this bug or limitation?
image

related: https://github.com/facebook/docusaurus/issues/1015

Have you read the Contributing Guidelines on issues?

yes

documentation

All 10 comments

Any live repro example? If you're talking about versioned pages that's
expected.

On Sat, May 23, 2020, 9:54 AM Jason-2020 notifications@github.com wrote:

📚 Documentation

enableUpdateTime option enables Last updated on DD/MM/YYYY feature.
However this value is same for every page. I guess this was working fine in
version 1 (it's broken when we started using github actions tho..) But
it's not working as expected in v2. Is this bug or limitation?
[image: image]
https://user-images.githubusercontent.com/58852063/82719167-e1177280-9c6d-11ea-8c92-7b2a88e8ddd6.png

related: #1015 https://github.com/facebook/docusaurus/issues/1015
Have you read the Contributing Guidelines on issues
https://github.com/facebook/docusaurus/blob/master/CONTRIBUTING.md#reporting-new-issues
?

yes

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/docusaurus/issues/2798, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAKBCHMZNH5EZNYOV7IW74LRS4UG7ANCNFSM4NIHI7AQ
.

If you're looking at the pages under https://v2.docusaurus.io/docs/, it's pointing to the latest released/stable version of the docs, and that's created when a new documentation version is cut, which was few days ago when we released alpha.55. If you see the trunk version of the docs under docs/next/ (e.g. https://v2.docusaurus.io/docs/next/using-plugins), you'll see that the author is different.

Closing this out as it's not a bug.

Hi @yangshun

If you're looking at the pages under https://v2.docusaurus.io/docs/, it's pointing to the latest released/stable version of the docs, and that's created when a new documentation version is cut, which was few days ago when we released alpha.55. If you see the trunk version of the docs under docs/next/ (e.g. https://v2.docusaurus.io/docs/next/using-plugins), you'll see that the author is different.

Thanks for the explanation. In our case we don't use versioned pages.
Please take a look at our documentation website. Here is the repo.
What would be the reason in our case? How can we fix it?

pinging 1 more time @yangshun

The last updated date look at Git history of a file, so I suspect it could be the environment of your build step. When you clone the repo on your deployment environment do you happen to be doing just a shallow clone? A preferably long history is needed for this to work well.

We're using github actions to deploy to github pages directly. Here is our workflow file.

Main part is:

- name: Publish
      if: github.event_name == 'push'
      run: |
        cd docs
        git config --global user.email "[email protected]"
        git config --global user.name "$DOC_USERNAME"
        echo "machine github.com login $DOC_USERNAME password $DOC_TOKEN" > ~/.netrc
        GIT_USER=$DOC_USERNAME CURRENT_BRANCH=develop yarn deploy

The last updated date look at Git history of a file, so I suspect it could be the environment of your build step. When you clone the repo on your deployment environment do you happen to be doing just a shallow clone? A preferably long history is needed for this to work well.

Hmm, we noticed this was broken when we moved from Gitlab-Ci to Github actions. I guess there must be something with Github actions then.

Could you try creating a custom build on your local machine and see if the timestamps work properly? If so then it's something with GitHub actions environment. Please let us know :)

I confirmed that showLastUpdateAuthor and showLastUpdateTime feature is working as expected on local builds. I guess I'll tune github checkout actions' settings then. Thank you :)

Solution: Fetch all of your github history in your checkout action. By default it fetches only last commit.

steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

Thanks @Jason-2020

Do you think we should include this in our GH pages deployment doc?

(it seems we are still on actions/checkout@v1, might be good to update the CI config a bit)

I'm not very familiar with Github CI but would merge a PR to improve/update this part of the doc

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoelMarcey picture JoelMarcey  Â·  3Comments

azu picture azu  Â·  3Comments

ericnakagawa picture ericnakagawa  Â·  3Comments

muuvmuuv picture muuvmuuv  Â·  3Comments

cheercroaker picture cheercroaker  Â·  3Comments