Skip to content

Commit 0ba56bc

Browse files
committed
Overhaul to bring in line with eleventy-base-blog
1 parent 9a35a5b commit 0ba56bc

34 files changed

+810
-1212
lines changed

_config/filters.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { DateTime } from "luxon";
2+
3+
export default function(eleventyConfig) {
4+
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
5+
// Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
6+
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
7+
});
8+
9+
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
10+
// dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
11+
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat('yyyy-LL-dd');
12+
});
13+
14+
// Get the first `n` elements of a collection.
15+
eleventyConfig.addFilter("head", (array, n) => {
16+
if(!Array.isArray(array) || array.length === 0) {
17+
return [];
18+
}
19+
if( n < 0 ) {
20+
return array.slice(n);
21+
}
22+
23+
return array.slice(0, n);
24+
});
25+
26+
// Return the smallest number argument
27+
eleventyConfig.addFilter("min", (...numbers) => {
28+
return Math.min.apply(null, numbers);
29+
});
30+
31+
// Return the keys used in an object
32+
eleventyConfig.addFilter("getKeys", target => {
33+
return Object.keys(target);
34+
});
35+
36+
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
37+
return (tags || []).filter(tag => ["all", "posts"].indexOf(tag) === -1);
38+
});
39+
40+
};

_data/metadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
language: "en",
55
description: "James Kerrane's personal website.",
66
author: {
7-
name: "JP Kerrane",
7+
name: "James Kerrane",
88
email: "hi@jameskerrane.com",
99
url: "https://www.jameskerrane.com/about-me/"
1010
}

_includes/layouts/base.html renamed to _includes/layouts/base.njk

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,28 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>{{ title or metadata.title }}</title>
77
<meta name="description" content="{{ description or metadata.description }}">
8-
9-
{#- Atom and JSON feeds included by default #}
108
<link rel="alternate" href="/feed/feed.xml" type="application/atom+xml" title="{{ metadata.title }}">
11-
<link rel="alternate" href="/feed/feed.json" type="application/json" title="{{ metadata.title }}">
129

1310
<meta name="generator" content="{{ eleventy.generator }}">
1411

1512
{#-
16-
CSS bundles are provided via the `eleventy-plugin-bundle` plugin:
17-
1. You can add to them using `{% css %}`
18-
2. You can get from them using `{% getBundle "css" %}` or `{% getBundleFileUrl "css" %}`
19-
3. You can do the same for JS: {% js %}{% endjs %} and <script>{% getBundle "js" %}</script>
20-
4. Learn more: https://github.com/11ty/eleventy-plugin-bundle
13+
Plain-text bundles are provided via the `eleventy-plugin-bundle` plugin:
14+
1. CSS:
15+
* Add to a per-page bundle using `{% css %}{% endcss %}`
16+
* Retrieve bundle content using `{% getBundle "css" %}` or `{% getBundleFileUrl "css" %}`
17+
2. Or for JavaScript:
18+
* Add to a per-page bundle using `{% js %}{% endjs %}`
19+
* Retrieve via `{% getBundle "js" %}` or `{% getBundleFileUrl "js" %}`
20+
3. Learn more: https://github.com/11ty/eleventy-plugin-bundle
2121
#}
2222

23-
{#- Add an arbitrary string to the bundle #}
24-
{%- css %}* { box-sizing: border-box; }{% endcss %}
25-
{#- Add the contents of a file to the bundle #}
2623
{%- css %}{% include "public/css/index.css" %}{% endcss %}
27-
{#- Or add from node_modules #}
28-
{# {%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %} #}
2924

3025
{#- Render the CSS bundle using Inlined CSS (for the fastest site performance in production) #}
3126
<style>{% getBundle "css" %}</style>
32-
{#- Renders the CSS bundle using a separate file, if you can't set CSP directive style-src: 'unsafe-inline' #}
33-
{#- <link rel="stylesheet" href="{% getBundleFileUrl "css" %}"> #}
27+
28+
{#- Add the heading-anchors web component to the JavaScript bundle #}
29+
{%- js %}{% include "node_modules/@zachleat/heading-anchors/heading-anchors.js" %}{% endjs %}
3430
</head>
3531
<body>
3632
<a href="#skip" class="visually-hidden">Skip to main content</a>
@@ -50,13 +46,17 @@ <h2 class="visually-hidden">Top level navigation menu</h2>
5046
</header>
5147

5248
<main id="skip">
49+
<heading-anchors>
5350
{{ content | safe }}
51+
</heading-anchors>
5452
</main>
5553

5654
{%- css %}{% include "public/css/message-box.css" %}{% endcss %}
5755
<footer class="message-box">
58-
<p><em>Made with <a href="https://www.11ty.dev/">Eleventy</a>! Based on the <a href="https://github.com/11ty/eleventy-base-blog"><code>eleventy-base-blog</code> repo</a>.</em></p>
59-
<img src="/img/possum.png" alt="A possum parent and two possum kids hanging from the iconic red balloon" style="width: auto;">
56+
<p><em>Built with <a href="https://www.11ty.dev/">{{ eleventy.generator }}</a>!</em></p>
57+
<img src="../public/img/possum.png" alt="A possum parent and two possum kids hanging from the iconic red balloon" style="width: 7.8em;">
6058
</footer>
59+
60+
<script type="module" src="{% getBundleFileUrl "js" %}"></script>
6161
</body>
6262
</html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: layouts/base.html
2+
layout: layouts/base.njk
33
---
44

55
{{ content | safe }}

_includes/layouts/post.html renamed to _includes/layouts/post.njk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: layouts/base.html
2+
layout: layouts/base.njk
33
---
44
{# Only include the syntax highlighter CSS on blog posts #}
55
{%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %}
@@ -22,8 +22,8 @@ <h1>{{ title }}</h1>
2222
{%- set nextPost = collections.posts | getNextCollectionItem %}
2323
{%- if nextPost or previousPost %}
2424
<ul class="links-nextprev">
25-
{%- if previousPost %}<li>Previous: <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
26-
{%- if nextPost %}<li>Next: <a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
25+
{%- if previousPost %}<li class="links-nextprev-prev">← Previous<br> <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
26+
{%- if nextPost %}<li class="links-nextprev-next">Next →<br><a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
2727
</ul>
2828
{%- endif %}
2929
{%- endif %}
File renamed without changes.
File renamed without changes.

content/404.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
---
2-
layout: layouts/home.html
32
permalink: 404.html
43
eleventyExcludeFromCollections: true
54
---
65
# Content not found.
76

87
Go <a href="/">home</a>.
8+
9+
<!--
10+
11+
Read more: https://www.11ty.dev/docs/quicktips/not-found/
12+
13+
This will work for both GitHub pages and Netlify:
14+
15+
* https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/
16+
* https://www.netlify.com/docs/redirects/#custom-404
17+
18+
-->

content/blog.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

content/blog.njk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---js
2+
const eleventyNavigation = {
3+
key: "Blog",
4+
order: 2
5+
};
6+
---
7+
<h1>Blog</h1>
8+
9+
{% set postslist = collections.posts %}
10+
{% include "postslist.njk" %}

0 commit comments

Comments
 (0)