From 329be8ae4775b65b0ff05d5b9d775755f7228a98 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Sat, 23 May 2026 19:24:59 +1200 Subject: [PATCH] Show official ORCID iD icon next to ORCID links Add the official ORCID iD SVG (green roundel from ORCID's brand guidelines, https://info.orcid.org/brand-guidelines/) at assets/orcid-id.svg and update the authors hook to render it next to ORCID identifiers wherever they appear. Hook changes (.config/hooks/authors.py): - New _orcid_markdown(orcid, asset_prefix) helper renders [![ORCID iD icon]({prefix}assets/orcid-id.svg) ](https://orcid.org/) so mkdocs rewrites the relative asset path correctly for both source roots. - _render_author_page uses asset_prefix="../" since author pages are generated under authors/.md. - _render_pattern_bullets uses asset_prefix="" since pattern pages live at the docs root. The SVG declares intrinsic width/height of 16px so the icon renders at a sensible inline size without requiring attr_list or extra CSS. Verified with `mkdocs build --strict`: clean build, icon copied to /assets/orcid-id.svg in the site output, rendered HTML on both author pages and pattern-page chips contains the expected ORCID iD icon inside the ORCID anchor. --- .config/hooks/authors.py | 17 ++++++++++++++--- assets/orcid-id.svg | 9 +++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 assets/orcid-id.svg diff --git a/.config/hooks/authors.py b/.config/hooks/authors.py index caea62d..8049a06 100644 --- a/.config/hooks/authors.py +++ b/.config/hooks/authors.py @@ -20,6 +20,7 @@ from mkdocs.structure.files import File AUTHORS_FILE = "authors.yml" +ORCID_ICON = "assets/orcid-id.svg" CONTRIB_HEADING_RE = re.compile( r"^##\s+Contributors\s*&\s*Acknowledg\w*\s*$", re.MULTILINE, @@ -28,6 +29,16 @@ HEADING_RE = re.compile(r"^#+\s", re.MULTILINE) +def _orcid_markdown(orcid: str, asset_prefix: str) -> str: + """Render an ORCID iD with the official icon, wrapped in a link. + + ``asset_prefix`` is "" for source pages at the docs root and "../" for + generated pages under ``authors/``. + """ + icon = f"![ORCID iD icon]({asset_prefix}{ORCID_ICON})" + return f"[{icon} {orcid}](https://orcid.org/{orcid})" + + def _load_authors(docs_dir: str) -> dict: path = Path(docs_dir) / AUTHORS_FILE if not path.exists(): @@ -101,7 +112,7 @@ def _render_authors_index( name = record.get("name", slug) aff = record.get("affiliation") or "" orcid = record.get("orcid") - orcid_cell = f"[{orcid}](https://orcid.org/{orcid})" if orcid else "" + orcid_cell = _orcid_markdown(orcid, "../") if orcid else "" lines.append(f"| [{name}](#{slug}) | {aff} | {orcid_cell} |") for slug, record in sorted_authors: @@ -112,7 +123,7 @@ def _render_authors_index( if aff: lines += [f"**Affiliation:** {aff}", ""] if orcid: - lines += [f"**ORCID:** [{orcid}](https://orcid.org/{orcid})", ""] + lines += [f"**ORCID:** {_orcid_markdown(orcid, '../')}", ""] lines += ["**Patterns:**", ""] patterns = by_author.get(slug, []) if patterns: @@ -136,7 +147,7 @@ def _render_pattern_bullets(slugs: list[str], authors_map: dict) -> str: if aff: extras.append(aff) if orcid: - extras.append(f"[ORCID](https://orcid.org/{orcid})") + extras.append(_orcid_markdown(orcid, "")) if extras: line += " — " + ", ".join(extras) bullets.append(line) diff --git a/assets/orcid-id.svg b/assets/orcid-id.svg new file mode 100644 index 0000000..332bda0 --- /dev/null +++ b/assets/orcid-id.svg @@ -0,0 +1,9 @@ + + + + +