Skip to content

Commit 7b5cedd

Browse files
committed
BUG: do not add icon links if theme_options[icon_links] is None
1 parent 6345c7d commit 7b5cedd

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/pydata_sphinx_theme/__init__.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ def update_config(app):
4040
)
4141

4242
# Validate icon links
43-
if not isinstance(theme_options.get("icon_links", []), list):
44-
raise ExtensionError(
45-
"`icon_links` must be a list of dictionaries, you provided "
46-
f"type {type(theme_options.get('icon_links'))}."
47-
)
43+
if theme_options.get("icon_links") is not None:
44+
if not isinstance(theme_options.get("icon_links", []), list):
45+
raise ExtensionError(
46+
"`icon_links` must be a list of dictionaries, you provided "
47+
f"type {type(theme_options.get('icon_links'))}."
48+
)
4849

4950
# Set the anchor link default to be # if the user hasn't provided their own
5051
if not utils.config_provided_by_user(app, "html_permalinks_icon"):
@@ -140,18 +141,19 @@ def update_config(app):
140141
# Add extra icon links entries if there were shortcuts present
141142
# TODO: Deprecate this at some point in the future?
142143
icon_links = theme_options.get("icon_links", [])
143-
for url, icon, name in shortcuts:
144-
if theme_options.get(url):
145-
# This defaults to an empty list so we can always insert
146-
icon_links.insert(
147-
0,
148-
{
149-
"url": theme_options.get(url),
150-
"icon": icon,
151-
"name": name,
152-
"type": "fontawesome",
153-
},
154-
)
144+
if icon_links is not None:
145+
for url, icon, name in shortcuts:
146+
if theme_options.get(url):
147+
# This defaults to an empty list so we can always insert
148+
icon_links.insert(
149+
0,
150+
{
151+
"url": theme_options.get(url),
152+
"icon": icon,
153+
"name": name,
154+
"type": "fontawesome",
155+
},
156+
)
155157
theme_options["icon_links"] = icon_links
156158

157159
# Prepare the logo config dictionary

0 commit comments

Comments
 (0)