]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in...
authorMotov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Tue, 30 Sep 2025 04:06:57 +0000 (06:06 +0200)
committerGitHub <noreply@github.com>
Tue, 30 Sep 2025 04:06:57 +0000 (06:06 +0200)
.github/workflows/build-docs.yml
scripts/mkdocs_hooks.py

index 7de1590b182f58852e342b974d547b182ac2931a..a5761361d964b2fcff94c732e91d393f3a77f189 100644 (file)
@@ -40,6 +40,7 @@ jobs:
             - mkdocs.no-insiders.yml
             - .github/workflows/build-docs.yml
             - .github/workflows/deploy-docs.yml
+            - scripts/mkdocs_hooks.py
   langs:
     needs:
       - changes
index e4a49165c6479547e9af599b5fe3ee3ed4cf7ca4..b9e4ff59ed095db9e494a4a9ad940c86e1d61ac7 100644 (file)
@@ -132,6 +132,15 @@ def on_pre_page(page: Page, *, config: MkDocsConfig, files: Files) -> Page:
 def on_page_markdown(
     markdown: str, *, page: Page, config: MkDocsConfig, files: Files
 ) -> str:
+    # Set matadata["social"]["cards_layout_options"]["title"] to clean title (without
+    # permalink)
+    title = page.title
+    clean_title = title.split("{ #")[0]
+    if clean_title:
+        page.meta.setdefault("social", {})
+        page.meta["social"].setdefault("cards_layout_options", {})
+        page.meta["social"]["cards_layout_options"]["title"] = clean_title
+
     if isinstance(page.file, EnFile):
         for excluded_section in non_translated_sections:
             if page.file.src_path.startswith(excluded_section):