statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Mounted entries show up in nav tag even when unpublished #2497

Open mattmurtaugh opened 4 years ago

mattmurtaugh commented 4 years ago

Describe the bug When using the nav tag with include_entries='true' it shows the entire mounted collection, including unpublished items. I'm trying to use the tag as a sitemap for the site, but don't want the draft blog posts to appear in the list.

To Reproduce Using the code below in a template is how I produced this.

<ul class="no-links sitemap">
    {{ nav from="/" include_entries="true" show_unpublished="false" }}
        <li>
            <a href="{{ url }}" class="inline-block">{{ title }}</a>
            {{ if children }}
                <ul class="">{{ *recursive children* }}</ul>
            {{ /if }}
        </li>
    {{ /nav }}
</ul>

Expected behavior The nav tag already filters our unpublished pages by default. At least in my use case, it should take the value from show_unpublished and use it recursively as well.

Environment details (please complete the following information):

Additional context I can remedy this issue by wrapping the whole inside of the nav tag with {{ if is_published }}, but there might be an underlying issue, so I wanted to report what I'd found.