A replacement method for inaccurate date display in Mkdocs-material #7135
W1ndys
started this conversation in
Show and tell
Replies: 1 comment 6 replies
-
If there is room for optimization in my code or there are other better ways, please feel free to correct my mistakes. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Question background.
After a deployment to Vercel, the date display was found to be inaccurate.
I asked the community for help, details can be seen: #6924, finally found that Vercel does not support this operation, so after two weeks of testing, I found a replacement solution.
The specific idea is to add a text of time information at the bottom of each Markdown file, and use Python script + automated workflow to automatically update the date.
This scheme is suitable for:
deploy to material sites on the Vercel platform.
document repository uses GitHub.
the submission record of the document repository is synchronized with the content of the document
Solution
Reference repository: https://github.com/W1ndys/Easy-QFNU
Python script
GitHub Actions
Use GitHub Actions to automate deployment and execute scripts automatically every time push arrives at the repository, at a fixed time, and when triggered manually.
Note
The Python script is placed in the root directory of the Github repository and named
update-docs.py
(the name can be customized, but note that it also needs to be modified in the corresponding location of the workflow).You need to modify the variables in the Python script to define your repository owner and repository name, and the script will get API based on this.
Other notes:
I come from China, my English level is not very good, some of the above documents are obtained through translation software, if there are any description errors, please forgive me, and point out the corrections in time.
Acknowledgements
Mkdocs-material
Thanks to the developers of the framework
W1ndys
My code ability is not high, with the help of ChatGPT, completed the implementation of this script, which really cost me too much time and energy, I want to thank myself
ChatGPT
A powerful language model for text generation, which can be used to generate text based on the input text, which is very useful for this script.
Beta Was this translation helpful? Give feedback.
All reactions