This commit is contained in:
Zach Leatherman 2024-01-14 12:32:15 +13:00
parent 6d64bd2813
commit 4c57a825da
11 changed files with 52 additions and 51 deletions

View File

@ -1,4 +1,4 @@
# eleventy-base-blog v8 # eleventy-base-blog v9
A starter repository showing how to build a blog with the [Eleventy](https://www.11ty.dev/) site generator (using the [v2.0 release](https://www.11ty.dev/blog/eleventy-v2/)). A starter repository showing how to build a blog with the [Eleventy](https://www.11ty.dev/) site generator (using the [v2.0 release](https://www.11ty.dev/blog/eleventy-v2/)).

View File

@ -1,5 +1,5 @@
export default { export default {
title: "Eleventy Base Blog v8", title: "Eleventy Base Blog v9",
url: "https://example.com/", url: "https://example.com/",
language: "en", language: "en",
description: "I am writing about my experiences as a naval navel-gazer.", description: "I am writing about my experiences as a naval navel-gazer.",

View File

@ -7,8 +7,8 @@
<meta name="description" content="{{ description or metadata.description }}"> <meta name="description" content="{{ description or metadata.description }}">
{#- Atom and JSON feeds included by default #} {#- Atom and JSON feeds included by default #}
<link rel="alternate" href="/feed/feed.xml" type="application/atom+xml" title="{{ metadata.title }}"> <link rel="alternate" href="feed/feed.njk" type="application/atom+xml" title="{{ metadata.title }}">
<link rel="alternate" href="/feed/feed.json" type="application/json" title="{{ metadata.title }}"> <link rel="alternate" href="feed/json.njk" type="application/json" title="{{ metadata.title }}">
{#- Uncomment this if youd like folks to know that you used Eleventy to build your site! #} {#- Uncomment this if youd like folks to know that you used Eleventy to build your site! #}
{#- <meta name="generator" content="{{ eleventy.generator }}"> #} {#- <meta name="generator" content="{{ eleventy.generator }}"> #}

View File

@ -5,7 +5,7 @@ eleventyExcludeFromCollections: true
--- ---
# Content not found. # Content not found.
Go <a href="/">home</a>. Go <a href="index.njk">home</a>.
<!-- <!--

View File

@ -1,6 +1,6 @@
--- ---node
title: This is a fifth post (draft) const title = "This is a fifth post (draft)";
date: 2023-01-23 const date = "2023-01-23";
draft: true const draft = true;
--- ---
This is a draft post This is a draft post

View File

@ -9,8 +9,8 @@ Leverage agile frameworks to provide a robust synopsis for high level overviews.
## Section Header ## Section Header
<a href="/blog/firstpost/">First post</a> <a href="/blog/firstpost.md">First post</a>
<a href="/blog/thirdpost/">Third post</a> <a href="blog/thirdpost.md">Third post</a>
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.

22
content/tag-pages.njk Normal file
View File

@ -0,0 +1,22 @@
---
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 }}/
---
<h1>Tagged “{{ tag }}”</h1>
{% set postslist = collections[ tag ] %}
{% include "postslist.njk" %}
<p>See <a href="tags.njk">all tags</a>.</p>

View File

@ -1,12 +0,0 @@
---
permalink: /tags/
layout: layouts/home.njk
---
<h1>Tags</h1>
<ul>
{% for tag in collections.all | getAllTags | filterTagList %}
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a></li>
{% endfor %}
</ul>

View File

@ -1,22 +1,11 @@
--- ---
pagination:
data: collections
size: 1
alias: tag
filter:
- all
- post
- posts
- tagList
addAllPagesToCollections: true
layout: layouts/home.njk layout: layouts/home.njk
eleventyComputed:
title: Tagged “{{ tag }}”
permalink: /tags/{{ tag | slugify }}/
--- ---
<h1>Tagged “{{ tag }}”</h1> <h1>Tags</h1>
{% set postslist = collections[ tag ] %} <ul>
{% include "postslist.njk" %} {% for tag in collections.all | getAllTags | filterTagList %}
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<p>See <a href="/tags/">all tags</a>.</p> <li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a></li>
{% endfor %}
</ul>

View File

@ -1,6 +1,7 @@
import { DateTime } from "luxon"; import { DateTime } from "luxon";
import markdownItAnchor from "markdown-it-anchor"; import markdownItAnchor from "markdown-it-anchor";
import { PathToUrlTransformPlugin, HtmlBasePlugin } from "@11ty/eleventy";
import pluginRss from "@11ty/eleventy-plugin-rss"; import pluginRss from "@11ty/eleventy-plugin-rss";
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import pluginBundle from "@11ty/eleventy-plugin-bundle"; import pluginBundle from "@11ty/eleventy-plugin-bundle";
@ -11,8 +12,6 @@ import pluginImages from "./eleventy.config.images.js";
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */ /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function(eleventyConfig) { export default async function(eleventyConfig) {
const { EleventyHtmlBasePlugin } = await import("@11ty/eleventy");
// Copy the contents of the `public` folder to the output folder // Copy the contents of the `public` folder to the output folder
// For example, `./public/css/` ends up in `_site/css/` // For example, `./public/css/` ends up in `_site/css/`
eleventyConfig.addPassthroughCopy({ eleventyConfig.addPassthroughCopy({
@ -36,8 +35,10 @@ export default async function(eleventyConfig) {
preAttributes: { tabindex: 0 } preAttributes: { tabindex: 0 }
}); });
eleventyConfig.addPlugin(pluginNavigation); eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(pluginBundle); eleventyConfig.addPlugin(pluginBundle);
eleventyConfig.addPlugin(HtmlBasePlugin);
eleventyConfig.addPlugin(PathToUrlTransformPlugin);
// Filters // Filters
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => { eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
@ -45,7 +46,7 @@ export default async function(eleventyConfig) {
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy"); return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
}); });
eleventyConfig.addFilter('htmlDateString', (dateObj) => { eleventyConfig.addFilter("htmlDateString", (dateObj) => {
// dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
}); });
@ -67,7 +68,7 @@ export default async function(eleventyConfig) {
return Math.min.apply(null, numbers); return Math.min.apply(null, numbers);
}); });
// Return all the tags used in a collection // Return all the tags used in any collection
eleventyConfig.addFilter("getAllTags", collection => { eleventyConfig.addFilter("getAllTags", collection => {
let tagSet = new Set(); let tagSet = new Set();
for(let item of collection) { for(let item of collection) {
@ -136,6 +137,7 @@ export default async function(eleventyConfig) {
// When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/ // When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/
// it will transform any absolute URLs in your HTML to include this // it will transform any absolute URLs in your HTML to include this
// folder name and does **not** affect where things go in the output folder. // folder name and does **not** affect where things go in the output folder.
pathPrefix: "/",
// pathPrefix: "/",
}; };
}; };

View File

@ -33,13 +33,13 @@
}, },
"homepage": "https://github.com/11ty/eleventy-base-blog#readme", "homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"devDependencies": { "devDependencies": {
"@11ty/eleventy": "^2.0.1", "@11ty/eleventy": "file:../eleventy",
"@11ty/eleventy-img": "^3.1.1", "@11ty/eleventy-img": "^3.1.8",
"@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-bundle": "^1.0.4", "@11ty/eleventy-plugin-bundle": "^1.0.5",
"@11ty/eleventy-plugin-rss": "^1.2.0", "@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"luxon": "^3.3.0", "luxon": "^3.4.4",
"markdown-it-anchor": "^8.6.7" "markdown-it-anchor": "^8.6.7"
} }
} }