Files
libretro/scripts/mkdocs_hooks.py
T
Abdessamad Derraz bd75defb61 fix: date sitemap entries from their pages
The sitemap gave every page the build date. A page now states its own date
and a mkdocs hook passes it on, or leaves lastmod out. The values added to
the site's code spans today are also escaped: a backtick in a profile or
file name could close the span and inject markup.
2026-10-18 10:08:18 +02:00

18 lines
647 B
Python

"""MkDocs hooks for the generated site.
The sitemap gave all 664 pages the build date as lastmod, so the field told
a crawler nothing. A page whose content carries its own date (an emulator
page: the day its profile was last read against the source) states it in
its front matter; the rest get no lastmod rather than an inexact one.
"""
from __future__ import annotations
from typing import Any
def on_page_markdown(markdown: str, page: Any, config: Any, files: Any) -> str: # noqa: ARG001
"""Take lastmod from the page's own date, or leave it out."""
page.update_date = str(page.meta.get("date_modified") or "")
return markdown