Skip to content

Commit

Permalink
Fix duplicated external links in collections (just-the-docs#1001)
Browse files Browse the repository at this point in the history
Fix external links and collections

The navigation should only display the external links once, after the links to pages that are not in collections.

The test for PR just-the-docs#876 at https://just-the-docs.github.io/just-the-docs-tests/navigation/external-links fails with v0.4.0.rc3,
and succeeds when the updated `nav.html` is added locally.

The docs need updating to clarify how the interaction between the collections feature and the external links feature is resolved.
  • Loading branch information
pdmosses committed Oct 14, 2022
1 parent e72181e commit 6d9d413
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 11 additions & 9 deletions _includes/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,17 @@
</li>
{%- endunless -%}
{%- endfor -%}
{%- assign nav_external_links = site.nav_external_links -%}
{%- for node in nav_external_links -%}
<li class="nav-list-item external">
<a href="{{ node.url | absolute_url }}" class="nav-list-link external">
{{ node.title }}
{% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
</a>
</li>
{%- endfor -%}
{%- unless include.key -%}
{%- assign nav_external_links = site.nav_external_links -%}
{%- for node in nav_external_links -%}
<li class="nav-list-item external">
<a href="{{ node.url | absolute_url }}" class="nav-list-link external">
{{ node.title }}
{% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
</a>
</li>
{%- endfor -%}
{%- endunless -%}
</ul>

{%- comment -%}
Expand Down
6 changes: 4 additions & 2 deletions docs/navigation-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ aux_links:
## External Navigation Links

To add external links to the navigation, add them to the `nav_external_links` [configuration]({{ site.baseurl }}{% link docs/configuration.md %}) option in your site's `_config.yml` file.
External links will appear under all other items in the listing order.
External links will appear in the navigation after the links to ordinary pages, but before any collections.

#### Example

{: .no_toc }

```yaml
Expand All @@ -266,6 +265,9 @@ nav_external_links:
hide_icon: false # set to true to hide the external link icon - defaults to false
```

The external links are decorated by an icon, which distinguishes them from internal links.
You can suppress the icon by setting `hide_icon: true`.

---

## In-page navigation with Table of Contents
Expand Down

0 comments on commit 6d9d413

Please sign in to comment.