Skip to content

Commit 52a474f

Browse files
committed
adding external url option to close #14
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent 372e5f1 commit 52a474f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

_docs/getting-started.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ And here is an example with nested children (currently active in the example):
146146
url: "news"
147147
```
148148
149+
If you want to add an external url for a parent or child, do this:
150+
151+
```yaml
152+
- title: GitHub Repository
153+
external_url: https://www.github.com/vsoch/mkdocs-jekyll
154+
```
155+
149156
### News Posts
150157
151158
It might be the case that your site or group has news items that would

_includes/sidebar.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="md-sidebar__scrollwrap">
33
<div class="md-sidebar__inner">
44
<nav class="md-nav md-nav--primary" data-md-level="0">
5-
<label class="md-nav__title md-nav__title--site" for="__drawer"><span class="md-nav__button md-logo">{% if site.logo %}<img height="48" src="{{ site.url }}/{{ site.baseurl }}/{{ site.logo }}" width="48">{% else %}<i class="md-icon"></i>{% endif %}</span> {{ site.title }}</label>
5+
<label class="md-nav__title md-nav__title--site" for="__drawer"><span class="md-nav__button md-logo">{% if site.logo %}<img height="48" src="{{ site.baseurl }}/{{ site.logo }}" width="48">{% else %}<i class="md-icon"></i>{% endif %}</span> {{ site.title }}</label>
66
<div class="md-nav__source">
77
<a class="md-source" data-md-source="github" href="{{ site.repo }}" title="Go to repository">
88
<div class="md-source__icon">
@@ -25,7 +25,7 @@
2525
<ul class="md-nav__list" data-md-scrollfix="">
2626
{% for section in site.data.toc %}
2727
<li class="md-nav__item">
28-
<a class="md-nav__link" href="{{ site.baseurl }}/{{ section.url }}"
28+
<a class="md-nav__link" href="{% if section.external_url %}{{ section.external_url }}{% else %}{{ site.baseurl }}/{{ section.url }}{% endif %}"
2929
id="pancakes-{{ section.title | slugify }}"
3030
title="{{ section.title }}">{{ section.title }}</a>
3131
</li>
@@ -36,19 +36,19 @@
3636

3737
<!-- This navigation is completely for mobile -->
3838
{% for section in site.data.toc %}<li class="md-nav__item mobile-nav" style="display:none">
39-
<a class="md-nav__link" href="{{ site.baseurl }}/{{ section.url }}" title="{{ section.title }}">{{ section.title }}</a>
39+
<a class="md-nav__link" href="{% if section.external_url %}{{ section.external_url }}{% else %}{{ site.baseurl }}/{{ section.url }}{% endif %}" title="{{ section.title }}">{{ section.title }}</a>
4040
</li>{% endfor %}
4141

4242
<!-- This navigation is completely for non mobile -->
4343
{% for section in site.data.toc %}
4444
<li class="md-nav__item md-nav__item--nested not-mobile-nav">
45-
<a class="md-nav__link pancakes-parent" {% if section.children %}href="#pancakes-{{ section.title | slugify }}"{% else %}href="{{ site.baseurl }}/{{ section.url }}"{% endif %}
45+
<a class="md-nav__link pancakes-parent" {% if section.children %}href="#pancakes-{{ section.title | slugify }}"{% else %}href="{% if section.external_url %}{{ section.external_url }}{% else %}{{ site.baseurl }}/{{ section.url }}{% endif %}"{% endif %}
4646
id="pancakes-{{ section.title | slugify }}"
4747
title="{{ section.title }}">{{ section.title }}</a>
4848
{% if section.children %}<nav class="md-nav">
4949
<ul class="md-nav__list">
5050
{% for child in section.children %}<li class="md-nav__item">
51-
<a href="{{ site.baseurl }}/{{ child.url }}"
51+
<a href="{% if child.external_url %}{{ child.external_url }}{% else %}{{ site.baseurl }}/{{ child.url }}{% endif %}"
5252
title="{{ child.title }}" style="display:none"
5353
class="md-nav__link pancakes-child">{{ child.title }}</a>
5454
</li>{% endfor %}

0 commit comments

Comments
 (0)