Skip to content

Commit

Permalink
docs(conf.py): remove version from html_title and add script to dynam…
Browse files Browse the repository at this point in the history
…ically update sidebar text with version
  • Loading branch information
yxlao committed Dec 31, 2024
1 parent 5af0c1f commit ac56352
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
"navigation_with_keys": True,
}

# Set the title with version and git hash
html_title = f"CamTools Documentation ({release})"
# Set the title without version
# This is the tab name in the browser
html_title = "CamTools Documentation"

# Favicon
favicon_path = (
Expand All @@ -83,13 +84,13 @@
html_favicon = str(favicon_path)


# Google Analytics configuration
def add_ga_javascript(app, pagename, templatename, context, doctree):
"""
Ref: https://github.com/sphinx-contrib/googleanalytics/blob/master/sphinxcontrib/googleanalytics.py
"""
metatags = context.get("metatags", "")
metatags += """
metatags += (
"""
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FG59NQBWRW"></script>
<script>
Expand All @@ -98,7 +99,18 @@ def add_ga_javascript(app, pagename, templatename, context, doctree):
gtag('js', new Date());
gtag('config', 'G-FG59NQBWRW');
</script>
<!-- Update sidebar text -->
<script>
document.addEventListener('DOMContentLoaded', function() {
const sidebarText = document.querySelector('.sidebar-brand-text');
if (sidebarText) {
sidebarText.textContent = 'CamTools Documentation (%s)';
}
});
</script>
"""
% release
)
context["metatags"] = metatags


Expand Down

0 comments on commit ac56352

Please sign in to comment.