From: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> Date: Tue, 30 Sep 2025 04:06:57 +0000 (+0200) Subject: 🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06367347e6da987db8e6806792d04b8aad8662e0;p=thirdparty%2Ffastapi%2Ffastapi.git 🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in social cards) (#14125) --- diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 7de1590b1..a5761361d 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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 diff --git a/scripts/mkdocs_hooks.py b/scripts/mkdocs_hooks.py index e4a49165c..b9e4ff59e 100644 --- a/scripts/mkdocs_hooks.py +++ b/scripts/mkdocs_hooks.py @@ -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):