Skip to content

Commit bae8169

Browse files
hayeslanabobalis
andauthored
Adding avatars as defult (#277)
Co-authored-by: Nabil Freij <[email protected]>
1 parent 5c72681 commit bae8169

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
"--remove-unused-variable",
2020
]
2121
- repo: https://github.com/PyCQA/docformatter
22-
rev: v1.7.5
22+
rev: master
2323
hooks:
2424
- id: docformatter
2525
args: ["--make-summary-multi-line", "--pre-summary-newline", "-ri"]

docs/cards.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Cards
1818
Stuart Mumford is the Python developer for the Daniel K. Inouye Solar Telescope Data Centre. He obtained a PhD in Numerical solar physics from Sheffield University in 2016, prior to his PhD he obtained a first class MPhys degree in Physics with Planetary and Space Physics from The University of Wales Aberystwyth, during which he spent 5 months studying at UNIS on Svalbard in the high arctic.
1919

2020
.. custom-card:: Stuart Mumford and Sons
21-
:img_name: _static/img/Stuart-Mumford.png
2221
:github: cadair
2322
:title: Lead Lead Lead Lead Lead Lead Developer
2423
:aff_name: Sheffield University

src/sunpy_sphinx_theme/cards.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ def visit_card_node(self, node) -> None:
2222
key = key.lower().replace(" ", "-")
2323
title = f"<h4>{title}</h4>" if len(title) > 0 else ""
2424
col_extra_class = "column-half" if title else ""
25+
img_src = node.get("img_name")
26+
# If there is no "img_name" given, we fallback to using the github avatar
27+
# if a user handle is provided. If so, the image provided is actually the sunpy icon
28+
if img_src == "sunpy_icon.svg" and node.get("github") is not None:
29+
img_src = f"https://github.com/{node['github']}.png"
2530
body = f"""<div class="column {col_extra_class}">
2631
{title}
2732
<div class="card">
28-
<img class="dark-light" src="{node['img_name']}" alt="{node['name']}">
33+
<img class="dark-light" src="{img_src}" alt="{node['name']}">
2934
<p>{node['name']}</p>
3035
<p><button type="button" class="btn btn-sunpy btn-sunpy1 stretched-link" data-bs-toggle="modal" data-bs-target="#{key}">More Info</button></p>
3136
<div class="modal fade" id="{key}" tabindex=-1>

0 commit comments

Comments
 (0)