-
Notifications
You must be signed in to change notification settings - Fork 341
ENH: Add breadcrumbs to article header #1142
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
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bb3abef
ENH: Add breadcrumbs to article header
choldgraf ee7a5ae
Merge branch 'main' into breadcrumbs
choldgraf 9e25a43
Update src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/b…
choldgraf 9cae296
More fixes
choldgraf 2ca194c
merge
choldgraf f5ec1cd
Improving nested page behavior
choldgraf 1050001
Documenting breadcrumbs
choldgraf d7b6a02
Update src/pydata_sphinx_theme/assets/styles/components/_breadcrumbs.…
choldgraf 1276cb4
Breacrumbs have link color
choldgraf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
src/pydata_sphinx_theme/assets/styles/components/_breadcrumbs.scss
This file contains hidden or 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,38 @@ | ||
/** | ||
* 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.8em; | ||
|
||
li.breadcrumb-item { | ||
display: flex; | ||
align-items: center; | ||
|
||
// 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; | ||
} | ||
|
||
// Breadcrumb links should behave like navbar links | ||
a { | ||
color: var(--pst-color-text-muted); | ||
transition: color 0.25s ease-out; | ||
|
||
&:hover { | ||
color: var(--pst-color-primary); | ||
text-decoration: none; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.