From c50a6dcd517987cf5d9d3ec4b070348cdc96d393 Mon Sep 17 00:00:00 2001
From: malthefogsporring <malthe@sporring.eu>
Date: Wed, 11 Jan 2023 17:03:07 +0000
Subject: [PATCH] Fix an issue where search bar didn't show on online docs.
 This is fixed permanently by only installing the current version of
 mkdocs-material, so future updates do not break out code.

Fix an issue where styles.css was not accessible to the website, by changing from combinatronics to jsdelivr as service for accessing the raw css file hosted on github.
---
 .github/workflows/deploy_website.yml  |  2 +-
 doc/custom.css                        |  2 +-
 mkdocs.yml                            |  2 +-
 site_overrides/main.html              | 10 +++----
 site_overrides/partials/nav-item.html | 43 ++++++++++++++++++++-------
 5 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/deploy_website.yml b/.github/workflows/deploy_website.yml
index 18ce205b0..268b30cb3 100644
--- a/.github/workflows/deploy_website.yml
+++ b/.github/workflows/deploy_website.yml
@@ -11,7 +11,7 @@ jobs:
       - uses: actions/setup-python@v2
         with:
           python-version: 3.x
-      - run: pip install mkdocs-material
+      - run: pip install mkdocs-material==9.0.3
       - run: pip install https://github.com/mitya57/python-markdown-math/archive/master.zip
       - run: pip install mkdocs-exclude
       - run: pip install mkdocs-redirects
diff --git a/doc/custom.css b/doc/custom.css
index cd5919e27..f36d4b4f5 100644
--- a/doc/custom.css
+++ b/doc/custom.css
@@ -60,4 +60,4 @@
         -ms-scroll-snap-type: none;
         scroll-snap-type: none;
     }
-}
\ No newline at end of file
+}
diff --git a/mkdocs.yml b/mkdocs.yml
index 19517c35c..a630d3d01 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -15,7 +15,7 @@ theme:
 docs_dir: 'doc'
 extra_css:
     - custom.css
-    - https://combinatronics.com/maths/moodle-qtype_stack/master/styles.css
+    - 'https://cdn.jsdelivr.net/gh/maths/moodle-qtype_stack@master/styles.css'
 markdown_extensions:
     - mdx_math
     - extra
diff --git a/site_overrides/main.html b/site_overrides/main.html
index 93c0e7565..f7af3d083 100644
--- a/site_overrides/main.html
+++ b/site_overrides/main.html
@@ -13,7 +13,7 @@
   </script>
 {% endblock %}
 
-<!--Override basic header-->
+ <!--Override basic header -->
 {% block header %}
 <header class="md-header" data-md-component="header">
   <nav class="md-header__inner md-grid" aria-label="{{ lang.t('header.title') }}">
@@ -24,13 +24,13 @@
     <label class="md-header__button md-icon" for="__drawer">
       {% include ".icons/material/menu" ~ ".svg" %}
     </label>
-    <!--Make site title permament-->
+    <!--Make site title permament -->
     <div class="md-header__title" data-md-component="header-title">
-      <div class="md-header__ellipsis md-header__topic md-ellipsis">
-        {{ config.site_name }}
+      <div class="md-header__ellipsis md-ellipsis">
+        <b>{{ config.site_name }}</b>
       </div>
     </div>
-     {% if "search" in config["plugins"] %}
+     {% if "material/search" in config.plugins %}
       <label class="md-header__button md-icon" for="__search">
         {% include ".icons/material/magnify.svg" %}
       </label>
diff --git a/site_overrides/partials/nav-item.html b/site_overrides/partials/nav-item.html
index c6896fb35..45c66cd29 100644
--- a/site_overrides/partials/nav-item.html
+++ b/site_overrides/partials/nav-item.html
@@ -3,7 +3,6 @@
   {% if nav_item.active %}
     {% set class = class ~ " md-nav__item--active" %}
   {% endif %}
-
 <!--Skip first level in the navigation bar, i.e. the "En" level-->
   {%if nav_item.title == "En"%}
     {% set base = path %}
@@ -20,17 +19,39 @@
       {% set class = class ~ " md-nav__item--section" %}
     {% endif %}
     <li class="{{ class }} md-nav__item--nested">
+      {% set expanded = "navigation.expand" in features %}
+      {% set active = nav_item.active or expanded %}
       {% set checked = "checked" if nav_item.active %}
-      {% if "navigation.expand" in features and not checked %}
-        <input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}"
-        data-md-state="indeterminate" type="checkbox" id="{{ path }}" checked>
+      {% if expanded and not checked %}
+        {% set indeterminate = "md-toggle--indeterminate" %}
+      {% endif %}
+      <input class="md-nav__toggle md-toggle {{ indeterminate }}" data-md-toggle="{{ path }}" 
+      type="checkbox" id="{{ path }}" {{ checked }}>
+      {% set indexes = [] %}
+      {% if "navigation.indexes" in features %}
+        {% for nav_item in nav_item.children %}
+          {% if nav_item.is_index and not index is defined %}
+            {% set _ = indexes.append(nav_item) %}
+          {% endif %}
+        {% endfor %}
+      {% endif %}
+      {% if not indexes %}
+        <label class="md-nav__link" for="{{ path }}" tabindex="0" aria-expanded="{{ nav_item.active | tojson }}">
+          {{ nav_item.title }}
+          <span class="md-nav__icon md-icon"></span>
+        </label>
       {% else %}
-        <input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" {{ checked }}>
+        {% set index = indexes | first %}
+        {% set class = "md-nav__link--active" if index == page %}
+        <div class="md-nav__link md-nav__link--index {{ class }}">
+          <a href="{{ index.url | url }}">{{ nav_item.title }}</a>
+          {% if nav_item.children | length > 1 %}
+            <label for="{{ path }}">
+              <span class="md-nav__icon md-icon"></span>
+            </label>
+          {% endif %}
+        </div>
       {% endif %}
-      <label class="md-nav__link" for="{{ path }}">
-        {{ nav_item.title }}
-        <span class="md-nav__icon md-icon"></span>
-      </label>
       <nav class="md-nav" aria-label="{{ nav_item.title }}" data-md-level="{{ level }}">
         <label class="md-nav__title" for="{{ path }}">
           <span class="md-nav__icon md-icon"></span>
@@ -38,7 +59,9 @@
         </label>
         <ul class="md-nav__list" data-md-scrollfix>
           {% for nav_item in nav_item.children %}
-            {{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
+            {% if not indexes or nav_item != indexes | first %}
+              {{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
+            {% endif %}
           {% endfor %}
         </ul>
       </nav>
-- 
GitLab