Skip to content

Commit e3fa2ea

Browse files
committed
layout chaining for everything but the home page
1 parent 65b5756 commit e3fa2ea

5 files changed

Lines changed: 112 additions & 121 deletions

File tree

_includes/article.njk

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,16 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="utf-8"/>
5-
<title>{{ windowTitle }} - {{ title }}</title>
6-
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
7-
<link rel="stylesheet" href="/custom.css">
8-
<link rel="icon" href="/favicon.png" type="image/png" sizes="72x72">
9-
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
10-
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title="RSS">
11-
<meta name="author" content="Corey Beres"/>
12-
<meta name="description"
13-
content="Personal homepage for Corey Beres. Mostly thoughts about software and skateboards."/>
14-
</head>
15-
16-
<body>
17-
<header id="intro">
18-
<h1>{{ siteTitle }}</h1>
19-
<p class="back"><a href="/">&#8592; Back to home</a></p>
20-
</header>
21-
<main>
22-
<section id="article">
23-
<h2>{{ title }}</h2>
24-
<p id="time">{{ dateString }}</p>
25-
{{ content | safe }}
26-
</section>
27-
<section id="tags">
28-
tags:
29-
<ul>
30-
{%- for tag in tags -%}
31-
{% if tag != 'articles' %}<li><a href="/tags/{{ tag | slugify }}">{{ tag }}</a></li>{% endif -%}
32-
{%- endfor -%}
33-
</ul>
34-
</section>
35-
</main>
36-
<footer>
37-
<p>
38-
&copy; 2024-2025 Corey Beres.
39-
Built with <a href="https://www.11ty.dev">{{ eleventy.generator }}</a>.
40-
Source available on <a href="https://github.com/cberes/cberes.com">GitHub</a>.
41-
</p>
42-
</footer>
43-
</body>
44-
45-
</html>
1+
---
2+
layout: secondary.njk
3+
---
4+
<section id="article">
5+
<h2>{{ title }}</h2>
6+
<p id="time">{{ dateString }}</p>
7+
{{ content | safe }}
8+
</section>
9+
<section id="tags">
10+
tags:
11+
<ul>
12+
{%- for tag in tags -%}
13+
{% if tag != 'articles' %}<li><a href="/tags/{{ tag | slugify }}">{{ tag }}</a></li>{% endif -%}
14+
{%- endfor -%}
15+
</ul>
16+
</section>

_includes/main.njk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<title>{{ windowTitle }}</title>
66
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
77
<link rel="stylesheet" href="/custom.css">
8-
<link rel="stylesheet" href="/pagination.css">
98
<link rel="icon" href="/favicon.png" type="image/png" sizes="72x72">
109
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
1110
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title="RSS">

_includes/secondary.njk

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>{{ windowTitle }} - {{ title }}</title>
6+
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
7+
<link rel="stylesheet" href="/custom.css">
8+
<link rel="stylesheet" href="/pagination.css">
9+
<link rel="icon" href="/favicon.png" type="image/png" sizes="72x72">
10+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
11+
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title="RSS">
12+
<meta name="author" content="Corey Beres"/>
13+
<meta name="description"
14+
content="Personal homepage for Corey Beres. Mostly thoughts about software and skateboards."/>
15+
</head>
16+
17+
<body>
18+
<header id="intro">
19+
<h1>{{ siteTitle }}</h1>
20+
<p class="back"><a href="/">&#8592; Back to home</a></p>
21+
</header>
22+
<main>
23+
{{ content | safe }}
24+
</main>
25+
<footer>
26+
<p>
27+
&copy; 2024-2025 Corey Beres.
28+
Built with <a href="https://www.11ty.dev">{{ eleventy.generator }}</a>.
29+
Source available on <a href="https://github.com/cberes/cberes.com">GitHub</a>.
30+
</p>
31+
</footer>
32+
</body>
33+
34+
</html>

articles/index.njk

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,64 @@
11
---
2-
layout: main.njk
3-
windowTitle: cberes - Articles
2+
layout: secondary.njk
43
title: Articles
54
pagination:
65
data: collections.articles
76
reverse: true
8-
size: 10
7+
size: 6
98
---
10-
<header id="intro">
11-
<h1>{{ siteTitle }}</h1>
12-
<p class="back"><a href="/">&#8592; Back to home</a></p>
13-
</header>
14-
<main>
15-
<section id="articles">
16-
<h2>{{ title }}</h2>
9+
<section id="articles">
10+
<h2>{{ title }}</h2>
1711

