Browse Source

Set `title` in page `metadata` to remove permalink

pull/14125/head
Yurii Motov 10 months ago
parent
commit
fdf2879431
  1. 9
      scripts/mkdocs_hooks.py

9
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)
header = markdown.split("\n\n", 1)[0]
header_clean = header.split("{ #")[0]
if header_clean:
page.meta.setdefault("social", {})
page.meta["social"].setdefault("cards_layout_options", {})
page.meta["social"]["cards_layout_options"]["title"] = header_clean
if isinstance(page.file, EnFile):
for excluded_section in non_translated_sections:
if page.file.src_path.startswith(excluded_section):

Loading…
Cancel
Save