Verified Commit 939c9bc9 authored by Benedikt's avatar Benedikt
Browse files

fix the ordering mess. use kapitels for ordering

parent 09d0614b
Loading
Loading
Loading
Loading
+3 −22
Original line number Diff line number Diff line
@@ -40,31 +40,12 @@ export default async function (eleventyConfig) {
    });
  });

  // sort by order filter
  eleventyConfig.addFilter("sortByOrder", collection => {
    return collection.sort((a, b) => {
      return a.data.order - b.data.order;
    });
  });
  // sort by kapitel filter
  eleventyConfig.addFilter("sortByKapitel", collection => {
    return collection.sort((a, b) => {
      return a.data.kapitel - b.data.kapitel;
    });
  });

  // sort by kapitel and order filter
  eleventyConfig.addFilter("sortBy", collection => {
    return collection.sort((a, b) => {
      if (a.data.kapitel < b.data.kapitel) {
        return -1;
      }
      else if (a.data.kapitel > b.data.kapitel) {
        return 1;
      }
      else {
        return a.data.order - b.data.order;
      }
      if (a.data.kapitel < b.data.kapitel) return -1;
      else if (a.data.kapitel > b.data.kapitel) return 1;
      else return 0;
    });
  });

+9 −7
Original line number Diff line number Diff line
@@ -12,11 +12,13 @@
    <div class="flex-shrink-0 text-xl font-semibold">Site x5</div>

    {# Mitte: Navigation #}
    <nav id="main-nav" class="hidden absolute top-[66px] left-0 right-0 bg-[#1b1d1e] dark:bg-black flex flex-col space-y-4 px-6 py-4 text-lg
    <nav id="main-nav"
      class="hidden absolute top-[66px] left-0 right-0 bg-[#1b1d1e] dark:bg-black flex flex-col space-y-4 px-6 py-4 text-lg
             md:relative md:flex md:flex-1 md:justify-center md:flex-row md:space-x-6 md:space-y-0 md:top-0 md:p-0 md:bg-transparent">
      {%- for item in collections.main | sortByOrder -%}
      {%- for item in collections.main | sortByKapitel -%}
      {% set isActive = item.data.mainSection == mainSection %}
        <a href="{{ item.url }}" {% if isActive %} aria-current="page" data-state="active" {% endif %} class="hover:text-[#e1c5a8] dark:hover:text-sky-400 {% if isActive %} border-b-2 border-white pb-1 {% endif %}">
      <a href="{{ item.url }}" {% if isActive %} aria-current="page" data-state="active" {% endif %}
        class="hover:text-[#e1c5a8] dark:hover:text-sky-400 {% if isActive %} border-b-2 border-white pb-1 {% endif %}">
        {{ item.data.title }}
      </a>
      {%- endfor -%}
+7 −9
Original line number Diff line number Diff line
---
title: Blog
order: 5
kapitel: 5
mainSection: blog
---

@@ -11,12 +11,11 @@ mainSection: blog
  <div>
    <h2>Programmierung</h2>
    <ul>
      {%- for post in collections.programmierung | filterByTags(["index"]) | sortBy -%}
      {%- for post in collections.programmierung | filterByTags(["index"]) | sortByKapitel -%}
      <li>
        <a href="{{ post.url }}">
        {%- if post.data.kapitel -%}
          {{ post.data.kapitel }} - 
        {% endif -%}{{ post.data.title }}
        {{ post.data.kapitel | join(".") }} - 
        {{ post.data.title }}
        </a>
      </li>
      {%- endfor -%}
@@ -26,12 +25,11 @@ mainSection: blog
  <div>
    <h2>Datenbanken</h2>
    <ul>
      {%- for post in collections.datenbanken | filterByTags(["index"]) | excludeByTags(["subindex"]) | sortBy -%}
      {%- for post in collections.datenbanken | filterByTags(["index"]) | excludeByTags(["subindex"]) | sortByKapitel -%}
      <li>
        <a href="{{ post.url }}">
        {%- if post.data.kapitel -%}
          {{ post.data.kapitel }} - 
        {% endif -%}{{ post.data.title }}
        {{ post.data.kapitel | join(".") }} - 
        {{ post.data.title }}
        </a>
      </li>
      {%- endfor -%}
+3 −4
Original line number Diff line number Diff line
---
title: Datenbanken
order: 3
kapitel: 3
mainSection: datenbanken
---

@@ -10,9 +10,8 @@ mainSection: datenbanken
  {%- for post in collections.datenbanken | filterByTags(["index"]) | sortByKapitel -%}
  <li>
    <a href="{{ post.url }}">
    {%- if post.data.kapitel -%}
      {{ post.data.kapitel }} - 
    {% endif -%}{{ post.data.title }}
    {{ post.data.kapitel | join(".") }} - 
    {{ post.data.title }}
    </a>
  </li>
  {%- endfor -%}
+1 −1
Original line number Diff line number Diff line
---
title: Home
order: 1
kapitel: 1
permalink: "/"
---

Loading