diff --git a/README.md b/README.md index 2e3b478..39997b3 100644 --- a/README.md +++ b/README.md @@ -56,20 +56,20 @@ Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the - _0ms Total Blocking Time_ - Local development live reload provided by [Eleventy Dev Server](https://www.11ty.dev/docs/dev-server/). - Content-driven [navigation menu](https://www.11ty.dev/docs/plugins/navigation/) -- [Image optimization](https://www.11ty.dev/docs/plugins/image/) via the `{% image %}` shortcode. +- Fully automated [Image optimization](https://www.11ty.dev/docs/plugins/image/) - Zero-JavaScript output. - Support for modern image formats automatically (e.g. AVIF and WebP) + - Processes images on-request during `--serve` for speedy local builds. - Prefers `` markup if possible (single image format) but switches automatically to `` for multiple image formats. - Automated `` 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). - 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). + - 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. This is driven by the `eleventyExcludeFromCollections` and `permalink` computed data in the `content/blog/blog.11tydata.js` directory data file. Schema validator will show an error if non-boolean value is set in data cascade. - Automated next/previous links - Accessible deep links to headings - Generated Pages @@ -82,9 +82,10 @@ Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the ## Demos - [Netlify](https://eleventy-base-blog.netlify.com/) -- [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/) +- [Vercel](https://eleventy-base-blog-snowy.vercel.app/) ## Deploy this to your own site diff --git a/content/404.md b/content/404.md index c8be2df..358aaa1 100644 --- a/content/404.md +++ b/content/404.md @@ -1,5 +1,4 @@ --- -layout: layouts/home.njk permalink: 404.html eleventyExcludeFromCollections: true --- diff --git a/content/about/index.md b/content/about/index.md index 18367d8..673fc8d 100644 --- a/content/about/index.md +++ b/content/about/index.md @@ -1,5 +1,4 @@ --- -layout: layouts/base.njk eleventyNavigation: key: About Me order: 3 diff --git a/content/blog.njk b/content/blog.njk index c7e04d6..1f7d876 100644 --- a/content/blog.njk +++ b/content/blog.njk @@ -1,5 +1,4 @@ --- -layout: layouts/home.njk eleventyNavigation: key: Archive order: 2 diff --git a/content/blog/blog.11tydata.js b/content/blog/blog.11tydata.js index 614f505..ea58351 100644 --- a/content/blog/blog.11tydata.js +++ b/content/blog/blog.11tydata.js @@ -1,6 +1,36 @@ +import { z } from "zod"; +import { fromZodError } from 'zod-validation-error'; + export default { tags: [ "posts" ], "layout": "layouts/post.njk", + eleventyDataSchema: function(data) { + let result = z.object({ + draft: z.boolean().or(z.undefined()), + }).safeParse(data); + + if(result.error) { + throw fromZodError(result.error); + } + }, + eleventyComputed: { + permalink: (data) => { + // Always skip during non-watch/serve builds + if(data.draft && process.env.ELEVENTY_RUN_MODE === "build") { + return false; + } + + return data.permalink; + }, + eleventyExcludeFromCollections: (data) => { + // Always exclude from non-watch/serve builds + if(data.draft && process.env.ELEVENTY_RUN_MODE === "build") { + return true; + } + + return data.eleventyExcludeFromCollections; + } + } }; diff --git a/content/content.11tydata.js b/content/content.11tydata.js new file mode 100644 index 0000000..8b0bb8e --- /dev/null +++ b/content/content.11tydata.js @@ -0,0 +1,3 @@ +export default { + layout: "layouts/home.njk", +}; diff --git a/content/feed/feed.11tydata.js b/content/feed/feed.11tydata.js index 42ad826..3c76e38 100644 --- a/content/feed/feed.11tydata.js +++ b/content/feed/feed.11tydata.js @@ -1,3 +1,3 @@ export default { - eleventyExcludeFromCollections: true -} + layout: false, +}; diff --git a/content/feed/feed.njk b/content/feed/feed.njk index a47a7e8..f3539e7 100755 --- a/content/feed/feed.njk +++ b/content/feed/feed.njk @@ -1,6 +1,9 @@ --- # Metadata comes from _data/metadata.js permalink: /feed/feed.xml +eleventyNavigation: + key: Feed + order: 3 --- diff --git a/content/index.njk b/content/index.njk index 9d3430a..260b20c 100644 --- a/content/index.njk +++ b/content/index.njk @@ -1,5 +1,4 @@ --- -layout: layouts/home.njk eleventyNavigation: key: Home order: 1 diff --git a/content/sitemap/sitemap.xml.njk b/content/sitemap.xml.njk similarity index 96% rename from content/sitemap/sitemap.xml.njk rename to content/sitemap.xml.njk index 4da684a..ec1716d 100644 --- a/content/sitemap/sitemap.xml.njk +++ b/content/sitemap.xml.njk @@ -1,5 +1,6 @@ --- permalink: /sitemap.xml +layout: false eleventyExcludeFromCollections: true --- diff --git a/content/tag-pages.njk b/content/tag-pages.njk index e5a5f70..9533be9 100644 --- a/content/tag-pages.njk +++ b/content/tag-pages.njk @@ -1,18 +1,19 @@ ---- -pagination: - data: collections - size: 1 - alias: tag - filter: - - all - - post - - posts - - tagList - addAllPagesToCollections: true -layout: layouts/home.njk -eleventyComputed: - title: Tagged “{{ tag }}” -permalink: /tags/{{ tag | slugify }}/ +---node +//