Skip to content

Remove double-linking of theme CSS #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def update_config(app, env):


def update_templates(app, pagename, templatename, context, doctree):
"""Update template names for page build."""
"""Update template names and assets for page build."""
# Allow for more flexibility in template names
template_sections = [
"theme_navbar_start",
"theme_navbar_center",
Expand All @@ -55,7 +56,6 @@ def update_templates(app, pagename, templatename, context, doctree):
"theme_left_sidebar_end",
"sidebars",
]

for section in template_sections:
if context.get(section):
# Break apart `,` separated strings so we can use , in the defaults
Expand All @@ -69,6 +69,14 @@ def update_templates(app, pagename, templatename, context, doctree):
if not os.path.splitext(template)[1]:
context[section][ii] = template + ".html"

# Remove a duplicate entry of the theme CSS. This is because it is in both:
# - theme.conf
# - manually linked in `webpack-macros.html`
if "css_files" in context:
theme_css_name = "_static/styles/pydata-sphinx-theme.css"
if theme_css_name in context["css_files"]:
context["css_files"].remove(theme_css_name)


def add_toctree_functions(app, pagename, templatename, context, doctree):
"""Add functions so Jinja templates can add toctree objects."""
Expand Down
2 changes: 2 additions & 0 deletions src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[theme]
inherit = basic
# Note that we don't link the CSS file via Sphinx
# instead we manually link it in `webpack-macros.html`
stylesheet = styles/pydata-sphinx-theme.css
pygments_style = tango
sidebars = search-field.html, sidebar-nav-bs.html
Expand Down