Skip to content

Commit 33c4ebe

Browse files
Merge pull request #1 from patrickpatrickpatrick/upgrade-11ty
Upgrade 11ty
2 parents 9ca8ece + f24b312 commit 33c4ebe

27 files changed

Lines changed: 2101 additions & 7581 deletions

.DS_Store

6 KB
Binary file not shown.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017–2023 Zach Leatherman @zachleat
3+
Copyright (c) 2017–2024 Zach Leatherman @zachleat
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,116 @@
1-
# My personal site
1+
# eleventy-base-blog v9
22

3-
It uses [eleventy-base-blog](https://github.com/11ty/eleventy-base-blog) and it is hosted on [Github Pages](https://pages.github.com/).
3+
A starter repository showing how to build a blog with the [Eleventy](https://www.11ty.dev/) site generator (using the [v3.0 release](https://github.com/11ty/eleventy/releases/tag/v3.0.0)).
4+
5+
## Getting Started
6+
7+
* [Want a more generic/detailed getting started guide?](https://www.11ty.dev/docs/getting-started/)
8+
9+
1. Make a directory and navigate to it:
10+
11+
```
12+
mkdir my-blog-name
13+
cd my-blog-name
14+
```
15+
16+
2. Clone this Repository
17+
18+
```
19+
git clone https://github.com/11ty/eleventy-base-blog.git .
20+
```
21+
22+
_Optional:_ Review `eleventy.config.js` and `_data/metadata.js` to configure the site’s options and data.
23+
24+
3. Install dependencies
25+
26+
```
27+
npm install
28+
```
29+
30+
4. Run Eleventy
31+
32+
Generate a production-ready build to the `_site` folder:
33+
34+
```
35+
npx @11ty/eleventy
36+
```
37+
38+
Or build and host on a local development server:
39+
40+
```
41+
npx @11ty/eleventy --serve
42+
```
43+
44+
Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the internals.
45+
46+
## Features
47+
48+
- Using [Eleventy v3](https://github.com/11ty/eleventy/releases/tag/v3.0.0) with zero-JavaScript output.
49+
- Content is exclusively pre-rendered (this is a static site).
50+
- Can easily [deploy to a subfolder without changing any content](https://www.11ty.dev/docs/plugins/html-base/)
51+
- All URLs are decoupled from the content’s location on the file system.
52+
- Configure templates via the [Eleventy Data Cascade](https://www.11ty.dev/docs/data-cascade/)
53+
- **Performance focused**: four-hundos Lighthouse score out of the box!
54+
- _0 Cumulative Layout Shift_
55+
- _0ms Total Blocking Time_
56+
- Local development live reload provided by [Eleventy Dev Server](https://www.11ty.dev/docs/dev-server/).
57+
- Content-driven [navigation menu](https://www.11ty.dev/docs/plugins/navigation/)
58+
- Fully automated [Image optimization](https://www.11ty.dev/docs/plugins/image/)
59+
- Zero-JavaScript output.
60+
- Support for modern image formats automatically (e.g. AVIF and WebP)
61+
- Processes images on-request during `--serve` for speedy local builds.
62+
- Prefers `<img>` markup if possible (single image format) but switches automatically to `<picture>` for multiple image formats.
63+
- Automated `<picture>` syntax markup with `srcset` and optional `sizes`
64+
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
65+
- Includes `loading="lazy"` for native lazy loading without JavaScript.
66+
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
67+
- Images can be co-located with blog post files.
68+
- Per page CSS bundles [via `eleventy-plugin-bundle`](https://github.com/11ty/eleventy-plugin-bundle).
69+
- Built-in [syntax highlighter](https://www.11ty.dev/docs/plugins/syntaxhighlight/) (zero-JavaScript output).
70+
- Draft content: use `draft: true` to mark any template as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. This is driven by the `addPreprocessor` configuration API in `eleventy.config.js`. Schema validator will show an error if non-boolean value is set in data cascade.
71+
- Blog Posts
72+
- Automated next/previous links
73+
- Accessible deep links to headings
74+
- Generated Pages
75+
- Home, Archive, and About pages.
76+
- [Atom feed included (with easy one-line swap to use RSS or JSON)](https://www.11ty.dev/docs/plugins/rss/)
77+
- `sitemap.xml`
78+
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
79+
- Content not found (404) page
80+
81+
## Demos
82+
83+
- [Netlify](https://eleventy-base-blog.netlify.app/)
84+
- [Vercel](https://demo-base-blog.11ty.dev/)
85+
- [Cloudflare Pages](https://eleventy-base-blog-d2a.pages.dev/)
86+
- [GitHub Pages](https://11ty.github.io/eleventy-base-blog/)
87+
88+
## Deploy this to your own site
89+
90+
Deploy this Eleventy site in just a few clicks on these services:
91+
92+
- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
93+
- [Deploy this to **Netlify**](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog)
94+
- [Deploy this to **Vercel**](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog)
95+
- Look in `.github/workflows/gh-pages.yml.sample` for information on [Deploying to **GitHub Pages**](https://www.11ty.dev/docs/deployment/#deploy-an-eleventy-project-to-git-hub-pages).
96+
- [Try it out on **Stackblitz**](https://stackblitz.com/github/11ty/eleventy-base-blog)
97+
98+
### Implementation Notes
99+
100+
- `content/about/index.md` is an example of a content page.
101+
- `content/blog/` has the blog posts but really they can live in any directory. They need only the `posts` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
102+
- Use the `eleventyNavigation` key (via the [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/)) in your front matter to add a template to the top level site navigation. This is in use on `content/index.njk` and `content/about/index.md`.
103+
- Content can be in _any template format_ (blog posts needn’t exclusively be markdown, for example). Configure your project’s supported templates in `eleventy.config.js` -> `templateFormats`.
104+
- The `public` folder in your input directory will be copied to the output folder (via `addPassthroughCopy` in the `eleventy.config.js` file). This means `./public/css/*` will live at `./_site/css/*` after your build completes.
105+
- This project uses three [Eleventy Layouts](https://www.11ty.dev/docs/layouts/):
106+
- `_includes/layouts/base.njk`: the top level HTML structure
107+
- `_includes/layouts/home.njk`: the home page template (wrapped into `base.njk`)
108+
- `_includes/layouts/post.njk`: the blog post template (wrapped into `base.njk`)
109+
- `_includes/postslist.njk` is a Nunjucks include and is a reusable component used to display a list of all the posts. `content/index.njk` has an example of how to use it.
110+
111+
#### Content Security Policy
112+
113+
If your site enforces a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (as public-facing sites should), you have a few choices (pick one):
114+
115+
1. In `base.njk`, remove `<style>{% getBundle "css" %}</style>` and uncomment `<link rel="stylesheet" href="{% getBundleFileUrl "css" %}">`
116+
2. Configure the server with the CSP directive `style-src: 'unsafe-inline'` (less secure).

_config/filters.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
eleventyConfig.addFilter("sortAlphabetically", strings =>
41+
(strings || []).sort((b, a) => b.localeCompare(a))
42+
);
43+
44+
// Return all the tags used in a collection
45+
eleventyConfig.addFilter("getAllTags", collection => {
46+
let tagSet = new Set();
47+
for(let item of collection) {
48+
(item.data.tags || []).forEach(tag => tagSet.add(tag));
49+
}
50+
return Array.from(tagSet);
51+
});
52+
53+
};

_data/eleventyDataSchema.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { z } from "zod";
2+
import { fromZodError } from 'zod-validation-error';
3+
4+
// Draft content, validate `draft` front matter
5+
export default function() {
6+
return function(data) {
7+
// Note that drafts may be skipped in a preprocessor (see eleventy.config.js)
8+
// when doing a standard build (not --serve or --watch)
9+
let result = z.object({
10+
draft: z.boolean().or(z.undefined()),
11+
}).safeParse(data);
12+
13+
if(result.error) {
14+
throw fromZodError(result.error);
15+
}
16+
}
17+
}

_data/metadata.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module.exports = {
2-
title: "Patrick's Pages",
1+
export default {
2+
title: "Eleventy Base Blog v9",
33
url: "https://example.com/",
44
language: "en",
5-
description: "It's Patrick's website",
5+
description: "I am writing about my experiences as a naval navel-gazer.",
66
author: {
7-
name: "Patrick",
8-
email: "",
9-
url: "https://patrickpatrickpatrick.github.io/about/"
7+
name: "Your Name Here",
8+
email: "youremailaddress@example.com",
9+
url: "https://example.com/about-me/"
1010
}
1111
}

_includes/layouts/atamaca.njk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!doctype html>
21
<html lang="en">
32

43
<head>
@@ -22,12 +21,13 @@
2221
<link href="/atamaca/css/main.50075e15.css" rel="stylesheet">
2322
</head>
2423

25-
<body><noscript>You need to enable JavaScript to run this app.</noscript>
24+
<body>
25+
<noscript>You need to enable JavaScript to run this app.</noscript>
2626
<div id="root"></div>
2727
<script src="/atamaca/js/main.js"></script>
28+
<script eleventy:ignore type="text/javascript">
29+
(() => fetch("/atamaca/references.json").then(e => e.json()).then(e => { window.renderGarden(e, '/works/atamaca-garden') }))()
30+
</script>
2831
</body>
29-
<script type="text/javascript">
30-
fetch("/atamaca/references.json").then(e => e.json()).then(e => { window.renderGarden(e, '/works/atamaca-garden') })
31-
</script>
3232

3333
</html>

_includes/layouts/email.njk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!doctype html>
21
<html lang="{{ metadata.language }}">
32
<head>
43
<meta charset="utf-8">

banner.html

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

content/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)