-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add breadcrumbs to article header (#1142)
* ENH: Add breadcrumbs to article header * Update src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html Co-authored-by: Tania Allard <taniar.allard@gmail.com> * More fixes * Improving nested page behavior * Documenting breadcrumbs * Update src/pydata_sphinx_theme/assets/styles/components/_breadcrumbs.scss Co-authored-by: Rambaud Pierrick <12rambau@users.noreply.github.com> * Breacrumbs have link color --------- Co-authored-by: Tania Allard <taniar.allard@gmail.com> Co-authored-by: Rambaud Pierrick <12rambau@users.noreply.github.com>
- Loading branch information
1 parent
3a59b4e
commit df125aa
Showing
16 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
docs/examples/subpages/subsubpages/subsubsubpages/subsubsubpage1.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Sub sub sub page 1 | ||
================== | ||
|
||
Test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/pydata_sphinx_theme/assets/styles/components/_breadcrumbs.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Breadcrumbs for parent pages meant for the article header | ||
*/ | ||
ul.bd-breadcrumbs { | ||
list-style: none; | ||
padding-left: 0; | ||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
// Font size slightly smaller to avoid cluttering up space too much | ||
font-size: 0.8rem; | ||
|
||
li.breadcrumb-item { | ||
display: flex; | ||
align-items: center; | ||
|
||
// Style should look like heavier in-page links | ||
font-weight: bold; | ||
a { | ||
color: var(--pst-color-link); | ||
} | ||
|
||
// Items that aren't the home have a carot to the left | ||
&:not(.breadcrumb-home):before { | ||
font-family: "Font Awesome 6 Free"; | ||
font-weight: 900; | ||
font-size: 0.8rem; | ||
content: var(--pst-breadcrumb-divider); | ||
color: var(--pst-color-text-muted); | ||
padding: 0 0.5rem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{%- block breadcrumbs %} | ||
{# | ||
If we have more than 3 parents (excluding the home page) then we remove | ||
The ones in the middle and add an ellipsis. | ||
#} | ||
{% if parents|length>2 %} | ||
{% set parents=[parents[0], {"title": '<i class="fa-solid fa-ellipsis"></i>'}, parents[-1]] %} | ||
{% endif %} | ||
|
||
{#- Hide breadcrumbs on the home page #} | ||
{% if title and pagename != root_doc %} | ||
<nav aria-label="breadcrumbs"> | ||
<ul class="bd-breadcrumbs" role="navigation" aria-label="Breadcrumb"> | ||
{# Home icon #} | ||
<li class="breadcrumb-item breadcrumb-home"> | ||
<a href="{{ pathto(root_doc) }}" class="nav-link" aria-label="Home"> | ||
<i class="fa-solid fa-home"></i> | ||
</a> | ||
</li> | ||
{%- for doc in parents %} | ||
{% if doc.link %} | ||
<li class="breadcrumb-item"><a href="{{ doc.link|e }}" class="nav-link">{{ doc.title }}</a></li> | ||
{% else %} | ||
<li class="breadcrumb-item">{{ doc.title }}</li> | ||
{% endif %} | ||
{%- endfor %} | ||
<li class="breadcrumb-item active" aria-current="page">{{ title }}</li> | ||
</ul> | ||
</nav> | ||
{% endif %} | ||
{%- endblock %} |
17 changes: 16 additions & 1 deletion
17
src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header-article.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
{#- Intentionally empty in case others want to add something -#} | ||
<div class="header-article-items header-article__section"> | ||
{% if theme_article_header_start %} | ||
<div class="header-article-items__start"> | ||
{% for item in theme_article_header_start %} | ||
<div class="header-article-start-item">{% include item %}</div> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
{% if theme_article_header_end %} | ||
<div class="header-article-items__end"> | ||
{% for item in theme_article_header_end %} | ||
<div class="header-article-end-item">{% include item %}</div> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters