Skip to content
Snippets Groups Projects
Unverified Commit 29b5d147 authored by Peter Mosses's avatar Peter Mosses Committed by GitHub
Browse files

Fix external links for sites with no pages (#1021)


Fix #1020

- Move the display of nav external links from `_includes/nav.html` to `_layouts/default.html`.
- Replace ` unless include.key` by `if site.nav_external_links`.
- Wrap the body of `if site.nav_external_links` in `<ul class="nav-list">…</ul>`.

To test this PR:

1.  Add to `_config.yml`:
    ```yaml
    defaults:
      -
        scope: {path: ""}
        values: {nav_exclude: true}
    ```

2.  Check that the only link to appear in the nav panel is external.

Co-authored-by: default avatarMatt Wang <matt@matthewwang.me>
parent bf6f5028
No related branches found
No related tags found
No related merge requests found
...@@ -207,17 +207,6 @@ ...@@ -207,17 +207,6 @@
</li> </li>
{%- endunless -%} {%- endunless -%}
{%- endfor -%} {%- 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> </ul>
{%- comment -%} {%- comment -%}
......
...@@ -58,6 +58,18 @@ layout: table_wrappers ...@@ -58,6 +58,18 @@ layout: table_wrappers
{% if pages_top_size > 0 %} {% if pages_top_size > 0 %}
{% include nav.html pages=site.html_pages key=nil %} {% include nav.html pages=site.html_pages key=nil %}
{% endif %} {% endif %}
{%- if site.nav_external_links -%}
<ul class="nav-list">
{%- for node in site.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 -%}
</ul>
{%- endif -%}
{% if site.just_the_docs.collections %} {% if site.just_the_docs.collections %}
{% assign collections_size = site.just_the_docs.collections | size %} {% assign collections_size = site.just_the_docs.collections | size %}
{% for collection_entry in site.just_the_docs.collections %} {% for collection_entry in site.just_the_docs.collections %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment