fix conflicts

This commit is contained in:
marksie1988 2020-06-27 10:02:36 +01:00
parent 040bef90bb
commit d3d17c0460
2 changed files with 109 additions and 60 deletions

View File

@ -1,51 +1,55 @@
<nav role="navigation" aria-label="Main navigation"> <ul class="nav-list">
<ul class="navigation-list"> {%- assign ordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order != nil" -%}
{%- assign ordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order != nil" -%} {%- assign unordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order == nil" -%}
{%- assign unordered_pages_list = site.html_pages | where_exp:"item", "item.nav_order == nil" -%} {%- if site.nav_sort == 'case_insensitive' -%}
{%- if site.nav_sort == 'case_insensitive' -%} {%- assign sorted_ordered_pages_list = ordered_pages_list | sort_natural:"nav_order" -%}
{%- assign sorted_ordered_pages_list = ordered_pages_list | sort_natural:"nav_order" -%} {%- assign sorted_unordered_pages_list = unordered_pages_list | sort_natural:"title" -%}
{%- assign sorted_unordered_pages_list = unordered_pages_list | sort_natural:"title" -%} {%- else -%}
{%- else -%} {%- assign sorted_ordered_pages_list = ordered_pages_list | sort:"nav_order" -%}
{%- assign sorted_ordered_pages_list = ordered_pages_list | sort:"nav_order" -%} {%- assign sorted_unordered_pages_list = unordered_pages_list | sort:"title" -%}
{%- assign sorted_unordered_pages_list = unordered_pages_list | sort:"title" -%} {%- endif -%}
{%- endif -%} {%- assign pages_list = sorted_ordered_pages_list | concat: sorted_unordered_pages_list -%}
{%- assign pages_list = sorted_ordered_pages_list | concat: sorted_unordered_pages_list -%} {%- for node in pages_list -%}
{%- for node in pages_list -%} {%- unless node.nav_exclude -%}
{%- unless node.nav_exclude -%} {%- if node.parent == nil and node.title -%}
{%- if node.parent == nil and node.title -%} <li class="nav-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
<li class="navigation-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}"> {%- if page.parent == node.title or page.grand_parent == node.title -%}
{%- if page.parent == node.title or page.grand_parent == node.title -%} {%- assign first_level_url = node.url | relative_url -%}
{%- assign first_level_url = node.url | relative_url -%} {%- endif -%}
{%- endif -%} {%- if node.has_children -%}
<a href="{{ node.url | relative_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a> <a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
{%- if node.has_children -%} {%- endif -%}
{%- assign children_list = pages_list | where: "parent", node.title -%} <a href="{{ node.url | relative_url }}" class="nav-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
<ul class="navigation-list-child-list "> {%- if node.has_children -%}
{%- for child in children_list -%} {%- assign children_list = pages_list | where: "parent", node.title -%}
{%- unless child.nav_exclude -%} <ul class="nav-list ">
<li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}"> {%- for child in children_list -%}
{%- if page.url == child.url or page.parent == child.title -%} {%- unless child.nav_exclude -%}
{%- assign second_level_url = child.url | relative_url -%} <li class="nav-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
{%- endif -%} {%- if page.url == child.url or page.parent == child.title -%}
<a href="{{ child.url | relative_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a> {%- assign second_level_url = child.url | relative_url -%}
{%- if child.has_children -%} {%- endif -%}
{%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%} {%- if child.has_children -%}
<ul class="navigation-list-child-list"> <a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
{%- for grand_child in grand_children_list -%} {%- endif -%}
<li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}"> <a href="{{ child.url | relative_url }}" class="nav-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
<a href="{{ grand_child.url | relative_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a> {%- if child.has_children -%}
</li> {%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%}
{%- endfor -%} <ul class="nav-list">
</ul> {%- for grand_child in grand_children_list -%}
{%- endif -%} <li class="nav-list-item {% if page.url == grand_child.url %} active{% endif %}">
</li> <a href="{{ grand_child.url | relative_url }}" class="nav-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
{%- endunless -%} </li>
{%- endfor -%} {%- endfor -%}
</ul> </ul>
{%- endif -%} {%- endif -%}
</li> </li>
{%- endif -%} {%- endunless -%}
{%- endunless -%} {%- endfor -%}
{%- endfor -%} </ul>
</ul> {%- endif -%}
</nav> </li>
{%- endif -%}
{%- endunless -%}
{%- endfor -%}
</ul>

View File

