<a
  class="np-header-desktop-nav-item"
  data-test="open-desktop-menu"
  data-toggle-event="mouseover"
  data-toggle-class-on-target="np-hidden"
  data-toggle-target=".np-courses-tooltip"
  data-toggle-outside
>
  {{title}}
</a>
<div class="np-dropdown-tooltip np-courses-tooltip np-hidden" role="tooltip">
  <nav class="np-tooltip-navigation">
    {% assign categories_by_name = categories | sort: "name" %}
    {% for category in categories_by_name %}
      {% assign category_name_split = category.name | split: " " %}
      {% assign category_name_joined = category_name_split | join: "-" | downcase %}
        {% assign category_name = "" %}
        {% assign courses_per_carousel = 0 %}
        {% assign catalog_courses = courses %}
        {% if courses.any? %}                     
          {% for course in courses %}           
            {% for course_category in course.categories %}
                {% if category.name == course_category.name %}                       
                  {% assign courses_per_carousel = courses_per_carousel | plus: 1 %}
                  {% if courses_per_carousel > 0 %}
                    {% assign category_name = category.name %}
                  {% endif %}
                {% endif %}
            {% endfor %}
          {% endfor %}
        {% endif %}

      {% if category_name != "" %}
        <a class="np-dropdown-tooltip-link" href="#{{category_name_joined}}">
          {{category_name}}
        </a>
      {% endif %}       
    {% endfor %}
  </nav>
</div>

<script>
  $(document).ready(function() {
    if (!$('.np-homepage').length) {
        console.log("not the homepage")
        $(".np-dropdown-tooltip-link").each(function() {
          let homeLink = "/app/" + $(this).attr("href");
          $(this).attr("href", homeLink);
        })
    }
  })
</script>