18-
{# Pagination: see https://www.11ty.dev/docs/pagination/ #}
19-
{%- for a in pagination.items %}
20-
<article>
21-
<h3>{{ a.data.title }}</h3>
22-
<p class="time">{{ a.data.dateString }}</p>
23-
<p class="summary">{% summarize a %}</p>
24-
<p><a class="button" href="{{ a.url }}">Read more</a></p>
25-
</article>
26-
{%- endfor %}
12+
{# Pagination: see https://www.11ty.dev/docs/pagination/ #}
13+
{%- for a in pagination.items %}
14+
<article>
15+
<h3>{{ a.data.title }}</h3>
16+
<p class="time">{{ a.data.dateString }}</p>
17+
<p class="summary">{% summarize a %}</p>
18+
<p><a class="button" href="{{ a.url }}">Read more</a></p>
19+
</article>
20+
{%- endfor %}
2721

28-
{# Pagination nav: see https://www.11ty.dev/docs/pagination/nav/ #}
29-
{# TODO the first/previous and next/last links are inactive for the current page, but not the numbered links #}
30-
{# TODO this is fine until I have many pages #}
31-
{% if pagination.pages.length > 1 %}
32-
<nav id="pages" aria-label="pagination">
33-
<ol class="pagination">
34-
{% if pagination.pages.length < 6 %}
35-
{%- for pageEntry in pagination.pages %}
36-
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}"{% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}><span class="visuallyhidden">Page </span>{{ loop.index }}</a></li>
37-
{%- endfor %}
38-
{% else %}
39-
<li>
40-
<a href="{{ pagination.href.first }}"{% if page.url == pagination.href.first %} aria-current="page"{% endif %}>
41-
<span aria-hidden="true">&laquo;</span>
42-
<span class="visuallyhidden">first page</span>
43-
</a>
44-
</li>
45-
<li>
46-
<a href="{{ pagination.href.previous }}"{% if not pagination.href.previous %} aria-current="page"{% endif %}>
47-
<span aria-hidden="true">&lsaquo;</span>
48-
<span class="visuallyhidden">previous page</span>
49-
</a>
50-
</li>
22+
{# Pagination nav: see https://www.11ty.dev/docs/pagination/nav/ #}
23+
{# TODO the first/previous and next/last links are inactive for the current page, but not the numbered links #}
24+
{# TODO this is fine until I have many pages #}
25+
{% if pagination.pages.length > 1 %}
26+
<nav id="pages" aria-label="pagination">
27+
<ol class="pagination">
28+
{% if pagination.pages.length < 6 %}
5129
{%- for pageEntry in pagination.pages %}
52-
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}"{% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}><span class="visuallyhidden">Page </span>{{ loop.index }}</a></li>
30+
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}"{% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}><span class="visuallyhidden">Page </span>{{ loop.index }}</a></li>
5331
{%- endfor %}
54-
<li>
55-
<a href="{{ pagination.href.next }}"{% if not pagination.href.next %} aria-current="page"{% endif %}>
56-
<span class="visuallyhidden">next page</span
57-
><span aria-hidden="true">&rsaquo;</span>
58-
</a>
59-
</li>
60-
<li>
61-
<a href="{{ pagination.href.last }}"{% if page.url == pagination.href.last %} aria-current="page"{% endif %}>
62-
<span class="visuallyhidden">last page</span
63-
><span aria-hidden="true">&raquo;</span>
64-
</a>
65-
</li>
66-
{% endif %}
67-
</ol>
68-
</nav>
32+
{% else %}
33+
<li>
34+
<a href="{{ pagination.href.first }}"{% if page.url == pagination.href.first %} aria-current="page"{% endif %}>
35+
<span aria-hidden="true">&laquo;</span>
36+
<span class="visuallyhidden">first page</span>
37+
</a>
38+
</li>
39+
<li>
40+
<a href="{{ pagination.href.previous }}"{% if not pagination.href.previous %} aria-current="page"{% endif %}>
41+
<span aria-hidden="true">&lsaquo;</span>
42+
<span class="visuallyhidden">previous page</span>
43+
</a>
44+
</li>
45+
{%- for pageEntry in pagination.pages %}
46+
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}"{% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}><span class="visuallyhidden">Page </span>{{ loop.index }}</a></li>
47+
{%- endfor %}
48+
<li>
49+
<a href="{{ pagination.href.next }}"{% if not pagination.href.next %} aria-current="page"{% endif %}>
50+
<span class="visuallyhidden">next page</span
51+
><span aria-hidden="true">&rsaquo;</span>
52+
</a>
53+
</li>
54+
<li>
55+
<a href="{{ pagination.href.last }}"{% if page.url == pagination.href.last %} aria-current="page"{% endif %}>
56+
<span class="visuallyhidden">last page</span
57+
><span aria-hidden="true">&raquo;</span>
58+
</a>
59+
</li>
6960
{% endif %}
70-
</section>
71-
</main>
61+
</ol>
62+
</nav>
63+
{% endif %}
64+
</section>

tags.njk

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
---
2-
layout: main.njk
2+
layout: secondary.njk
33
pagination:
44
data: collections.tagsList
55
size: 1
66
alias: title
77
permalink: "/tags/{{ title | slugify }}/"
88
---
9-
<header id="intro">
10-
<h1>{{ siteTitle }}</h1>
11-
<p class="back"><a href="/">&#8592; Back to home</a></p>
12-
</header>
13-
<main>
14-
<section id="items">
15-
<h2>{{ title | title }}</h2>
16-
<ol>
17-
{%- for a in collections[title} | reverse %}
18-
<li><a href="{{ a.url }}">{{ a.data.title }}</a></li>
19-
{%- endfor %}
20-
</ol>
21-
</section>
22-
</main>
9+
<section id="items">
10+
<h2>{{ title | title }}</h2>
11+
<ol>
12+
{%- for a in collections[title} | reverse %}
13+
<li><a href="{{ a.url }}">{{ a.data.title }}</a></li>
14+
{%- endfor %}
15+
</ol>
16+
</section>

0 commit comments

Comments
 (0)