Skip to content

Commit 40acca8

Browse files
committedJul 14, 2024·
Endlich die Index modularisiert
1 parent 1605e65 commit 40acca8

File tree

4 files changed

+43
-71
lines changed

4 files changed

+43
-71
lines changed
 
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div{% if myClass %} class="{{myClass}}"{% endif %}>
2+
<ul class="list list--shortlist">
3+
{% set atPost = 0 %}
4+
{%- for post in myCollection %}
5+
{%- if atPost < 8 -%}
6+
<li class="list__item list__item--overview"><a href="{{ post.url | url}}">{{ post.data.title }}</a></li>
7+
{%- endif -%}
8+
{# Zählvariable hochzählen #}
9+
{% set atPost = atPost + 1 %}
10+
{%- endfor -%}
11+
</ul>
12+
<div class="overview__forward">
13+
<a href="{{myLink | url}}">
14+
mehr aus der Kategorie <strong>{{myLinkText}}</strong> ...</a>
15+
</div>
16+
17+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h2 class="index-headline separator"><span>{{myLinkText}}</span></h2>

‎src/assets/scss/_overview.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
display: block;
6565
}
6666
}
67-
&--grid {
67+
&--grid .list {
6868
display: grid;
6969
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
7070
gap: $gap;

‎src/content/pages/index.njk

+24-70
Original file line numberDiff line numberDiff line change
@@ -12,87 +12,41 @@ eleventyNavigation:
1212
key: Startseite
1313
order: 1
1414
---
15-
<h2 class="index-headline separator"><span>Hauptgerichte</span></h2>
15+
{% set myLinkText = "Hauptgerichte" %}
16+
{% include "partials/index-headline.njk" %}
1617
<div class="overview">
1718
{% set randomPost = collections.maincourseCollection | getRandom %}
1819
{% include "partials/random-post-card.njk" %}
19-
<div>
20-
<ul class="list list--shortlist">
21-
{% set atPost = 0 %}
22-
{%- for post in collections.maincourseCollection %}
23-
{%- if atPost < 8 -%}
24-
<li class="list__item list__item--overview"><a href="{{ post.url | url}}">{{ post.data.title }}</a></li>
25-
{%- endif -%}
26-
{# Zählvariable hochzählen #}
27-
{% set atPost = atPost + 1 %}
28-
{%- endfor -%}
29-
</ul>
30-
<div class="overview__forward">
31-
<a href="hauptgerichte.html">
32-
mehr aus der Kategorie <strong>Hauptgerichte</strong> ...</a>
33-
</div>
34-
35-
</div>
20+
{% set myCollection = collections.maincourseCollection %}
21+
{% set myLink = "hauptgerichte.html" %}
22+
{% include "partials/first-meals.njk" %}
3623
</div>
3724

38-
<h2 class="index-headline separator"><span>Beilagen</span></h2>
25+
{% set myLinkText = "Beilagen" %}
26+
{% include "partials/index-headline.njk" %}
3927
<div class="overview">
4028
{% set randomPost = collections.sidedishCollection | getRandom %}
4129
{% include "partials/random-post-card.njk" %}
42-
<div class="overview__shortlist">
43-
<ul class="list list--shortlist">
44-
{% set atPost = 0 %}
45-
{%- for post in collections.sidedishCollection %}
46-
{%- if atPost < 8 -%}
47-
<li class="list__item list__item--overview"><a href="{{ post.url | url}}">{{ post.data.title }}</a></li>
48-
{%- endif -%}
49-
{# Zählvariable hochzählen #}
50-
{% set atPost = atPost + 1 %}
51-
{%- endfor -%}
52-
</ul>
53-
<div class="overview__forward">
54-
<a href="beilagen.html">
55-
mehr aus der Kategorie <strong>Beilagen</strong> ...</a>
56-
</div>
57-
</div>
58-
30+
{% set myCollection = collections.sidedishCollection %}
31+
{% set myLink = "beilagen.html" %}
32+
{% include "partials/first-meals.njk" %}
5933
</div>
6034

61-
<h2 class="index-headline separator"><span>Sonstiges</span></h2>
62-
<div>
63-
<ul class="list list--grid">
64-
{% set atPost = 0 %}
65-
{%- for post in collections.otherCollection %}
66-
{%- if atPost < 8 -%}
67-
<li class="list__item list__item--overview"><a href="{{ post.url | url}}">{{ post.data.title }}</a></li>
68-
{%- endif -%}
69-
{# Zählvariable hochzählen #}
70-
{% set atPost = atPost + 1 %}
71-
{%- endfor -%}
72-
</ul>
73-
<div class="overview__forward">
74-
<a href="sonstiges.html">
75-
mehr aus der Kategorie <strong>Sonstiges</strong> ...</a>
76-
</div>
35+
{% set myCollection = collections.otherCollection %}
36+
{% set myClass="list--grid" %}
37+
{% set myLink = "sonstiges.html" %}
38+
{% set myLinkText = "Sonstiges" %}
7739

78-
</div>
40+
{% include "partials/index-headline.njk" %}
41+
{% include "partials/first-meals.njk" %}
7942

80-
<h2 class="index-headline separator"><span>Wissenswertes</span></h2>
81-
<div>
82-
<ul class="list list--grid">
83-
{% set atPost = 0 %}
84-
{%- for post in collections.wissenswertes %}
85-
{%- if atPost < 8 -%}
86-
<li class="list__item list__item--overview"><a href="{{ post.url | url}}">{{ post.data.title }}</a></li>
87-
{%- endif -%}
88-
{# Zählvariable hochzählen #}
89-
{% set atPost = atPost + 1 %}
90-
{%- endfor -%}
91-
</ul>
92-
<div class="overview__forward">
93-
<a href="wissenswertes.html">
94-
mehr aus der Kategorie <strong>Wissenswertes</strong> ...</a>
95-
</div>
9643

97-
</div>
44+
{% set myCollection = collections.wissenswertes %}
45+
{% set myClass="list--grid" %}
46+
{% set myLink = "wissenswertes.html" %}
47+
{% set myLinkText = "Wissenswertes" %}
48+
49+
{% include "partials/index-headline.njk" %}
50+
{% include "partials/first-meals.njk" %}
51+
9852

0 commit comments

Comments
 (0)
Please sign in to comment.