Skip to content
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

Deletes the archive pages from the Document's quick jump. #75

Closed
DoubleVII opened this issue Nov 1, 2022 · 7 comments
Closed

Deletes the archive pages from the Document's quick jump. #75

DoubleVII opened this issue Nov 1, 2022 · 7 comments

Comments

@DoubleVII
Copy link

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>
@DoubleVII
Copy link
Author

I've tried this code but it doesn't work. I don't know why, I'm not very familiar with the Liquid language.

@vsoch
Copy link
Owner

vsoch commented Nov 1, 2022

Did you try with a lowercase archive ? https://vsoch.github.io/docsy-jekyll/archive/

@DoubleVII
Copy link
Author

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 ):
capture

@vsoch
Copy link
Owner

vsoch commented Nov 1, 2022

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!)

@DoubleVII
Copy link
Author

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).

@vsoch
Copy link
Owner

vsoch commented Nov 1, 2022

Perfecto! So is this something you want to contribute here, or were you just asking for help? Either way, glad you figured it out!

@DoubleVII
Copy link
Author

Thanks. I will close this issue. It is welcome to merge it into the repository if you agree with the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants