Skip to content

Commit

Permalink
docs and fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Apr 6, 2024
1 parent 70a3ed5 commit 5c74a7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The core changes between this theme and the `pydata-sphinx-theme` are:
* Add links to the header bar which are specified as theme config variables, with defaults for sunpy.org.
* Add a center element to the footer bar.
* Restyled the theme for SunPy colors.
* Added optional support for analytics though `goatcounter.com <https://www.goatcounter.com/>`__ which defaults to on for sunpy.org domains.

.. grid:: 1 2 2 2
:gutter: 3
Expand Down
4 changes: 2 additions & 2 deletions src/sunpy_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def setup(app: Sphinx):
root_domain = theme_options.get("sst_site_root", "https://sunpy.org")
sunpy_goat_url = "https://sunpy.goatcounter.com/count"
default_goat_url = sunpy_goat_url if root_domain == "https://sunpy.org" else None
if theme_options.get("goatcounter_analytics_url", default_goat_url):
if primary_goat_url := theme_options.get("goatcounter_analytics_url", default_goat_url):
root_domain = root_domain.removeprefix("https://").removeprefix("http://")
default_endpoint = theme_options.get("goatcounter_non_domain_endpoint", False)
if default_endpoint is False:
Expand All @@ -159,7 +159,7 @@ def setup(app: Sphinx):
body=f"""
var endpoint = '{default_endpoint}';
if (location.hostname.endsWith('{root_domain}')) {{
endpoint = '{theme_options["goatcounter_analytics_url"]}'
endpoint = '{primary_goat_url}'
}}
window.goatcounter = {{
Expand Down
2 changes: 1 addition & 1 deletion src/sunpy_sphinx_theme/theme/sunpy/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sst_is_root = False
sst_project_name = SunPy
# Enable sending stats to goat counter
# Set this URL to something like https://MYCODE.goatcounter.com/count
goatcounter_analytics_url = https://sunpy.goatcounter.com/count
goatcounter_analytics_url =
# If you only want to count visits to sst_site_root or subdomains there of then set this to False
# otherwise set it to another (or the same) goat counter endpoint
goatcounter_non_domain_endpoint = False
Expand Down

0 comments on commit 5c74a7f

Please sign in to comment.