mirror of https://github.com/tiangolo/fastapi.git
🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in social cards) (#14125)
This commit is contained in:
parent
333f1ba737
commit
06367347e6
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue