11---js
22// <script >
33const eleventyNavigation = {
4- key: " Series" ,
5- order: 2 ,
4+ key: " Series" ,
5+ order: 2 ,
66};
77const aside = true ;
88
99function pageSeries (collection ){
1010 return Object .keys (collection)
1111 .map ((name ) => ({
12- name: name,
13- latestPostDate: new Date (Math .max (... collection[name].map (p => p .date ))),
14- posts: collection[name],
12+ name: name,
13+ latestPostDate: new Date (Math .max (... collection[name].map (p => p .date ))),
14+ posts: collection[name],
1515 }))
1616 .sort ((a , b ) => b .latestPostDate - a .latestPostDate );
1717};
1818// </script >
1919---
2020{% css %}
2121.series-posts {
22- display: grid;
23- grid-gap: 1rem;
24- grid-template-columns: 1fr 1fr 1fr 1fr;
22+ display: grid;
23+ grid-gap: 1rem;
24+ grid-template-columns: 1fr 1fr 1fr 1fr;
2525}
26+ @media(max-width: 1024px) {
27+ .series-posts {
28+ grid-template-columns: 1fr 1fr;
29+ }
30+ }
31+ @media(max-width: 640px) {
32+ .series-posts {
33+ grid-template-columns: 100%;
34+ }
35+ }
36+
2637.series-post {
27- display: flex;
28- flex-direction: column;
29- gap: 1rem;
30- padding: 8px;
31- background-color: var(--bg-color-secondary);
32- box-shadow: 2px 2px 4px var(--shadow-color);
33- transition: background-color 0.3s;
38+ display: flex;
39+ flex-direction: column;
40+ gap: 1rem;
41+ padding: 8px;
42+ background-color: var(--bg-color-secondary);
43+ box-shadow: 2px 2px 4px var(--shadow-color);
44+ transition: background-color 0.3s;
3445}
3546
3647.series-view-all {
37- display: flex;
38- align-items: center;
39- justify-content: center;
40- font-weight: bold;
41- padding: 8px;
42- background-color: var(--bg-color-secondary);
43- box-shadow: 2px 2px 4px var(--shadow-color);
44- transition: background-color 0.3s;
48+ display: flex;
49+ align-items: center;
50+ justify-content: center;
51+ font-weight: bold;
52+ padding: 8px;
53+ background-color: var(--bg-color-secondary);
54+ box-shadow: 2px 2px 4px var(--shadow-color);
55+ transition: background-color 0.3s;
4556}
4657h3.series-title {
47- margin-bottom: 0.5rem;
58+ margin-bottom: 0.5rem;
4859}
4960{% endcss %}
5061<h1 >Series</h1 >
5162
5263{% for series in pageSeries (collections .series ) %}
53- {% if series .posts .length > 0 %}
54- {% set serieUrl %} /series/{{ series .name | slugify }} /{% endset %}
55- <h3 class =" series-title" ><a href =" {{ serieUrl }}" >{{ series .name }} </a ></h3 >
56- <div class =" series-posts" >
57- {% for post in series .posts .slice (- 3) | reverse %}
58- <div class =" series-post" >
59- <a href =" {{ post.url }}" >
60- <img eleventy:ignore src =" {{ post.data.imageUrl }}" alt =" {{ post.data.title }}" />
61- {{ post .data .title }}
62- </a >
63- </div >
64- {% endfor %}
65- {% if series .posts .length > 3 %}
66- <div class =" series-view-all" >
67- <a href =" {{ serieUrl }}" >View all {{ series .posts .length }} posts > ;> ; </a >
68- </div >
69- {% endif %}
70- </div >
71- {% endif %}
64+ {% if series .posts .length > 0 %}
65+ {% set serieUrl %} /series/{{ series .name | slugify }} /{% endset %}
66+ <h3 class =" series-title" ><a href =" {{ serieUrl }}" >{{ series .name }} </a ></h3 >
67+ <div class =" series-posts" >
68+ {% for post in series .posts .slice (- 3) | reverse %}
69+ <div class =" series-post" >
70+ <a href =" {{ post.url }}" >
71+ <img eleventy:ignore src =" {{ post.data.imageUrl }}" alt =" {{ post.data.title }}" />
72+ {{ post .data .title }}
73+ </a >
74+ </div >
75+ {% endfor %}
76+ {% if series .posts .length > 3 %}
77+ <div class =" series-view-all" >
78+ <a href =" {{ serieUrl }}" >View all {{ series .posts .length }} posts > ;> ; </a >
79+ </div >
80+ {% endif %}
81+ </div >
82+ {% endif %}
7283{% endfor %}
0 commit comments