Skip to content

Commit

Permalink
Pass the right links for navbar for any language
Browse files Browse the repository at this point in the history
  • Loading branch information
dpshelio committed Aug 8, 2019
1 parent 84dee0a commit 7e595c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
22 changes: 14 additions & 8 deletions _includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@
{% endif %}

{% comment %} Always show link to home page. {% endcomment %}
<a class="navbar-brand" href="{{ page.root }}{% link index.md %}">{{ include.language.index }}</a>
{% assign indexurl = include.pathLocale | append: "index/" | absolute_url %}
<a class="navbar-brand" href="{{ indexurl }}">{{ include.language.index }}</a>

</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">

{% comment %} Always show code of conduct. {% endcomment %}
<li><a href="{{ page.root }}{% link CONDUCT.md %}">{{ include.language.CoC }}</a></li>
{% assign CoCurl = include.pathLocale | append: "conduct/" | absolute_url %}
<li><a href="{{ CoCurl}}">{{ include.language.CoC }}</a></li>

{% if site.kind == "lesson" %}
{% comment %} Show setup instructions. {% endcomment %}
<li><a href="{{ page.root }}{% link setup.md %}">{{ include.language.setup }}</a></li>
{% assign setupurl = include.pathLocale | append: "setup/" | absolute_url %}
<li><a href="{{ setupurl }}">{{ include.language.setup }}</a></li>

{% comment %} Show lesson episodes for lessons. {% endcomment %}
<li class="dropdown">
Expand All @@ -55,7 +58,8 @@
<li><a href="{{ episode.url }}">{{ episode.title }}</a></li><!-- NOTE: Check whether this works on github where root is different than localhost; also for extras and others. -->
{% endfor %}
<li role="separator" class="divider"></li>
<li><a href="{{ page.root }}{% link aio.md %}">{{ include.language.aio }} (Beta)</a></li>
{% assign aiourl = include.pathLocale | append: "aio/" | absolute_url %}
<li><a href="{{ aiourl }}">{{ include.language.aio }} (Beta)</a></li>
</ul>
</li>
{% endif %}
Expand All @@ -65,7 +69,8 @@
<li class="dropdown">
<a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ include.language.extras }} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ page.root }}{% link reference.md %}">{{ include.language.reference }}</a></li>
{% assign referenceurl = include.pathLocale | append: "reference/" | absolute_url %}
<li><a href="{{ referenceurl }}">{{ include.language.reference }}</a></li>
{% for extra in extras %}
<li><a href="{{ extra.url }}">{{ extra.title }}</a></li>
{% endfor %}
Expand All @@ -74,7 +79,8 @@
{% endif %}

{% comment %} Always show license. {% endcomment %}
<li><a href="{{ page.root }}{% link LICENSE.md %}">{{ include.language.LICENSE }}</a></li>
{% assign licenseurl = include.pathLocale | append: "LICENSE/" | absolute_url %}
<li><a href="{{ licenseurl}}">{{ include.language.LICENSE }}</a></li>
{% if page.source %}
{% if page.source == "Rmd" %}
<li><a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path|replace: "_episodes", "_episodes_rmd" | replace: ".md", ".Rmd"}}">{{ include.language.improve }}<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li>
Expand All @@ -96,9 +102,9 @@
{% comment %} Check whether the page is a root page {% endcomment %}
{% assign allpages = site.pages | map: "path" %}
{% if allpages contains current_page %}
{% assign path_current = site.pages | where_exp: "spage", "spage.path contains current_page" | map: "url" %}
{% assign path_current_original = site.pages | where_exp: "spage", "spage.path contains current_page" | map: "url" %}
{% assign path_word = current_page | replace: ".md", "" %}
<li><a href="{{ path_current }}">en: {{ include.language_en[path_word] }}</a>
<li><a href="{{ path_current_original }}">en: {{ include.language_en[path_word] }}</a>
{% else %}
{% comment %} Looking for episodes {% endcomment %}
{% for episode in site.episodes %}
Expand Down
3 changes: 2 additions & 1 deletion _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{% assign extras = site.locale | where_exp:"item", "item.path contains pathLocale" | where_exp:"item", "item.path contains 'extra'" | sort: "path" %}
{% else %}
{% assign locale = "en" %}
{% assign pathLocale = "" %}
{% assign episodes = site.episodes %}
{% assign extras = site.extras %}
{% endif %}
Expand Down Expand Up @@ -53,7 +54,7 @@
{% include life_cycle.html %}

<div class="container">
{% include navbar.html language=data_language language_en=data_language_en episodes=episodes extras=extras locale=locale %}
{% include navbar.html language=data_language language_en=data_language_en episodes=episodes extras=extras locale=locale pathLocale=pathLocale %}
{{ content }}
{% if site.kind == "workshop" %}
{% include workshop_footer.html %}
Expand Down

0 comments on commit 7e595c8

Please sign in to comment.