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/)).

View File

@ -1,5 +1,5 @@
export default {
title: "Eleventy Base Blog v8",
title: "Eleventy Base Blog v9",
url: "https://example.com/",
language: "en",
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 }}">
{#- 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.json" type="application/json" title="{{ metadata.title }}">
<link rel="alternate" href="feed/feed.njk" type="application/atom+xml" 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! #}
{#- <meta name="generator" content="{{ eleventy.generator }}"> #}

View File

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

View File

@ -1,6 +1,6 @@
---
title: This is a fifth post (draft)
date: 2023-01-23
draft: true
---node
const title = "This is a fifth post (draft)";
const date = "2023-01-23";
const draft = true;
---
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
<a href="/blog/firstpost/">First post</a>
<a href="/blog/thirdpost/">Third post</a>
<a href="/blog/firstpost.md">First 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.

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
eleventyComputed:
title: Tagged “{{ tag }}”
permalink: /tags/{{ tag | slugify }}/
---
<h1>Tagged “{{ tag }}”</h1>
<h1>Tags</h1>
{% set postslist = collections[ tag ] %}
{% include "postslist.njk" %}
<p>See <a href="/tags/">all tags</a>.</p>
<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,6 +1,7 @@
import { DateTime } from "luxon";
import markdownItAnchor from "markdown-it-anchor";
import { PathToUrlTransformPlugin, HtmlBasePlugin } from "@11ty/eleventy";
import pluginRss from "@11ty/eleventy-plugin-rss";
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import pluginBundle from "@11ty/eleventy-plugin-bundle";
@ -11,8 +12,6 @@ import pluginImages from "./eleventy.config.images.js";
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function(eleventyConfig) {
const { EleventyHtmlBasePlugin } = await import("@11ty/eleventy");
// Copy the contents of the `public` folder to the output folder
// For example, `./public/css/` ends up in `_site/css/`
eleventyConfig.addPassthroughCopy({
@ -36,8 +35,10 @@ export default async function(eleventyConfig) {
preAttributes: { tabindex: 0 }
});
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(pluginBundle);
eleventyConfig.addPlugin(HtmlBasePlugin);
eleventyConfig.addPlugin(PathToUrlTransformPlugin);
// Filters
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");
});
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
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');
});
@ -67,7 +68,7 @@ export default async function(eleventyConfig) {
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 => {
let tagSet = new Set();
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/
// 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.
pathPrefix: "/",
// pathPrefix: "/",
};
};

View File

@ -33,13 +33,13 @@
},
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-img": "^3.1.1",
"@11ty/eleventy": "file:../eleventy",
"@11ty/eleventy-img": "^3.1.8",
"@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-syntaxhighlight": "^5.0.0",
"luxon": "^3.3.0",
"luxon": "^3.4.4",
"markdown-it-anchor": "^8.6.7"
}
}