Deletes the archive pages from the Document's quick jump.
DoubleVII opened this issue · 7 comments
Document pages will automatically render all pages in site.docs
through Jekyll, which also contains pages under Archive. This causes a lot of duplication of these quick jumps, especially if there are more versions. I recommend filtering this out with an if statement.
Like this:
<!-- /pages/docs.md -->
<div class="section-index">
<hr class="panel-line">
{% for post in site.docs %}
{% assign path_segment = post.url | split: "/" | slice: 2 %}
{% if path_segment != "Archive" %}
<div class="entry">
<h5><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h5>
<p>{{ post.description }}</p>
</div>
{% endif %}
{% endfor %}
</div>
I've tried this code but it doesn't work. I don't know why, I'm not very familiar with the Liquid language.
Did you try with a lowercase archive
? https://vsoch.github.io/docsy-jekyll/archive/
Did you try with a lowercase
archive
? https://vsoch.github.io/docsy-jekyll/archive/
Still not working. I printed the path_segment
on the page, and it has the value Archive
.
See this capture (printed post.url
and path_segment
):
okay so the next thing to try is to surround the path_segment with some character (e.g., x{{ path_segment }}x
and see if there is some white space you are missing (that is present and preventing the match as you'd expect!)
okay so the next thing to try is to surround the path_segment with some character (e.g.,
x{{ path_segment }}x
and see if there is some white space you are missing (that is present and preventing the match as you'd expect!)
I have successfully fixed this bug with the following code:
<!-- /pages/docs.md -->
<div class="section-index">
<hr class="panel-line">
{% for post in site.docs %}
{% assign path_segments = post.url | split: "/" %}
{% if path_segments[2] != "Archive" %}
<div class="entry">
<h5><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h5>
<p>{{ post.description }}</p>
</div>
{% endif %}
{% endfor %}
</div>
It looks like the slice filter does not return a string (probably an Array).
Perfecto! So is this something you want to contribute here, or were you just asking for help? Either way, glad you figured it out!
Thanks. I will close this issue. It is welcome to merge it into the repository if you agree with the idea.