Skip to content

Commit

Permalink
Assorted fixes (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair authored Sep 7, 2023
1 parent 479f242 commit a6c5dbb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/sunpy_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ def update_config(app):
# To do this, you must manually modify `app.builder.theme_options`.
theme_options = utils.get_theme_options_dict(app)

if not theme_options.get("sst_site_root"):
theme_options["sst_site_root"] = "https://sunpy.org"
if theme_options.get("sst_logo"):
if not isinstance(theme_options["sst_logo"], dict):
sst_logo = str(theme_options["sst_logo"])
theme_options["sst_logo"] = {"light": sst_logo, "dark": sst_logo}

if not theme_options.get("sst_is_root"):
theme_options["sst_is_root"] = False
theme_options["sst_is_root"] = bool(theme_options.get("sst_is_root", False))

if not theme_options.get("navbar_links"):
theme_options["navbar_links"] = default_navbar()

if not theme_options.get("footer_links"):
if theme_options.get("footer_links", False) != []:
theme_options["footer_links"] = [
("Code", "https://github.com/sunpy", 3),
("Forum", "https://community.openastronomy.org/c/sunpy", 3),
Expand Down
17 changes: 13 additions & 4 deletions src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<a class="navbar-brand" href="{{ sst_pathto('.', 2) }}">
{%- block sidebarlogo %}
{%- if logo %}<span><img src="{{ pathto('_static/' + logo, 1) }}"></span>{%- endif %}
{%- endblock %}
SunPy
{% if theme_sst_logo %}
{# Theme switching is only available when JavaScript is enabled.
# Thus we should add the extra image using JavaScript, defaulting
# depending on the value of default_mode; and light if unset.
#}
{% if default_mode is undefined or default_mode == "auto" %}
{% set default_mode = "light" %}
{% endif %}
{% set js_mode = "light" if default_mode == "dark" else "dark" %}
<img src="{{ pathto('_static/' + theme_sst_logo[default_mode], 1) }}" class="logo__image only-{{ default_mode }}" alt="{{ alt }}"/>
<script>document.write(`<img src="{{ pathto('_static/' + theme_sst_logo[js_mode], 1) }}" class="logo__image only-{{ js_mode }}" alt="{{ theme_sst_logo.get('alt', '') }}"/>`);</script>
{% endif %}
{{ theme_sst_project_name }}
</a>
2 changes: 1 addition & 1 deletion src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ html {
}

html[data-theme="light"] {
--pst-color-primary: var(--sst-darker-gray);
--pst-color-primary: var(--sst-darker-color);
--pst-color-secondary: var(--sst-accent-color-muted);
--pst-color-link: var(--sst-accent-color-muted);
--sst-footer-background-color: var(--sst-lightest-color);
Expand Down
6 changes: 5 additions & 1 deletion src/sunpy_sphinx_theme/theme/sunpy/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ footer_end = components/built-with.html
# sunpy-sphinx-theme config
footer_center = components/footer-links.html
# This config sets the base URL for top navbar items when sst_is_root is False
sst_site_root = "https://sunpy.org"
sst_site_root = https://sunpy.org
# If true then the site that's being built is the site that's normally deployed at sst_site_root
sst_is_root = False
# This is the name that appears in the top left of the navbar
sst_project_name = SunPy
# The logo to go in the top navbar in place of the project name
sst_logo =
navbar_links =
footer_links =

0 comments on commit a6c5dbb

Please sign in to comment.