-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert blog to use Eleventy instead of Next.js
This came from me staring at the Next.js 13/14 update and just not wanting to do it 🙈 Our blog is hella basic, so Next.js was somewhat overkill either way. I've been playing around with Eleventy recently and wanted to try converting the blog to it. Overall the dependency management should be much simpler now. There is a downside in that it introduces a new framework, but I'd say 11ty is pretty basic to work with and given that we don't actively develop on the blog I'd say its an okay trade-off.
- Loading branch information
Showing
134 changed files
with
6,377 additions
and
3,955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const readingTime = require("eleventy-plugin-reading-time"); | ||
const { default: markdownItPrism } = require("markdown-it-prism"); | ||
|
||
module.exports = function (eleventyConfig) { | ||
eleventyConfig.addPassthroughCopy("./index.css"); | ||
|
||
eleventyConfig.addShortcode("formatDate", function (dateString) { | ||
return new Date(dateString).toLocaleDateString(undefined, { dateStyle: 'medium' }); | ||
}); | ||
|
||
eleventyConfig.addShortcode("excerpt", function (post) { | ||
if (post.data.subtitle) { | ||
return post.data.subtitle; | ||
} | ||
|
||
const strings = post.content.slice(0, 160).split(" "); | ||
strings.pop(); | ||
return `${strings.join(" ")}…`; | ||
}); | ||
|
||
eleventyConfig.addPlugin(readingTime); | ||
|
||
eleventyConfig.addCollection("tags", function (collectionApi) { | ||
return [ | ||
...new Set( | ||
collectionApi | ||
.getAll() | ||
.map((item) => item.data?.postTags || []) | ||
.flat() | ||
), | ||
]; | ||
}); | ||
|
||
eleventyConfig.amendLibrary("md", mdLib => mdLib.use(markdownItPrism)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ yarn-error.log* | |
.serverless_nextjs | ||
|
||
.vscode | ||
|
||
# 11ty | ||
_site |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[ | ||
{ | ||
"name": "Klas Eskilson", | ||
"avatar": "1_zSqaPz5bMJHwmyprRRmK0g.jpeg" | ||
}, | ||
{ | ||
"name": "Brian Underwood", | ||
"avatar": "brian.jpg" | ||
}, | ||
{ | ||
"name": "Anton Kondratiuk", | ||
"avatar": "anton.jpeg", | ||
"shortDescription": "Android Engineer - Platform" | ||
}, | ||
{ | ||
"name": "Emil Bogren", | ||
"avatar": "emil.jpeg", | ||
"shortDescription": "Engineering Manager - Social" | ||
}, | ||
{ | ||
"name": "Gayan Witharana", | ||
"avatar": "gayan.jpg", | ||
"shortDescription": "Frontend Engineer in the Web-Discovery team" | ||
}, | ||
{ | ||
"name": "Knut Holm", | ||
"avatar": "knut.jpeg", | ||
"shortDescription": "Engineering Manager and Frontend Developer" | ||
}, | ||
{ | ||
"name": "Luke Hansford", | ||
"avatar": "luke_smallest.jpg", | ||
"shortDescription": "Engineering manager and full-stack web developer" | ||
}, | ||
{ | ||
"name": "Pedro Mancheno", | ||
"avatar": "1_PG2n91CBU1I42lTpwkgz_g.jpeg", | ||
"shortDescription": "Software Engineer. Crafting beautiful code for the sake of my future self." | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"siteTitle": "Fishbrain Engineering Blog" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
pagination: | ||
data: authors | ||
size: 1 | ||
alias: author | ||
permalink: "authors/{{ author.name | slugify }}/" | ||
eleventyComputed: | ||
title: "{{ author.name }} | {{ meta.siteTitle }}" | ||
layout: layout.njk | ||
--- | ||
<article class="mb-32"> | ||
<div class="tracking-tighter leading-tight md:leading-none mb-12 text-center md:text-left"> | ||
<h1 class="text-5xl md:text-6xl lg:text-7xl font-bold tracking-tighter leading-tight md:leading-none text-center md:text-left"> | ||
{{ author.name }} | ||
</h1> | ||
{% if author.shortDescription %} | ||
<p class="mt-6 text-lg">{{ author.shortDescription }}</p> | ||
{% endif %} | ||
</div> | ||
<section className="grid grid-cols-1 row-gap-0 mb-32"> | ||
{% for post in collections.post | reverse %} | ||
{% if post.data.author == author.name %} | ||
<div class="border-b-2 pb-8 mb-10"> | ||
{% if post.data.imageSrc %} | ||
<div class="mb-5"> | ||
<div class="sm:mx-0"> | ||
<a aria-label="{{ post.data.postTitle }}" href="/posts/{{ post.fileSlug }}"> | ||
<img src="/posts/{{ post.fileSlug }}/{{ post.data.imageSrc }}" alt="{{ post.data.imageAlt }}" class="shadow-small hover:shadow-medium transition-shadow duration-200 w-full"/> | ||
</a> | ||
</div> | ||
</div> | ||
{% endif %} | ||
<h3 class="text-3xl mb-3 leading-snug"> | ||
<a class="hover:underline" href="/posts/{{ post.fileSlug }}">{{ post.data.postTitle }}</a> | ||
</h3> | ||
<div class="text-lg markdown"> | ||
{% excerpt post %} | ||
</div> | ||
<div class="text-md my-4"> | ||
<time datetime="{{ post.data.date }}">{% formatDate post.data.date %}</time> - {{ post.content | readingTime }} read | ||
</div> | ||
<div class="flex items-center"> | ||
{% for a in authors %} | ||
{% if a.name == post.data.author %} | ||
<a aria-label="{{post.data.author}}" href="/authors/{{post.data.author | slugify }}"> | ||
<img | ||
src="/images/authors/{{a.avatar}}" | ||
class="w-12 h-12 rounded-full mr-4" | ||
alt="{{post.data.author}}" | ||
/> | ||
</a> | ||
{% endif %} | ||
{% endfor %} | ||
<a class="text-xl font-bold hover:underline" href="/authors/{{post.data.author | slugify }}"> | ||
{{post.data.author}} | ||
</a> | ||
</div> | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
</section> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
layout: layout.njk | ||
--- | ||
|
||
<section class="grid grid-cols-1 row-gap-0 mb-32"> | ||
{% for post in collections.post | reverse %} | ||
<div class="border-b-2 pb-8 mb-10"> | ||
{% if post.data.imageSrc %} | ||
<div class="mb-5"> | ||
<div class="sm:mx-0"> | ||
<a aria-label="{{ post.data.postTitle }}" href="/posts/{{ post.fileSlug }}"> | ||
<img src="/posts/{{ post.fileSlug }}/{{ post.data.imageSrc }}" alt="{{ post.data.imageAlt }}" class="shadow-small hover:shadow-medium transition-shadow duration-200 w-full"/> | ||
</a> | ||
</div> | ||
</div> | ||
{% endif %} | ||
<h3 class="text-3xl mb-3 leading-snug"> | ||
<a class="hover:underline" href="/posts/{{ post.fileSlug }}">{{ post.data.postTitle }}</a> | ||
</h3> | ||
<div class="text-lg markdown"> | ||
{% excerpt post %} | ||
</div> | ||
<div class="text-md my-4"> | ||
<time datetime="{{ post.data.date }}">{% formatDate post.data.date %}</time> - {{ post.content | readingTime }} read | ||
</div> | ||
<div class="flex items-center"> | ||
{% for a in authors %} | ||
{% if a.name == post.data.author %} | ||
<a aria-label="{{post.data.author}}" href="/authors/{{post.data.author | slugify }}"> | ||
<img | ||
src="/images/authors/{{a.avatar}}" | ||
class="w-12 h-12 rounded-full mr-4" | ||
alt="{{post.data.author}}" | ||
/> | ||
</a> | ||
{% endif %} | ||
{% endfor %} | ||
<a class="text-xl font-bold hover:underline" href="/authors/{{post.data.author | slugify }}"> | ||
{{post.data.author}} | ||
</a> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>{{ title }}</title> | ||
|
||
<link rel="shortcut icon" href="/favicon.ico"/> | ||
<link rel="alternate" type="application/rss+xml" href="/feed.xml"/> | ||
<meta name="description" content="We make an app for fishing, the world's most popular hobby."/> | ||
<meta name="color-scheme" content="light dark"> | ||
{% if metaImage %} | ||
<meta property="og:image" content="{{ metaImage }}"/> | ||
{% endif %} | ||
|
||
<link rel="stylesheet" href="{{ '/assets/css/index.css' | url }}"> | ||
<link href="https://unpkg.com/[email protected]/themes/prism-nord.css" rel="stylesheet"/> | ||
</head> | ||
<body> | ||
<div class="min-h-screen"> | ||
|
||
<div class="container max-w-3xl mx-auto px-5"> | ||
<header class="flex items-center mt-8 mb-4"> | ||
<a href="/"> | ||
<img src="/app-icon.png" alt="Fishbrain" class="h-12 mr-2"/> | ||
</a> | ||
<a href="/" class="hover:underline"> | ||
{% if metaImage %} | ||
<h1 class="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mr-auto">{{ meta.siteTitle }}</h1> | ||
{% else %} | ||
<div class="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mr-auto">{{ meta.siteTitle }}</div> | ||
{% endif %} | ||
</a> | ||
<input id="dark-mode" class="dark-mode-checkbox visually-hidden" type="checkbox"> | ||
</header> | ||
<hr/> | ||
<div class="py-2 uppercase text-sm text-gray-500"> | ||
<a class="hover:underline" href="https://fishbrain.com">Get the app</a> | ||
<span class="px-2">|</span> | ||
<a class="hover:underline" href="https://careers.fishbrain.com/">Join the team</a> | ||
</div> | ||
<hr class="mb-8"/> | ||
<main> | ||
{{ content | safe }} | ||
</main> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
layout: layout.njk | ||
eleventyComputed: | ||
title: "{{ postTitle }} | {{ meta.siteTitle }}" | ||
metaImage: "{{ imageSrc }}" | ||
--- | ||
<article class="mb-32"> | ||
<div class="tracking-tighter leading-tight md:leading-none mb-12 text-center md:text-left"> | ||
<h1 class="text-5xl md:text-6xl lg:text-7xl font-bold tracking-tighter leading-tight md:leading-none text-center md:text-left"> | ||
{{ postTitle }} | ||
</h1> | ||
{% if subtitle %} | ||
<p class="mt-6 text-lg">{{ subtitle }}</p> | ||
{% endif %} | ||
</div> | ||
<div class="hidden md:block md:mb-12"> | ||
<div class="flex items-center"> | ||
{% for a in authors %} | ||
{% if a.name == author %} | ||
<a class="text-xl font-bold hover:underline" href="/authors/{{author | slugify }}" aria-label="{{author}}"> | ||
<img | ||
src="/images/authors/{{a.avatar}}" | ||
class="w-12 h-12 rounded-full mr-4" | ||
alt="{{author}}" | ||
/> | ||
</a> | ||
{% endif %} | ||
{% endfor %} | ||
<a class="text-xl font-bold hover:underline" href="/authors/{{author | slugify }}"> | ||
{{author}} | ||
</a> | ||
</div> | ||
</div> | ||
<div class="mb-8 md:mb-16 max-w-2xl mx-auto"> | ||
{% if imageSrc %} | ||
<div class="sm:mx-0"> | ||
<a href="/posts/{{slug}}" aria-label="{{title}}"> | ||
<img src="{{ imageSrc }}" alt="{{ imageAlt }}"/> | ||
</a> | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="max-w-2xl mx-auto"> | ||
<div class="block md:hidden mb-6"> | ||
<div class="flex items-center"> | ||
{% for a in authors %} | ||
{% if a.name == author %} | ||
<a aria-label="{{author}}" href="/authors/{{author | slugify }}"> | ||
<img | ||
src="/images/authors/{{a.avatar}}" | ||
class="w-12 h-12 rounded-full mr-4" | ||
alt="{{author}}" | ||
/> | ||
</a> | ||
{% endif %} | ||
{% endfor %} | ||
<a class="text-xl font-bold hover:underline" href="/authors/{{author | slugify }}"> | ||
{{author}} | ||
</a> | ||
</div> | ||
</div> | ||
<div class="mb-6 text-lg"> | ||
<time datetime="{{ date }}">{% formatDate date %}</time> - {{ content | readingTime }} read | ||
</div> | ||
</div> | ||
<PostBody content={post.content} tags={post.postTags}/> | ||
<div class="max-w-2xl mx-auto markdown"> | ||
{{ content | safe }} | ||
<section class="flex flex-wrap"> | ||
{% for tag in postTags %} | ||
<a href="/tags/{{ tag | slugify }}" class="bg-gray-400 py-2 px-4 text-gray-900 mr-4 mb-4">{{ tag }}</a> | ||
{% endfor %} | ||
</section> | ||
</div> | ||
</article> |
Oops, something went wrong.