Added support for search within the template as suggested in #581. I decided to go with a client side search based on [Ninja keys](https://github.com/ssleptsov/ninja-keys), but using [deepdub's fork](https://github.com/deepdub-ai/ninja-keys) as basis since it supports fuzzy search. Had to do a bunch of changes to their code to make it work without using node to install everything. Also changed to use some colors defined in our side and using both pages' titles and descriptions for search. Also had to increase the template max width to better accomodate the new item in navigation bar. Missing implementations: - [ ] One thing I'd love to do (but currently have no idea how) would be to change the text next to the search button depending on the platform. For example, if the user is accessing the site on a mac they should use ⌘k instead of ctrl k. - [x] Test how this looks like (and how it is supposed to work) on devices with smaller screens - [x] Support for offline mode Some screenshots: --- ## Dark version    --- ## Light version    --------- Signed-off-by: George Araujo <george.gcac@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
141 lines
5.5 KiB
Plaintext
141 lines
5.5 KiB
Plaintext
<header>
|
|
<!-- Nav Bar -->
|
|
<nav id="navbar" class="navbar navbar-light navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}" role="navigation">
|
|
<div class="container">
|
|
{% if page.permalink != '/' %}
|
|
<a class="navbar-brand title font-weight-lighter" href="{{ site.baseurl }}/">
|
|
{% if site.title == 'blank' %}
|
|
{% if site.first_name %}
|
|
<span class="font-weight-bold">
|
|
{{- site.first_name -}}
|
|
</span>
|
|
{% endif %}
|
|
{% if site.middle_name %}
|
|
{{- site.middle_name -}}
|
|
{% endif %}
|
|
{% if site.last_name %}
|
|
{{- site.last_name -}}
|
|
{% endif %}
|
|
{% else %}
|
|
{{- site.title -}}
|
|
{% endif %}
|
|
</a>
|
|
{% elsif site.enable_navbar_social %}
|
|
<!-- Social Icons -->
|
|
<div class="navbar-brand social">{% include social.liquid %}</div>
|
|
{% endif %}
|
|
<!-- Navbar Toggle -->
|
|
<button
|
|
class="navbar-toggler collapsed ml-auto"
|
|
type="button"
|
|
data-toggle="collapse"
|
|
data-target="#navbarNav"
|
|
aria-controls="navbarNav"
|
|
aria-expanded="false"
|
|
aria-label="Toggle navigation"
|
|
>
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar top-bar"></span>
|
|
<span class="icon-bar middle-bar"></span>
|
|
<span class="icon-bar bottom-bar"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse text-right" id="navbarNav">
|
|
<ul class="navbar-nav ml-auto flex-nowrap">
|
|
{% for page in site.pages %}
|
|
{% if page.permalink == '/' %} {% assign about_title = page.title %} {% endif %}
|
|
{% endfor %}
|
|
|
|
<!-- About -->
|
|
<li class="nav-item {% if page.permalink == '/' %}active{% endif %}">
|
|
<a class="nav-link" href="{{ '/' | relative_url }}">
|
|
{{- about_title }}
|
|
{% if page.permalink == '/' %}
|
|
<span class="sr-only">(current)</span>
|
|
{% endif %}
|
|
</a>
|
|
</li>
|
|
|
|
<!-- Other pages -->
|
|
{% assign sorted_pages = site.pages | sort: 'nav_order' %}
|
|
{% for p in sorted_pages %}
|
|
{% if p.nav and p.autogen == null %}
|
|
{% if p.dropdown %}
|
|
{% assign has_active_child = false %}
|
|
{% for child in p.children %}
|
|
{% if page.title == child.title %}
|
|
{% assign has_active_child = true %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
<li class="nav-item dropdown {% if page.title == p.title or has_active_child %}active{% endif %}">
|
|
<a
|
|
class="nav-link dropdown-toggle"
|
|
href="#"
|
|
id="navbarDropdown"
|
|
role="button"
|
|
data-toggle="dropdown"
|
|
aria-haspopup="true"
|
|
aria-expanded="false"
|
|
>
|
|
{{- p.title }}
|
|
{% if page.title == p.title or has_active_child %}
|
|
<span class="sr-only">(current)</span>
|
|
{% endif %}
|
|
</a>
|
|
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
|
{% for child in p.children %}
|
|
{% if child.title == 'divider' %}
|
|
<div class="dropdown-divider"></div>
|
|
{% else %}
|
|
<a class="dropdown-item {% if page.title == child.title %}active{% endif %}" href="{{ child.permalink | relative_url }}">
|
|
{{- child.title -}}
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
</li>
|
|
{% else %}
|
|
<li class="nav-item {% if page.url contains p.permalink %}active{% endif %}">
|
|
{% if p.permalink contains '/blog/' %}{% assign url = '/blog/' %} {% else %}{% assign url = p.url %}{% endif %}
|
|
<a class="nav-link" href="{{ url | relative_url }}">
|
|
{{- p.title }}
|
|
{% if page.url contains p.url %}
|
|
<span class="sr-only">(current)</span>
|
|
{% endif %}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if site.search_enabled %}
|
|
<!-- Search -->
|
|
<li class="nav-item">
|
|
<button id="search-toggle" title="Search" onclick="openSearchModal()">
|
|
<span class="nav-link">ctrl k <i class="ti ti-search"></i></span>
|
|
</button>
|
|
</li>
|
|
{% endif %}
|
|
{% if site.enable_darkmode %}
|
|
<!-- Toogle theme mode -->
|
|
<li class="toggle-container">
|
|
<button id="light-toggle" title="Change theme">
|
|
<i class="ti ti-sun-moon" id="light-toggle-system"></i>
|
|
<i class="ti ti-moon-filled" id="light-toggle-dark"></i>
|
|
<i class="ti ti-sun-filled" id="light-toggle-light"></i>
|
|
</button>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
{% if site.enable_progressbar %}
|
|
<!-- Scrolling Progress Bar -->
|
|
<progress id="progress" value="0">
|
|
<div class="progress-container">
|
|
<span class="progress-bar"></span>
|
|
</div>
|
|
</progress>
|
|
{% endif %}
|
|
</header>
|