Skip to content

Commit ab19cb2

Browse files
committed
Make doc index work with translated documentation too
1. Distinguish doc index using appropriate language-specific permalink. Fortunately, doc-heading.html already sets 'doc_link' variable. 2. For translated doc, iterate over site.translated, instead of site.doc.
1 parent 1072186 commit ab19cb2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

_includes/doc-index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{% assign doc_content = site.data.includes %}
44
{% assign lang = "" %}
55
{% assign indexed = site.data.doc-index %}
6+
{% assign all_docs = site.doc %}
67
{% else %}
78
{% assign lang = "/" | append: page.lang %}
89
{% assign doc_content = site.data.translation[page.lang].includes %}
@@ -13,6 +14,7 @@
1314
{% if indexed == nil or indexed.size == 0 %}
1415
{% assign indexed = site.data.doc-index %}
1516
{% endif %}
17+
{% assign all_docs = site.translated %}
1618
{% endif %}
1719
{% assign docs = doc_content | where_exp: "item", "item.section == 'doc-content'" | first %}
1820
<!-- Opening HTML for doc content -->
@@ -41,7 +43,7 @@ <h2 id="{{ item.title | downcase | replace: " ", "-" | replace: ",",""}}">{{ ite
4143
{% if item.category == 'external' %}
4244
<li><a href="{{ sub.url }}">{{ sub.text }}</a></li>
4345
{%- else %}
44-
{% for page in site.doc %}{% if page.url == sub.url -%}
46+
{% for page in all_docs %}{% if page.url == sub.url -%}
4547
<li><a href="{{ sub.url }}">{{ page.title }}</a></li>
4648
{%- endif %}{% endfor %}
4749
{%- endif %}
@@ -64,7 +66,7 @@ <h3 id="{{ sub2.title | downcase | replace: " ", "-" | replace: ",","" }}">{{ su
6466
{% if item.category == 'external' %}
6567
<li><a href="{{ sub3.url }}">{{ sub3.text }}</a></li>
6668
{%- else %}
67-
{% for page in site.doc -%}
69+
{% for page in all_docs -%}
6870
{% if page.url == sub3.url -%}
6971
<li><a href="{{ sub3.url }}">{{ page.title }}</a></li>
7072
{%- endif %}

_layouts/doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="container">
55
{% include doc-heading.html %}
66
<div class="more-bottom white-box page-content">
7-
{% if page.permalink == '/doc/' %}
7+
{% if page.permalink == doc_link %}
88
{% include doc-index.html %}
99
{% else %}
1010
{% include doc-content.html %}

0 commit comments

Comments
 (0)