Skip to content

Commit

Permalink
Add article and content footer components (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf authored Mar 21, 2023
1 parent eec17ab commit 956edcf
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
# "navbar_end": ["theme-switcher", "navbar-icon-links"],
# "navbar_persistent": ["search-button"],
# "primary_sidebar_end": ["custom-template.html", "sidebar-ethical-ads.html"],
# "article_footer_items": ["prev-next.html", "test.html", "test.html"],
# "content_footer_items": ["prev-next.html", "test.html", "test.html"],
# "footer_start": ["test.html", "test.html"],
# "secondary_sidebar_items": ["page-toc.html"], # Remove the source buttons
"switcher": {
Expand Down
30 changes: 30 additions & 0 deletions docs/user_guide/layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Click on section titles to learn more about them and some basic layout configura

Article Footer

``article_footer_items``

.. grid-item::
:padding: 2
:columns: 6
Expand Down Expand Up @@ -151,6 +153,8 @@ Click on section titles to learn more about them and some basic layout configura

Footer content

``content_footer_items``



.. grid-item::
Expand Down Expand Up @@ -421,6 +425,15 @@ Article Footer
Located in ``sections/footer-article.html``.

The article footer exists just below your page's article, and is primarily used for navigating between adjacent sections / pages.
By default, it has the following templates:

.. code-block:: python
html_theme_options = {
...
"article_footer_items": ["prev-next.html"],
...
}
Hide the previous and next buttons
----------------------------------
Expand All @@ -434,6 +447,23 @@ at the bottom. You can hide these buttons with the following configuration:
"show_prev_next": False
}
Content Footer
==============

Located in ``sections/footer-content.html``.

The content footer exists below your page's article and secondary sidebar.
By default it is empty, but you can add templates to it with the following configuration:

.. code-block:: python
html_theme_options = {
...
"content_footer_items": ["your-template.html"],
...
}
.. _layout-footer:

Footer
Expand Down
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ def compile(session):
if _should_install(session):
session.install("-e", ".")
session.install("sphinx-theme-builder[cli]")
session.run("stb", "compile")


@nox.session(name="docs")
def docs(session):
"""Build the documentation and place in docs/_build/html."""
"""Build the documentation and place in docs/_build/html. Use --no-compile to skip compilation."""
if _should_install(session):
session.install("-e", ".[doc]")
session.install("sphinx-theme-builder[cli]")
if "no-compile" not in session.posargs:
session.run("stb", "compile")
session.run("sphinx-build", "-b=html", "docs/", "docs/_build/html", "-v")


Expand Down
2 changes: 2 additions & 0 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ def update_and_remove_templates(app, pagename, templatename, context, doctree):
"theme_navbar_end",
"theme_article_header_start",
"theme_article_header_end",
"theme_article_footer_items",
"theme_content_footer_items",
"theme_footer_start",
"theme_footer_end",
"theme_secondary_sidebar_items",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@import "./sections/article";
@import "./sections/footer";
@import "./sections/footer-article";
@import "./sections/footer-content";
@import "./sections/header";
@import "./sections/header-article";
@import "./sections/sidebar-primary";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.bd-footer-article {
display: flex;
margin-top: auto;
.footer-article-items {
display: flex;
flex-direction: column;
margin-top: auto;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.bd-footer-content {
.footer-content-items {
display: flex;
flex-direction: column;
margin-top: auto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
{% endblock docs_toc %}
</div>
<footer class="bd-footer-content">
<div class="bd-footer-content__inner">{% include "sections/footer-content.html" %}</div>
{% include "sections/footer-content.html" %}
</footer>
{% endblock docs_main %}
</main>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{% include "components/footer-article/prev-next.html" %}
{% if theme_article_footer_items %}
<div class="footer-article-items footer-article__inner">
{% for item in theme_article_footer_items %}
<div class="footer-article-item">{% include item %}</div>
{% endfor %}
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{#- Intentionally empty in case others want to add something -#}
{% if theme_content_footer_items %}
<div class="footer-content-items footer-content__inner">
{% for item in theme_content_footer_items %}
<div class="footer-content-item">{% include item %}</div>
{% endfor %}
</div>
{% endif %}
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
Expand Up @@ -43,6 +43,8 @@ navbar_end = theme-switcher.html, navbar-icon-links.html
navbar_persistent = search-button.html
article_header_start = breadcrumbs.html
article_header_end =
article_footer_items = prev-next.html
content_footer_items =
primary_sidebar_end = sidebar-ethical-ads.html
footer_start = copyright.html, sphinx-version.html
footer_end = theme-version.html
Expand Down

0 comments on commit 956edcf

Please sign in to comment.