-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Create next_prev.html #394
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
Conversation
I though it might be nice to have a next_prev.html include that could be included at the top and bottom of pages. The next_prev.html include uses the nav_order page property to find the next or previous page in the sequence and then makes these available as links. This could be added as desired to the default layout like so:
```
{% include next_prev.html %}
{{content}}
{% include next_prev.html %}
|
@jeffreycwitt thanks for the suggestion! generating links to the next and previous pages would surely be a nice enhancement. There are already links to those pages in the sidebar navigation menu (under the page titles), but having next and previous buttons at the top and bottom of each page body in a website does make it easier to go through all the pages in the right order. Moreover, the sidebar isn't visible on small screens while scrolling a page: to see the existing links to the next and previous pages, one currently has to scroll back to the top of the page and click on the menu button. Next and previous buttons are a standard feature of posts on blogs or mailing lists, but I've personally found such buttons useful also when browsing documentation pages produced using Read the Docs, and I'd like to have this feature in Just the Docs (as a configurable option). The suggested implementation clearly works well for the site shown in your screenshot. However, it appears to rely on several assumptions:
The description and implementation of the navigation structure in Just the Docs avoids making any of those assumptions:
It seems the current PR works only when all pages in the navigation set |
|
@pdmosses yes I completely agree about the assumptions required for it to work, namely:
My use case operates under these assumptions, so it works for me. I don't think I'll have time to make it more flexible for cases where the above assumptions are not met (at least until this is something my use cases demand). Nevertheless, since it would definitely be a configuration feature, it could be turned off by default, but be turned on with a configuration switch by people who understand its limitations and can ensure that their site meets the above conditions. In any case, maybe the pull request could be just considered a "feature request" with an example of how it might function. (I love the "theme" by the way!!! kudos to everyone working on it) |
Generalises the feature proposed in PR just-the-docs#394 by jeffreycwitt. The styling is just a quick hack, and needs improving. The links appear to be correct for the theme docs. Maybe the first and last pages of each list should have up-links?
|
It was quite easy to add the proposed feature to my re-implementation of PR #192 for recursive navigation. My next-prev branch generalises the feature proposed in the present PR to mutli-level hierarchies. The styling is just a quick hack, and needs improving (I'm not familiar with the CSS details). Putting the upper next-rev links to the right of any breadcrumbs should look OK. The lower next-prev links should probably be aligned with the top of the TOC. The links appear to be correct for the theme docs. I haven't yet tested that recursive includes don't overwrite local variables – it may be necessary to manipulate a stack of saved page arrays… 😟 The feature can be turned off by: nav_next_prev: falsebut that should probably be the default. Maybe the first and last pages of each list should have up-links? For the first page, up could link to the parent; for the last page, it could link to the next of the parent. To test this feature on your own site, set: remote_theme: pdmosses/just-the-docs@next-prev |
|
@pdmosses sounds great. I changed the remote them to
There definitely could be something wrong on my end. But I thought it might be worth mentioning. Here's my site instance for reference: https://github.com/jeffreycwitt/pl399 |
|
@jeffreycwitt thanks for testing my branch – much appreciated! I took a copy of your master branch, and updated it to settings that refer to After eliminating most of your source files, I finally noticed that Jekyll was processing three files that have no Could you try adding either If that doesn't fix the build issue at your end, please create a branch with a version of your site that demonstrates the issue, so I can be sure of using the same settings when debugging. |
|
@jeffreycwitt, I wrote:
In fact the Just-the-Docs navigation simply ignores pages with no title when creating the navigation. I've updated the |
|
This is a great enhancement, thank you @jeffreycwitt! In addition to what @pdmosses wrote, could we add the pagination to the bottom of the page instead of the top? |
|
@pmarsceill I don't think should be hard at all. I've put the include above and below the content, like so: Works fine in my instance. I see the navigation when I'm at the top, but also see it when I've scrolled down to the end of the page. Perhaps the config could be modified, so that users could control whether the include is added to the top, bottom, or both. I think "both" should be the default, as it seems most desirable to have it present at the top and at the bottom. |
|
@jeffreycwitt Would you have time to develop this PR to work with the multi-level navigation used for the theme docs? It might be fairly straightforward to enhance the current |
|
@pdmosses I can give it a shot. Maybe I can give it some time this weekend. So, I'll try to up this PR to include your changes to support multi-level navigation. Then you can review the updated PR. |
|
@pdmosses @pmarsceill checkout my most recent commits. This is just one option whose main virtue is simplicity. The only change is that the loop now checks to see if there is a common parent before looking up the next and previous page for a given context page. This seems to be enough to respect the multi-level navigation. Removing the first and third assumption. The other assumptions still apply, though they don't seem like unreasonable assumptions to me. If you don't want make these assumptions then you could just set
you can preview it here: https://jeffreycwitt.com/just-the-docs the solution of @pdmosses is much more sophisticated (and will handle much variation) but if you think its too involved to merge, this approach might be a simple temporary option until a more sophisticated approach can be merged. ps. I also had to add gem "kramdown-parser-gfm" to my the Gemfile to get it to compile locally. I'm not sure why. |
|
@jeffreycwitt thanks for the generalisation to multi-level navigation! I'll take a look at it. I hope it works well enough with the theme documentation pages. My solution is definitely not an option at present, since it relies on allowing unlimited-depth ('recursive') navigation, and the details haven't yet been reviewed. Even if approved, a merge will probably have to wait for a new major version of the theme (although I think it is actually backwards-compatible with 0.3.1). |
|
The styling that puts it in the same line as the breadcrumbs looks very good on the theme docs. As I expected, there are no next or prev links on the child pages of Your branch built OK for me without the Minor releases of this theme generally aim for complete backwards compatibility, so the default for |
|
I wrote:
The idea is to let The implementation of the idea is a bit repetitive, because the code for the top level needs duplicating at the child and grandchild levels; with recursive navigation, no duplication was needed. But it works OK with the current 3-level navigation (I've tested it with some grandchildren), and it doesn't require the values of I'm attaching the updated Unless you see any drawbacks, I suggest to update the PR with these files. (I could try pushing the updates to the PR, but I don't have previous experience of doing that, and in any case I prefer to check that you don't have objections to the changes.) |
|
@pdmosses That seems like a great solution. I'll integrate your changes in the Archive.zip and then push the new commit for your review. |
|
@pdmosses have a look at the updated pull request and my working gh-pages, https://jeffreycwitt.com/just-the-docs/ Seems to work well for both pages with nav_order and those without (see working nav links in the "Utilities" section.) So if @pmarsceill likes it, seems like it could be merged. P.s. Also it might be nice to have an "next/down" link when a page contains children or an "next/up" when you reach the end of the children list and want to go up to the next parent. (similarly for previous). be to include and "up" or "parent" link so that if you reach the end |
|
@jeffreycwitt Many thanks for the updates to the PR. I don't have sufficient knowledge of CSS to review the details of the styling myself, but it looks very good. I'm glad the code in If this PR is merged in 0.3.2, you might follow up by submitting an issue with your suggested enhancements before proceeding to submit a further PR. |
|
@jeffreycwitt have you considered using arrows instead of the words for the next and previous links? That might make them stand out a bit better, and look neater if you later add up and down. I have previously used Hyperlatex to generate web pages from LaTeX sources, and it automatically adds arrows: The arrows are included also at the bottom of each page. It has an option to change the behaviour of next so it automatically goes down and up, instead of staying at the same level. |
| @@ -0,0 +1,14 @@ | |||
| <nav aria-label="Breadcrumb" class="next-prev-nav"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corner case: an only child, having neither next nor prev. This currently produces an invisible empty list, which seems superfluous. I suggest to wrap this code in:
{%- if previous_page or next_page -%}
...
{%- endif -%}
| } | ||
| } | ||
|
|
||
| // Next-Prev nav |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This styling produces a small margin at the right of the list. It would probably look neater to remove it (making the Previous/Next flush with the right edge of the aux links etc.) but I don't know how to implement that.
|
@jeffreycwitt I've added a couple of minor comments on the changed files, and requested a review from @pmarsceill |
|
I'm going to circle back on this one as I'd like to think about the visual styling a bit more... I think it is a valuable addition, perhaps to get into the next patch. |
|
@pmarsceill Agreed. While it is nice to have the navigation at the top of the page, I think the navigation is most useful when at the bottom of the page. But I omitted the include here because I wasn't sure the best way to integrate the navigation styling with the already existing "back to the top" link. This also seems like a navigation function. So I think, with a little reorganization of the divs at the bottom, the next/prev links could easily be integrated in a way that is also consistent with their presentation at the top of the page. |
|
@jeffreycwitt, I wrote:
I've now added this feature to my combination-rec-nav branch (which adds multi-level navigation to the branch used for the combination PR #578). This involved rather simple additions to two files (and adding a configuration option). The results can be seen (temporarily) at https://pdmosses.github.io/just-the-docs/. I've moved the links for the previous and next pages to just above the auto-generated TOC of child pages, since they share the aim of giving quick access to closely-related pages. I've also added links to parent pages. The link texts are configurable, and appear as arrows by default: It would be easy to repeat the links at the top of the page, but as you wrote:
That is especially true on narrow displays, where the navigation panel is hidden. Pages with Comments and suggestions for improvement are welcome. |
I've now done that. It makes it a lot easier to use the relative links to browse all the siblings of a page. The CSS I used for the relative links is very basic, but appears to work – also with narrower displays:
I've also changed the default arrow symbols, because Firefox was rendering them differently from Safari. (They should probably be replaced by SVGs, to avoid browser dependence.) |
This PR combines (and resolves conflicts between) #448, #463, #466, #494, #495, #496, #498, and #572. The main aim is to facilitate use of several of the implemented features _together_, when using the fork as a remote theme. It should also simplify merging the included PRs into a future release. The branch [combination-rec-nav](https://github.com/pdmosses/just-the-docs/tree/combination-rec-nav) adds [multi-level navigation](#462) and (NEW:) [sibling links](#394) to the branch used for this PR. It includes updated [documentation for the navigation structure](https://pdmosses.github.io/just-the-docs/docs/navigation-structure/), and reorganised and extended [navigation tests](https://pdmosses.github.io/just-the-docs/tests/navigation/). The documentation and the tests can be browsed at the (temporary) [website published from the combination-rec-nav branch](https://pdmosses.github.io/just-the-docs/). _Caveat:_ The changes to v0.3.3 in this PR and #462 have not yet been reviewed or approved, and may need updating before merging into a release of the theme. If you use a branch from a PR as a remote theme, there is a risk of such updates affecting your website. Moreover, these branches are likely to be deleted after they have been merged. To avoid such problems, you could copy the branch that you want to use to your own fork of the theme. Co-authored-by: Matt Wang <[email protected]>
|
Hi all - if we're still interested in merging this PR in, I'm happy to work with us to get it up to speed. Two options:
I'm not in a rush either way, though I think this is a great feature to implement! Let me know what y'all think! (regardless, there will be several merge conflicts) |
|
@mattxwang thanks for considering this PR for inclusion in Re styling and accessibility, I'm personally quite happy with the appearance of the prev-up-next links used in my I personally dislike sites where the authors have decided to force you to go through the pages depth-first. It doesn't make much difference on a shallow site like the theme docs, but on a deep multi-level site, depth-first may require going through a lot of lower-level pages before getting to the next sibling on the current level. In any case, I don't think that depth-first is particularly appropriate for documentation sites. @jeffreycwitt would you have time to retarget this PR to v0.4.0 and resolve merge conflicts, so that @mattxwang can provide feedback on styling & accessibility? If not, it will probably have to wait for a subsequent release. |
|
Hm, for now I'm going to close this PR as stale. Feel free to re-open (or open a new PR) if you're interested in this feature! (I don't think I'd be able to dedicate time to taking over the code for this PR) |
|
@mattxwang I need next-prev for my project site. When I get time again, I'll focus first on #462, then I'll re-open this PR. |
Sounds good, looking forward to it! |
This PR combines (and resolves conflicts between) #448, #463, #466, #494, #495, #496, #498, and #572. The main aim is to facilitate use of several of the implemented features _together_, when using the fork as a remote theme. It should also simplify merging the included PRs into a future release. The branch [combination-rec-nav](https://github.com/pdmosses/just-the-docs/tree/combination-rec-nav) adds [multi-level navigation](just-the-docs/just-the-docs#462) and (NEW:) [sibling links](just-the-docs/just-the-docs#394) to the branch used for this PR. It includes updated [documentation for the navigation structure](https://pdmosses.github.io/just-the-docs/docs/navigation-structure/), and reorganised and extended [navigation tests](https://pdmosses.github.io/just-the-docs/tests/navigation/). The documentation and the tests can be browsed at the (temporary) [website published from the combination-rec-nav branch](https://pdmosses.github.io/just-the-docs/). _Caveat:_ The changes to v0.3.3 in this PR and #462 have not yet been reviewed or approved, and may need updating before merging into a release of the theme. If you use a branch from a PR as a remote theme, there is a risk of such updates affecting your website. Moreover, these branches are likely to be deleted after they have been merged. To avoid such problems, you could copy the branch that you want to use to your own fork of the theme. Co-authored-by: Matt Wang <[email protected]>



I though it might be nice to have a next_prev.html include that could be included at the top and bottom of pages. The next_prev.html include uses the nav_order page property to find the next or previous page in the sequence and then makes these available as links. This could be added as desired to the default layout like so: