diff --git a/_config.yml b/_config.yml index b0f9310262914ede4ce5aafb1436d47876887a50..5944d041d4036b2080cb64e76d55ca4d95c53ae0 100644 --- a/_config.yml +++ b/_config.yml @@ -87,6 +87,11 @@ aux_links_new_tab: false # nav_sort: case_insensitive # default, equivalent to nil nav_sort: case_sensitive # Capital letters sorted before lowercase +# External navigation links +nav_external_links: + - title: Just the Docs on GitHub + url: https://github.com/just-the-docs/just-the-docs + # Footer content # appears at the bottom of every page's main content diff --git a/_includes/icons/external_link.html b/_includes/icons/external_link.html new file mode 100644 index 0000000000000000000000000000000000000000..1592be66190b9db9673b62f3122d4606d8f1e02b --- /dev/null +++ b/_includes/icons/external_link.html @@ -0,0 +1,5 @@ +<!-- Feather. MIT License: https://github.com/feathericons/feather/blob/master/LICENSE --> +<symbol id="svg-external-link" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"> + <title id="svg-external-link-title">(external link)</title> + <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line> +</symbol> diff --git a/_includes/nav.html b/_includes/nav.html index a2aa2d664e6f4488dec221703d48084c0356398e..3881008658faa4ff32c148454b3546d475a27c83 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -104,6 +104,15 @@ {%- endunless -%} {%- endif -%} {%- 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 -%} </ul> {%- if page.collection == include.key -%} diff --git a/_layouts/default.html b/_layouts/default.html index 63e23b0c64e5723b9b8847bbe4e4871cbec8dbbf..a09a2a477c9ce49d43bb171f39f0d8e3a5937248 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -38,6 +38,7 @@ layout: table_wrappers <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> + {% include icons/external_link.html %} </svg> <div class="side-bar"> diff --git a/_sass/navigation.scss b/_sass/navigation.scss index 0e67349772256afe1772ea76a2860bfb9c5685aa..20773367246037bb54335f1c5a2a86dbacb54fad 100644 --- a/_sass/navigation.scss +++ b/_sass/navigation.scss @@ -44,6 +44,12 @@ } } + &.external > svg { + width: $sp-4; + height: $sp-4; + vertical-align: text-bottom; + } + &.active { font-weight: 600; text-decoration: none; diff --git a/docs/configuration.md b/docs/configuration.md index cb0b7fd31f521274dea077275764f3aadc68ef59..041805c2429adeb41aebae56323f1747a0654d62 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -106,6 +106,11 @@ aux_links_new_tab: false heading_anchors: true ``` +## External navigation links + +External links can be added to the navigation through the `nav_external_links` option. +See [Navigation Structure]({{ site.baseurl }}{% link docs/navigation-structure.md %}#external-navigation-links) for more details. + ## Footer content ```yaml diff --git a/docs/navigation-structure.md b/docs/navigation-structure.md index 9d481bd32a46892769b20e12ba3dd5ee7ddce033..b67369c6c5f3e5e47f7573b09b0cf83ca3163bb0 100644 --- a/docs/navigation-structure.md +++ b/docs/navigation-structure.md @@ -246,6 +246,25 @@ 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. + +#### Example + +{: .no_toc } + +```yaml +# External navigation links +nav_external_links: + - title: Just the Docs on GitHub + url: https://github.com/just-the-docs/just-the-docs + hide_icon: false # set to true to hide the external link icon - defaults to false +``` + +--- + ## In-page navigation with Table of Contents To generate a Table of Contents on your docs pages, you can use the `{:toc}` method from Kramdown, immediately after an `<ol>` in Markdown. This will automatically generate an ordered list of anchor links to various sections of the page based on headings and heading levels. There may be occasions where you're using a heading and you don't want it to show up in the TOC, so to skip a particular heading use the `{: .no_toc }` CSS class.