Browse Source
🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in social cards) (#14125)
pull/14129/head
Motov Yurii
5 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
10 additions and
0 deletions
-
.github/workflows/build-docs.yml
-
scripts/mkdocs_hooks.py
|
|
@ -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): |
|
|
|