@ -3,23 +3,68 @@ namespace :search do
task :init do task :init do
puts 'Creating search data json file...' puts 'Creating search data json file...'
mkdir_p 'assets/js' mkdir_p 'assets/js'
touch 'assets/js/search-data.json' touch 'assets/js/zzzz-search-data.json'
content = %Q[{{ page.content | markdownify | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '</ul', ' . </ul' | replace: '</tr', ' . </tr' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | strip_html | escape_once | remove: 'Table of contents' | remove: '```' | remove: '---' | replace: '\\', ' ' | replace: ' . . . ', ' . ' | replace: ' . . ', ' . ' | normalize_whitespace }}]
puts 'Done.' puts 'Done.'
puts 'Generating content...' puts 'Generating content...'
File.open('assets/js/search-data.json', 'w') do |f| File.open('assets/js/zzzz-search-data.json', 'w') do |f|
f.puts '--- f.puts '---
permalink: /assets/js/search-data.json
--- ---
{ {
{% assign comma = false %} {%- assign i = 0 -%}
{% for page in site.html_pages %}{% if page.search_exclude != true %}{% if comma == true%},{% endif %}"{{ forloop.index0 }}": { {% for page in site.html_pages %}
"title": "{{ page.title | replace: \'&amp;\', \'&\' }}", {%- if page.title and page.search_exclude != true -%}
"content": "'+content+'", {%- assign page_content = page.content -%}
{%- assign heading_level = site.search.heading_level | default: 2 -%}
{%- for j in (2..heading_level) -%}
{%- assign tag = \'<h\' | append: j -%}
{%- assign closing_tag = \'</h\' | append: j -%}
{%- assign page_content = page_content | replace: tag, \'<h1\' | replace: closing_tag, \'</h1\' -%}
{%- endfor -%}
{%- assign parts = page_content | split: \'<h1\' -%}
{%- assign title_found = false -%}
{% for part in parts offset: 1 %}
{%- assign titleAndContent = part | split: \'</h1>\' -%}
{%- assign title = titleAndContent[0] | replace_first: \'>\', \'<h1>\' | split: \'<h1>\' -%}
{%- assign title = title[1] | strip_html -%}
{%- assign content = titleAndContent[1] -%}
{%- assign url = page.url -%}
{%- if title == page.title and parts[0] == \'\' -%}
{%- assign title_found = true -%}
{%- else -%}
{%- assign id = titleAndContent[0] -%}
{%- assign id = id | split: \'id="\' -%}
{%- if id.size == 2 -%}
{%- assign id = id[1] -%}
{%- assign id = id | split: \'"\' -%}
{%- assign id = id[0] -%}
{%- capture url -%}{{ url | append: \'#\' | append: id }}{%- endcapture -%}
{%- endif -%}
{%- endif -%}
{%- unless i == 0 -%},{%- endunless -%}
"{{ i }}": {
"doc": {{ page.title | jsonify }},
"title": {{ title | jsonify }},
"content": {{ content | replace: \'</h\', \' . </h\' | replace: \'<hr\', \' . <hr\' | replace: \'</p\', \' . </p\' | replace: \'<ul\', \' . <ul\' | replace: \'</ul\', \' . </ul\' | replace: \'<ol\', \' . <ol\' | replace: \'</ol\', \' . </ol\' | replace: \'</tr\', \' . </tr\' | replace: \'<li\', \' | <li\' | replace: \'</li\', \' | </li\' | replace: \'</td\', \' | </td\' | replace: \'<td\', \' | <td\' | replace: \'</th\', \' | </th\' | replace: \'<th\', \' | <th\' | strip_html | remove: \'Table of contents\' | normalize_whitespace | replace: \'. . .\', \'.\' | replace: \'. .\', \'.\' | replace: \'| |\', \'|\' | append: \' \' | jsonify }},
"url": "{{ url | relative_url }}",
"relUrl": "{{ url }}"
}
{%- assign i = i | plus: 1 -%}
{%- endfor -%}
{%- unless title_found -%}
{%- unless i == 0 -%},{%- endunless -%}
"{{ i }}": {
"doc": {{ page.title | jsonify }},
"title": {{ page.title | jsonify }},
"content": {{ parts[0] | replace: \'</h\', \' . </h\' | replace: \'<hr\', \' . <hr\' | replace: \'</p\', \' . </p\' | replace: \'<ul\', \' . <ul\' | replace: \'</ul\', \' . </ul\' | replace: \'<ol\', \' . <ol\' | replace: \'</ol\', \' . </ol\' | replace: \'</tr\', \' . </tr\' | replace: \'<li\', \' | <li\' | replace: \'</li\', \' | </li\' | replace: \'</td\', \' | </td\' | replace: \'<td\', \' | <td\' | replace: \'</th\', \' | </th\' | replace: \'<th\', \' | <th\' | strip_html | remove: \'Table of contents\' | normalize_whitespace | replace: \'. . .\', \'.\' | replace: \'. .\', \'.\' | replace: \'| |\', \'|\' | append: \' \' | jsonify }},
"url": "{{ page.url | relative_url }}", "url": "{{ page.url | relative_url }}",
"relUrl": "{{ page.url }}" "relUrl": "{{ page.url }}"
}{% assign comma = true %} }
{% endif %}{% endfor %} {%- assign i = i | plus: 1 -%}
{%- endunless -%}
{%- endif -%}
{% endfor %}
}' }'
end end
puts 'Done.' puts 'Done.'