Using deep data merge (post tag is inherited from posts/posts.json) and updates to use 0.7.0.
This commit is contained in:
parent
0cb6dab28a
commit
496982355e
18
.eleventy.js
18
.eleventy.js
@ -5,6 +5,7 @@ const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
|
|||||||
module.exports = function(eleventyConfig) {
|
module.exports = function(eleventyConfig) {
|
||||||
eleventyConfig.addPlugin(pluginRss);
|
eleventyConfig.addPlugin(pluginRss);
|
||||||
eleventyConfig.addPlugin(pluginSyntaxHighlight);
|
eleventyConfig.addPlugin(pluginSyntaxHighlight);
|
||||||
|
eleventyConfig.setDataDeepMerge(true);
|
||||||
|
|
||||||
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
|
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
|
||||||
|
|
||||||
@ -12,6 +13,11 @@ module.exports = function(eleventyConfig) {
|
|||||||
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL yyyy");
|
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL yyyy");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
|
||||||
|
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
|
||||||
|
return DateTime.fromJSDate(dateObj).toFormat('yyyy-LL-dd');
|
||||||
|
});
|
||||||
|
|
||||||
// Get the first `n` elements of a collection.
|
// Get the first `n` elements of a collection.
|
||||||
eleventyConfig.addFilter("head", (array, n) => {
|
eleventyConfig.addFilter("head", (array, n) => {
|
||||||
if( n < 0 ) {
|
if( n < 0 ) {
|
||||||
@ -21,18 +27,6 @@ module.exports = function(eleventyConfig) {
|
|||||||
return array.slice(0, n);
|
return array.slice(0, n);
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
|
|
||||||
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
|
|
||||||
return DateTime.fromJSDate(dateObj).toFormat('yyyy-LL-dd');
|
|
||||||
});
|
|
||||||
|
|
||||||
// only content in the `posts/` directory
|
|
||||||
eleventyConfig.addCollection("posts", function(collection) {
|
|
||||||
return collection.getFilteredByGlob("./posts/*").sort(function(a, b) {
|
|
||||||
return a.date - b.date;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
eleventyConfig.addCollection("tagList", require("./_11ty/getTagList"));
|
eleventyConfig.addCollection("tagList", require("./_11ty/getTagList"));
|
||||||
|
|
||||||
eleventyConfig.addPassthroughCopy("img");
|
eleventyConfig.addPassthroughCopy("img");
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
module.exports = function(collection) {
|
module.exports = function(collection) {
|
||||||
let tagSet = new Set();
|
let tagSet = new Set();
|
||||||
collection.getAllSorted().forEach(function(item) {
|
collection.getAll().forEach(function(item) {
|
||||||
if( "tags" in item.data ) {
|
if( "tags" in item.data ) {
|
||||||
let tags = item.data.tags;
|
let tags = item.data.tags;
|
||||||
if( typeof tags === "string" ) {
|
|
||||||
tags = [tags];
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = tags.filter(function(item) {
|
tags = tags.filter(function(item) {
|
||||||
switch(item) {
|
switch(item) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "Your Blog Name",
|
"title": "Your Blog Name",
|
||||||
"url": "https://myurl.com/",
|
"url": "https://myurl.com/",
|
||||||
|
"description": "I am writing about my experiences as a naval navel-gazer.",
|
||||||
"feed": {
|
"feed": {
|
||||||
"subtitle": "I am writing about my experiences as a naval navel-gazer.",
|
"subtitle": "I am writing about my experiences as a naval navel-gazer.",
|
||||||
"filename": "feed.xml",
|
"filename": "feed.xml",
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{ renderData.title or title or metadata.title }}</title>
|
<title>{{ renderData.title or title or metadata.title }}</title>
|
||||||
|
<meta name="Description" content="{{ renderData.description or description or metadata.description }}">
|
||||||
<link rel="stylesheet" href="{{ '/css/index.css' | url }}">
|
<link rel="stylesheet" href="{{ '/css/index.css' | url }}">
|
||||||
<link rel="stylesheet" href="{{ '/css/prism-base16-monokai.dark.css' | url }}">
|
<link rel="stylesheet" href="{{ '/css/prism-base16-monokai.dark.css' | url }}">
|
||||||
<link rel="alternate" href="{{ metadata.feed.path | url }}" type="application/atom+xml" title="{{ metadata.title }}">
|
<link rel="alternate" href="{{ metadata.feed.path | url }}" type="application/atom+xml" title="{{ metadata.title }}">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<a href="{{ post.url | url }}" class="postlist-link">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a>
|
<a href="{{ post.url | url }}" class="postlist-link">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a>
|
||||||
<time class="postlist-date" datetime="{{ post.date | htmlDateString }}">{{ post.date | readableDate }}</time>
|
<time class="postlist-date" datetime="{{ post.date | htmlDateString }}">{{ post.date | readableDate }}</time>
|
||||||
{% for tag in post.data.tags %}
|
{% for tag in post.data.tags %}
|
||||||
{%- if tag != "post" -%}
|
{%- if tag != "posts" -%}
|
||||||
{% set tagUrl %}/tags/{{ tag }}/{% endset %}
|
{% set tagUrl %}/tags/{{ tag }}/{% endset %}
|
||||||
<a href="{{ tagUrl | url }}" class="tag">{{ tag }}</a>
|
<a href="{{ tagUrl | url }}" class="tag">{{ tag }}</a>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
|
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@11ty/eleventy": "^0.5.4",
|
"@11ty/eleventy": "^0.7.0",
|
||||||
"@11ty/eleventy-plugin-rss": "^1.0.3",
|
"@11ty/eleventy-plugin-rss": "^1.0.3",
|
||||||
"@11ty/eleventy-plugin-syntaxhighlight": "^2.0.0",
|
"@11ty/eleventy-plugin-syntaxhighlight": "^2.0.0",
|
||||||
"luxon": "^1.0.0",
|
"luxon": "^1.0.0",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: This is my first post.
|
title: This is my first post.
|
||||||
|
description: This is a post on My Blog about agile frameworks.
|
||||||
date: 2018-05-01
|
date: 2018-05-01
|
||||||
tags:
|
tags:
|
||||||
- post
|
|
||||||
- another-tag
|
- another-tag
|
||||||
layout: layouts/post.njk
|
layout: layouts/post.njk
|
||||||
---
|
---
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: This is my fourth post.
|
title: This is my fourth post.
|
||||||
|
description: This is a post on My Blog about touchpoints and circling wagons.
|
||||||
date: 2018-09-30
|
date: 2018-09-30
|
||||||
tags: second-tag
|
tags: second-tag
|
||||||
layout: layouts/post.njk
|
layout: layouts/post.njk
|
||||||
|
5
posts/posts.json
Normal file
5
posts/posts.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"tags": [
|
||||||
|
"posts"
|
||||||
|
]
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: This is my second post.
|
title: This is my second post.
|
||||||
|
description: This is a post on My Blog about leveraging agile frameworks.
|
||||||
date: 2018-07-04
|
date: 2018-07-04
|
||||||
tags:
|
tags:
|
||||||
- post
|
|
||||||
- number-2
|
- number-2
|
||||||
layout: layouts/post.njk
|
layout: layouts/post.njk
|
||||||
---
|
---
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: This is my third post.
|
title: This is my third post.
|
||||||
|
description: This is a post on My Blog about win-win survival strategies.
|
||||||
date: 2018-08-24
|
date: 2018-08-24
|
||||||
tags:
|
tags:
|
||||||
- post
|
|
||||||
- second-tag
|
- second-tag
|
||||||
layout: layouts/post.njk
|
layout: layouts/post.njk
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user