` syntax markup with `srcset` and optional `sizes`
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
- Includes `loading="lazy"` for native lazy loading without JavaScript.
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
- Images can be co-located with blog post files.
- - View the [Image plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.images.js)
- Per page CSS bundles [via `eleventy-plugin-bundle`](https://github.com/11ty/eleventy-plugin-bundle).
- Built-in [syntax highlighter](https://www.11ty.dev/docs/plugins/syntaxhighlight/) (zero-JavaScript output).
+- 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.
- Blog Posts
- - Draft posts: use `draft: true` to mark a blog post as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. View the [Drafts plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.drafts.js).
- Automated next/previous links
- Accessible deep links to headings
- Generated Pages
- Home, Archive, and About pages.
- - [Feeds for Atom and JSON](https://www.11ty.dev/docs/plugins/rss/)
+ - [Atom feed included (with easy one-line swap to use RSS or JSON](https://www.11ty.dev/docs/plugins/rss/)
- `sitemap.xml`
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
- Content not found (404) page
@@ -83,20 +82,19 @@ Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the
- [Netlify](https://eleventy-base-blog.netlify.app/)
- [Vercel](https://demo-base-blog.11ty.dev/)
-- [GitHub Pages](https://11ty.github.io/eleventy-base-blog/)
- [Remix on Glitch](https://glitch.com/~11ty-eleventy-base-blog)
- [Cloudflare Pages](https://eleventy-base-blog-d2a.pages.dev/)
+- [GitHub Pages](https://11ty.github.io/eleventy-base-blog/)
## Deploy this to your own site
Deploy this Eleventy site in just a few clicks on these services:
+- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
- [Deploy this to **Netlify**](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog)
- [Deploy this to **Vercel**](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog)
- Look in `.github/workflows/gh-pages.yml.sample` for information on Deploying to **GitHub Pages**.
- [Try it out on **Stackblitz**](https://stackblitz.com/github/11ty/eleventy-base-blog)
-- If you run Eleventy locally you can drag your `_site` folder to [`netlify.com/drop`](https://netlify.com/drop) to upload it without using `git`.
-- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
### Implementation Notes
@@ -105,9 +103,6 @@ Deploy this Eleventy site in just a few clicks on these services:
- 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`.
- 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`.
- 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.
-- Provides two content feeds:
- - `content/feed/feed.njk`
- - `content/feed/json.njk`
- This project uses three [Eleventy Layouts](https://www.11ty.dev/docs/layouts/):
- `_includes/layouts/base.njk`: the top level HTML structure
- `_includes/layouts/home.njk`: the home page template (wrapped into `base.njk`)
diff --git a/_config/filters.js b/_config/filters.js
new file mode 100644
index 0000000..4af2fe8
--- /dev/null
+++ b/_config/filters.js
@@ -0,0 +1,40 @@
+import { DateTime } from "luxon";
+
+export default function(eleventyConfig) {
+ eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
+ // Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
+ return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
+ });
+
+ eleventyConfig.addFilter("htmlDateString", (dateObj) => {
+ // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
+ return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat('yyyy-LL-dd');
+ });
+
+ // Get the first `n` elements of a collection.
+ eleventyConfig.addFilter("head", (array, n) => {
+ if(!Array.isArray(array) || array.length === 0) {
+ return [];
+ }
+ if( n < 0 ) {
+ return array.slice(n);
+ }
+
+ return array.slice(0, n);
+ });
+
+ // Return the smallest number argument
+ eleventyConfig.addFilter("min", (...numbers) => {
+ return Math.min.apply(null, numbers);
+ });
+
+ // Return the keys used in an object
+ eleventyConfig.addFilter("getKeys", target => {
+ return Object.keys(target);
+ });
+
+ eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
+ return (tags || []).filter(tag => ["all", "posts"].indexOf(tag) === -1);
+ });
+
+};
diff --git a/_data/eleventyDataSchema.js b/_data/eleventyDataSchema.js
new file mode 100644
index 0000000..ca764ec
--- /dev/null
+++ b/_data/eleventyDataSchema.js
@@ -0,0 +1,13 @@
+import { z } from "zod";
+import { fromZodError } from 'zod-validation-error';
+
+export default function(data) {
+ // Draft content, validate `draft` front matter
+ let result = z.object({
+ draft: z.boolean().or(z.undefined()),
+ }).safeParse(data);
+
+ if(result.error) {
+ throw fromZodError(result.error);
+ }
+}
diff --git a/_data/metadata.js b/_data/metadata.js
index 5a5c99b..7e8b636 100644
--- a/_data/metadata.js
+++ b/_data/metadata.js
@@ -1,5 +1,5 @@
-module.exports = {
- title: "Eleventy Base Blog v8",
+export default {
+ title: "Eleventy Base Blog v9",
url: "https://example.com/",
language: "en",
description: "I am writing about my experiences as a naval navel-gazer.",
diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk
index ae7f5bd..57a29a2 100644
--- a/_includes/layouts/base.njk
+++ b/_includes/layouts/base.njk
@@ -5,33 +5,36 @@
{{ title or metadata.title }}
-
- {#- Atom and JSON feeds included by default #}
-
-
+
{#- Uncomment this if you’d like folks to know that you used Eleventy to build your site! #}
{#- #}
{#-
- CSS bundles are provided via the `eleventy-plugin-bundle` plugin:
- 1. You can add to them using `{% css %}`
- 2. You can get from them using `{% getBundle "css" %}` or `{% getBundleFileUrl "css" %}`
- 3. You can do the same for JS: {% js %}{% endjs %} and
- 4. Learn more: https://github.com/11ty/eleventy-plugin-bundle
+ Plain-text bundles are provided via the `eleventy-plugin-bundle` plugin:
+ 1. CSS:
+ * Add to a per-page bundle using `{% css %}{% endcss %}`
+ * Retrieve bundle content using `{% getBundle "css" %}` or `{% getBundleFileUrl "css" %}`
+ 2. Or for JavaScript:
+ * Add to a per-page bundle using `{% js %}{% endjs %}`
+ * Retrieve via `{% getBundle "js" %}` or `{% getBundleFileUrl "js" %}`
+ 3. Learn more: https://github.com/11ty/eleventy-plugin-bundle
#}
{#- Add an arbitrary string to the bundle #}
- {%- css %}* { box-sizing: border-box; }{% endcss %}
+ {%- css %}/* This is an arbitrary CSS string added to the bundle */{% endcss %}
{#- Add the contents of a file to the bundle #}
{%- css %}{% include "public/css/index.css" %}{% endcss %}
- {#- Or add from node_modules #}
+ {#- Or you can add from node_modules #}
{# {%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %} #}
- {#- Render the CSS bundle using Inlined CSS (for the fastest site performance in production) #}
+ {#- Render the CSS bundle using inlined CSS (for the fastest site performance in production) #}
{#- Renders the CSS bundle using a separate file, if you can't set CSP directive style-src: 'unsafe-inline' #}
{#- #}
+
+ {#- Add the heading-anchors web component to the JavaScript bundle #}
+ {%- js %}{% include "node_modules/@zachleat/heading-anchors/heading-anchors.js" %}{% endjs %}
Skip to main content
@@ -51,11 +54,16 @@
- {{ content | safe }}
+
+ {{ content | safe }}
+
-
+
+