Add ``last updated`` for document (#11164)

## Summary

![image](https://github.com/user-attachments/assets/75431f9f-debe-435d-a02e-d216be7a3a01)

![image](https://github.com/user-attachments/assets/2d1b895e-4878-410e-90ff-ff8e932cbf24)
Display the last document update time, excluding any automatically
generated parts of the document, while ensuring that Google can
accurately read and recognize the webpage's time.

Note that I do not have permission to update
``requirements-insiders.txt``


Google time info
*
https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for
*
https://developers.google.com/search/docs/appearance/structured-data/article#amp

Similar https://github.com/astral-sh/uv/pull/11162
Closes #11148
## Test Plan
uvx --with-requirements docs/requirements.txt -- mkdocs serve -f
mkdocs.public.yml --strict

![image](https://github.com/user-attachments/assets/6e8cd609-2e60-489c-97cc-fb28aa3204e0)
The correct format is actually ``2024-08-08T22:01:08Z``, but Google
Search happens to be lenient and accepts this format.

![image](https://github.com/user-attachments/assets/2ec8ce98-49ea-403b-bbd2-3d0d5630a562)
This commit is contained in:
FishAlchemist 2025-02-04 11:28:47 +08:00 committed by GitHub
parent 73e9928d40
commit 49b85d2e65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
ref: ${{ inputs.ref }} ref: ${{ inputs.ref }}
fetch-depth: 0
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:

View File

@ -21,6 +21,10 @@
<meta name="robots" content="index,follow"/> <meta name="robots" content="index,follow"/>
<script type="application/ld+json"> <script type="application/ld+json">
{ {
{% if page and page.meta.git_revision_date_localized_raw_iso_datetime %}
"datePublished": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
"dateModified": "{{ page.meta.git_revision_date_localized_raw_iso_datetime }}Z",
{% endif %}
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "WebSite", "@type": "WebSite",
"name": "Astral Docs", "name": "Astral Docs",

View File

@ -6,3 +6,4 @@ mdformat>=0.7.17
mdformat-mkdocs>=2.0.4 mdformat-mkdocs>=2.0.4
mdformat-admon>=2.0.2 mdformat-admon>=2.0.2
mkdocs-redirects>=1.2.2 mkdocs-redirects>=1.2.2
mkdocs-git-revision-date-localized-plugin>=1.3.0

View File

@ -1,7 +1,9 @@
# This file was autogenerated by uv via the following command: # This file was autogenerated by uv via the following command:
# uv pip compile docs/requirements.in -o docs/requirements.txt --universal -p 3.12 # uv pip compile docs/requirements.in -o docs/requirements.txt --universal -p 3.12
babel==2.15.0 babel==2.15.0
# via mkdocs-material # via
# mkdocs-git-revision-date-localized-plugin
# mkdocs-material
black==24.4.2 black==24.4.2
# via -r docs/requirements.in # via -r docs/requirements.in
certifi==2024.7.4 certifi==2024.7.4
@ -19,6 +21,10 @@ colorama==0.4.6
# mkdocs-material # mkdocs-material
ghp-import==2.1.0 ghp-import==2.1.0
# via mkdocs # via mkdocs
gitdb==4.0.12
# via gitpython
gitpython==3.1.44
# via mkdocs-git-revision-date-localized-plugin
idna==3.7 idna==3.7
# via requests # via requests
jinja2==3.1.4 jinja2==3.1.4
@ -72,10 +78,13 @@ mergedeep==1.3.4
mkdocs==1.6.0 mkdocs==1.6.0
# via # via
# -r docs/requirements.in # -r docs/requirements.in
# mkdocs-git-revision-date-localized-plugin
# mkdocs-material # mkdocs-material
# mkdocs-redirects # mkdocs-redirects
mkdocs-get-deps==0.2.0 mkdocs-get-deps==0.2.0
# via mkdocs # via mkdocs
mkdocs-git-revision-date-localized-plugin==1.3.0
# via -r docs/requirements.in
mkdocs-material==9.5.29 mkdocs-material==9.5.29
# via -r docs/requirements.in # via -r docs/requirements.in
mkdocs-material-extensions==1.3.1 mkdocs-material-extensions==1.3.1
@ -106,6 +115,8 @@ pymdown-extensions==10.8.1
# via mkdocs-material # via mkdocs-material
python-dateutil==2.9.0.post0 python-dateutil==2.9.0.post0
# via ghp-import # via ghp-import
pytz==2025.1
# via mkdocs-git-revision-date-localized-plugin
pyyaml==6.0.1 pyyaml==6.0.1
# via # via
# mkdocs # mkdocs
@ -120,6 +131,8 @@ requests==2.32.3
# via mkdocs-material # via mkdocs-material
six==1.16.0 six==1.16.0
# via python-dateutil # via python-dateutil
smmap==5.0.2
# via gitdb
uc-micro-py==1.0.3 uc-micro-py==1.0.3
# via linkify-it-py # via linkify-it-py
urllib3==2.2.2 urllib3==2.2.2

View File

@ -2,6 +2,8 @@ INHERIT: mkdocs.template.yml
# Omit the `typeset` plugin which is only available in the Insiders version. # Omit the `typeset` plugin which is only available in the Insiders version.
plugins: plugins:
- search - search
- git-revision-date-localized:
timezone: UTC # It can only be in UTC unless the ISO time can include timezone.
validation: validation:
anchors: warn anchors: warn
watch: watch: