Cleaned up v2.0 status

This commit is contained in:
Zach Leatherman 2023-01-23 10:02:06 -06:00
parent 00f82812d0
commit 65feb1c686
30 changed files with 116 additions and 278 deletions

View File

@ -1,5 +1,5 @@
---
layout: layouts/home.webc
layout: layouts/home.njk
permalink: 404.html
eleventyExcludeFromCollections: true
---

View File

@ -1,6 +1,6 @@
# eleventy-base-blog
A starter repository showing how to build a (multi-language friendly) blog with the [Eleventy](https://github.com/11ty/eleventy) static site generator.
A starter repository showing how to build a blog with the [Eleventy](https://github.com/11ty/eleventy) site generator.
[![Build Status](https://travis-ci.org/11ty/eleventy-base-blog.svg?branch=master)](https://travis-ci.org/11ty/eleventy-base-blog)
@ -33,7 +33,7 @@ git clone https://github.com/11ty/eleventy-base-blog.git my-blog-name
cd my-blog-name
```
Specifically have a look at `.eleventy.js` to see if you want to configure any Eleventy options differently.
Specifically have a look at `eleventy.config.js` to see if you want to configure any Eleventy options differently.
### 3. Install dependencies
@ -63,14 +63,12 @@ DEBUG=Eleventy* npx @11ty/eleventy
### Implementation Notes
- `en` is the folder for content (written using the primary language for project, here were using English)
- `en/about/index.md` is an example of an English content page.
- `en/blog/` has the English blog posts but really they can live in any directory. They need only the `post` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
- To localize a blog post you will need to add a top level folder for that language (`es` for Spanish, `ja` for Japanese, `en-us` for American English) and match the rest of the file path to the primary language folder. For example `en/blog/my-post.md` could have `ja/blog/my-post.md` or `es/blog/my-post.md`. Read more about [best practices for organizing files for internationalization (i18n) in Eleventy projects](https://www.11ty.dev/docs/i18n/).
- Use the `eleventyNavigation` key in your front matter to add a template to the top level site navigation. For example, this is in use on `index.njk` and `about/index.md`.
- `about/index.md` is an example of a content page.
- `blog/` has the blog posts but really they can live in any directory. They need only the `post` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
- Use the `eleventyNavigation` key in your front matter to add a template to the top level site navigation. This is in use on `index.njk` and `about/index.md`.
- This makes use of the [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/)
- Content can be any template format (blog posts neednt be markdown, for example). Configure your supported templates in `.eleventy.js` -> `templateFormats`.
- The `public` folder in your input directory will be copied to the output folder (via `addPassthroughCopy()` in the `.eleventy.js` file). This means `./public/css/*` will live at `./_site/css/*` after your build completes. [When using `--serve` this behavior is emulated](/docs/copy/#passthrough-during-serve) (the files will not show up in `_site`).
- Content can be any template format (blog posts neednt be markdown, for example). Configure your 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.
- The blog post feed template is in `feed/feed.njk`. This is also a good example of using a global data files in that it uses `_data/metadata.json`.
- This project uses three layouts:
- `_includes/layouts/base.njk`: the top level HTML structure

View File

@ -1,24 +0,0 @@
<div class="infobox">
<slot></slot>
</div>
<style>
/* Infobox */
:root {
--color-infobox: #ffc;
}
@media (prefers-color-scheme: dark) {
:root {
--color-infobox: #082840;
}
}
.infobox {
background-color: var(--color-infobox);
color: var(--color-gray-90);
padding: 1em 0.625em; /* 16px 10px /16 */
}
.infobox ol:only-child {
margin: 0;
}
</style>

View File

@ -1,5 +0,0 @@
<link rel="stylesheet" href="../../../node_modules/prismjs/themes/prism-okaidia.css">
<link rel="stylesheet" href="./prism-diff.css">
```<template @html="this.syntax || ''" webc:nokeep></template>
<slot></slot>
```

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="{{ lang or metadata.language }}">
<html lang="{{ metadata.language }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -10,34 +10,27 @@
{#- <meta name="generator" content="{{ eleventy.generator }}"> #}
<link rel="stylesheet" href="/css/index.css">
<style>
{{ page.url | webcGetCss | safe }}
</style>
<link rel="stylesheet" href="/css/prism-okaidia.css">
<link rel="stylesheet" href="/css/prism-diff.css">
<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 }}">
{%- set alternateUrls = page.url | locale_links %}
{% if alternateUrls.length %}
<link rel="alternate" hreflang="{{ lang or metadata.language }}" href="{{ page.url | htmlBaseUrl(metadata.url) }}">
{%- for link in alternateUrls %}
<link rel="alternate" hreflang="{{ link.lang }}" href="{{ link.url | htmlBaseUrl(metadata.url) }}">
{%- endfor %}
{%- endif %}
</head>
<body>
<header>
<h1 class="home"><a href="/">{{ metadata.title }}</a></h1>
{#- Read more about `eleventy-navigation` at https://www.11ty.dev/docs/plugins/navigation/ #}
<ul class="nav">
{%- for entry in collections.all | eleventyNavigation %}
<li class="nav-item{% if entry.url == page.url %} nav-item-active{% endif %}"><a href="{{ entry.url }}">{{ entry.title | i18n }}</a></li>
{%- endfor %}
</ul>
</header>
<nav>
<ul class="nav">
{%- for entry in collections.all | eleventyNavigation %}
<li class="nav-item"><a href="{{ entry.url }}"{% if entry.url == page.url %} aria-current="page"{% endif %}>{{ entry.title }}</a></li>
{%- endfor %}
</ul>
</nav>
</header>
<main{% if templateClass %} class="{{ templateClass }}"{% endif %}>
<main>
{{ content | safe }}
</main>

View File

@ -1,16 +1,16 @@
---
layout: layouts/base.njk
templateClass: tmpl-home
---
<!-- Delete this message -->
<infobox>
<div class="message-box">
<link rel="stylesheet" href="/css/message-box.css">
<ol>
<li>Edit the <code>_data/metadata.json</code> with your blogs information.</li>
<li>(Optional) Edit <code>.eleventy.js</code> with your <a href="https://www.11ty.dev/docs/config/">configuration preferences</a>.</li>
<li>Delete this message from <code>_includes/layouts/home.webc</code>.</li>
<li>(Optional) Edit <code>eleventy.config.js</code> with your <a href="https://www.11ty.dev/docs/config/">configuration preferences</a>.</li>
<li>Delete this message from <code>_includes/layouts/home.njk</code>.</li>
</ol>
<p><em>This is an <a href="https://www.11ty.dev/">Eleventy project</a> created from the <a href="https://github.com/11ty/eleventy-base-blog"><code>eleventy-base-blog</code> repo</a>.</em></p>
</infobox>
</div>
<!-- Stop deleting -->
<template @raw="content" webc:nokeep></template>
{{ content | safe }}

View File

@ -1,6 +1,5 @@
---
layout: layouts/base.njk
templateClass: tmpl-post
---
<h1>{{ title }}</h1>
@ -16,27 +15,13 @@ templateClass: tmpl-post
<hr>
{% set i18nLinks = page.url | locale_links %}
{% if i18nLinks.length %}
<ul>
<li>
{{ "i18n.also" | i18n }}
{%- for link in i18nLinks %}
<a href="{{ link.url }}" lang="{{ link.lang }}" hreflang="{{ link.lang }}">{{ link.label }}</a>
{%- if not loop.last %},{% endif %}
{%- endfor -%}
</li>
</ul>
{% endif %}
{%- if collections.posts %}
{# these filters are locale-aware in 2.0.0-canary.14 #}
{%- set previousPost = collections.posts | getPreviousCollectionItem %}
{%- set nextPost = collections.posts | getNextCollectionItem %}
{%- if nextPost or previousPost %}
<ul>
{%- if previousPost %}<li>{{ "i18n.previous" | i18n }}: <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
{%- if nextPost %}<li>{{ "i18n.next" | i18n }}: <a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
{%- if previousPost %}<li>Previous: <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
{%- if nextPost %}<li>Next: <a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
</ul>
{%- endif %}
{%- endif %}

9
about/index.md Normal file
View File

@ -0,0 +1,9 @@
---
layout: layouts/base.njk
eleventyNavigation:
key: About Me
order: 3
---
# About Me
I am a person that writes stuff.

View File

@ -1,10 +1,9 @@
---
layout: layouts/home.webc
layout: layouts/home.njk
eleventyNavigation:
key: nav.archive
key: Archive
order: 2
---
<h1>Archive</h1>
{% set postslist = collections.posts %}

View File

@ -9,13 +9,11 @@ Leverage agile frameworks to provide a robust synopsis for high level overviews.
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.
{{ "/" | locale_url }}
## Section Header
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
<script webc:is="syntax-highlight" @syntax="diff-js">
```diff-js
// this is a command
function myCommand() {
+ let counter = 0;
@ -25,4 +23,4 @@ Capitalize on low hanging fruit to identify a ballpark value added activity to b
// Test with a line break above this line.
console.log('Test');
</script>
```

View File

@ -8,7 +8,7 @@ tags:
---
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
<script webc:is="syntax-highlight" @syntax="js">
```js
// this is a command
function myCommand() {
let counter = 0;
@ -17,7 +17,7 @@ function myCommand() {
// Test with a line break above this line.
console.log('Test');
</script>
```
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.

View File

@ -1,19 +1,10 @@
const { DateTime } = require("luxon");
const rosetta = require("rosetta");
const markdownItAnchor = require("markdown-it-anchor");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginNavigation = require("@11ty/eleventy-navigation");
const pluginWebc = require("@11ty/eleventy-plugin-webc");
const {
EleventyRenderPlugin,
EleventyI18nPlugin,
EleventyHtmlBasePlugin
} = require("@11ty/eleventy");
const languageStrings = require("./i18n.js");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
module.exports = function(eleventyConfig) {
eleventyConfig.ignores.add("README.md");
@ -22,23 +13,18 @@ module.exports = function(eleventyConfig) {
// For example, `./public/css/` ends up in `_site/css/`
eleventyConfig.addPassthroughCopy({
"./public/": "/",
"./node_modules/prismjs/themes/prism-okaidia.css": "/css/prism-okaidia.css"
});
// If your passthrough copy gets heavy and cumbersome, add this line
// to emulate the file copy on the dev server. Learn more: https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve
// eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
// Add plugins
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginSyntaxHighlight);
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(pluginWebc, {
components: "./_includes/components/**/*.webc"
});
eleventyConfig.addPlugin(EleventyI18nPlugin, {
defaultLanguage: "en",
errorMode: "allow-fallback",
});
eleventyConfig.addFilter("readableDate", (dateObj, format = "dd LLLL yyyy") => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(format);
@ -79,7 +65,7 @@ module.exports = function(eleventyConfig) {
return (tags || []).filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1);
});
// Customize Markdown library and settings:
// Customize Markdown library settings:
eleventyConfig.amendLibrary("md", mdLib => {
mdLib.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.ariaHidden({
@ -88,28 +74,10 @@ module.exports = function(eleventyConfig) {
symbol: "#",
}),
level: [1,2,3,4],
slugify: eleventyConfig.getFilter("slug")
slugify: eleventyConfig.getFilter("slugify")
});
});
// Override @11ty/eleventy-dev-server defaults (used only with --serve)
eleventyConfig.setServerOptions({
showVersion: true,
});
// i18n filter using Rosetta
const rosettaLib = rosetta(languageStrings);
eleventyConfig.addFilter("i18n", function (key, lang) {
const I18N_PREFIX = "i18n.";
if(key.startsWith(I18N_PREFIX)) {
key = key.slice(I18N_PREFIX.length);
}
// depends on page.lang in 2.0.0-canary.14+
let page = this.page || this.ctx?.page || this.context?.environments?.page || {};
return rosettaLib.t(key, {}, lang || page.lang);
});
return {
// Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid
@ -126,20 +94,6 @@ module.exports = function(eleventyConfig) {
// Pre-process *.html files with: (default: `liquid`)
htmlTemplateEngine: "njk",
// -----------------------------------------------------------------
// If your site deploys to a subdirectory, change `pathPrefix`.
// Dont worry about leading and trailing slashes, we normalize these.
// If you dont have a subdirectory, use "" or "/" (they do the same thing)
// This is only used for link URLs (it does not affect your file structure)
// Best paired with the `url` filter: https://www.11ty.dev/docs/filters/url/
// You can also pass this in on the command line using `--pathprefix`
// Optional (default is shown)
pathPrefix: "/",
// -----------------------------------------------------------------
// These are all optional (defaults are shown):
dir: {
input: ".",
@ -147,5 +101,19 @@ module.exports = function(eleventyConfig) {
data: "_data",
output: "_site"
}
// -----------------------------------------------------------------
// Optional:
// If your site deploys to a subdirectory, change `pathPrefix`.
// Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix
// 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.
// Optional (default is shown)
// pathPrefix: "/",
// -----------------------------------------------------------------
};
};

View File

@ -1,11 +0,0 @@
---
layout: layouts/base.njk
title: About Me
templateClass: tmpl-post
eleventyNavigation:
key: nav.about
order: 3
---
# <span @html="this.title" webc:nokeep></span>
I am a person that writes stuff.

View File

@ -1,11 +0,0 @@
module.exports = {
lang: "en",
permalink: function(data) {
// Change (English) /en/blog/my-post URLs to have an implied language code /blog/my-post URLs instead.
let [slashPrefixEmpty, langCode, ...stem] = data.page.filePathStem.split("/");
let path = stem.join("/");
// Account for `permalink: 404.html` style
return stem[stem.length - 1] === "index" ? `${path}.html` : `${path}/index.html`;
}
}

View File

@ -1,22 +0,0 @@
---
layout: layouts/home.webc
eleventyNavigation:
key: i18n.nav.home
order: 1
---
{% set maxPosts = collections.posts.length | min(3) %}
<h1>Latest {% if maxPosts == 1 %}Post{% else %}{{ maxPosts }} Posts{% endif %}</h1>
{% set postslist = collections.posts | head(-3) %}
{% set postslistCounter = collections.posts | length %}
{% include "postslist.njk" %}
<p>More posts can be found in <a href="/blog/">the archive</a>.</p>
{# List all of the pages in the project
<ul>
{%- for entry in collections.all %}
<li><a href="{{ entry.url }}"><code>{{ entry.url }}</code></a></li>
{%- endfor %}
</ul>
#}

View File

@ -1,14 +0,0 @@
---
title: Esta es mi cuarta publicación.
slugOverride: cuarta publicación
date: 2018-09-30
layout: layouts/post.njk
---
Aproveche los marcos ágiles para proporcionar una sinopsis sólida para descripciones generales de alto nivel. Los enfoques iterativos de la estrategia corporativa fomentan el pensamiento colaborativo para promover la propuesta de valor general. Hacer crecer orgánicamente la visión holística del mundo de la innovación disruptiva a través de la diversidad y el empoderamiento en el lugar de trabajo.
Traiga a la mesa estrategias de supervivencia de ganar-ganar para asegurar una dominación proactiva. Al final del día, en el futuro, una nueva normalidad que ha evolucionado desde la generación X está en camino hacia una solución de nube optimizada. El contenido generado por el usuario en tiempo real tendrá múltiples puntos de contacto para la deslocalización.
## Encabezado de sección
Saque provecho de la fruta al alcance de la mano para identificar una actividad de valor agregado de estadio de béisbol para la prueba beta. Supere la brecha digital con clics adicionales de DevOps. La inmersión en nanotecnología a lo largo de la autopista de la información cerrará el círculo centrándose únicamente en el resultado final.

View File

@ -1,24 +0,0 @@
---
title: Esta es mi tercer publicación.
date: 2018-09-30
layout: layouts/post.njk
---
Aproveche los marcos ágiles para proporcionar una sinopsis sólida para descripciones generales de alto nivel. Los enfoques iterativos de la estrategia corporativa fomentan el pensamiento colaborativo para promover la propuesta de valor general. Hacer crecer orgánicamente la visión holística del mundo de la innovación disruptiva a través de la diversidad y el empoderamiento en el lugar de trabajo.
```js
// this is a command
function myCommand() {
let counter = 0;
counter++;
}
// Test with a line break above this line.
console.log('Test');
```
Traiga a la mesa estrategias de supervivencia de ganar-ganar para asegurar una dominación proactiva. Al final del día, en el futuro, una nueva normalidad que ha evolucionado desde la generación X está en camino hacia una solución de nube optimizada. El contenido generado por el usuario en tiempo real tendrá múltiples puntos de contacto para la deslocalización.
## Encabezado de sección
Saque provecho de la fruta al alcance de la mano para identificar una actividad de valor agregado de estadio de béisbol para la prueba beta. Supere la brecha digital con clics adicionales de DevOps. La inmersión en nanotecnología a lo largo de la autopista de la información cerrará el círculo centrándose únicamente en el resultado final.

View File

@ -1,11 +0,0 @@
module.exports = {
"lang": "es",
"permalink": function(data) {
// Slug override is set in the post for localized URL slugs
// e.g. /es/blog/fourthpost.md will optionally write to
// /es/blog/cuarta-publicacion/ instead of /es/blog/fourth-post/
if(data.slugOverride) {
return `/${data.lang}/blog/${this.slugify(data.slugOverride)}/`;
}
}
}

22
i18n.js
View File

@ -1,22 +0,0 @@
module.exports = {
en: {
also: "This page is also available in:",
previous: "Previous",
next: "Next",
nav: {
home: "Home",
archive: "Archive",
about: "About Me",
}
},
es: {
also: "Esta página también está disponible en:",
previous: "Anterior",
next: "Siguiente",
nav: {
home: "Página de inicio",
archive: "Archivo",
about: "Acerca de mí",
}
}
};

26
index.njk Normal file
View File

@ -0,0 +1,26 @@
---
layout: layouts/home.njk
eleventyNavigation:
key: Home
order: 1
---
{% set postsCount = collections.posts | length %}
{% set latestPostsCount = postsCount | min(3) %}
<h1>Latest {{ latestPostsCount }} Post{% if latestPostsCount != 1 %}s{% endif %}</h1>
{% set postslist = collections.posts | head(-3) %}
{% set postslistCounter = postsCount %}
{% include "postslist.njk" %}
{% if postsCount > 3 %}
<p>More posts can be found in <a href="/blog/">the archive</a>.</p>
{% endif %}
{# List every content page in the project #}
{#
<ul>
{%- for entry in collections.all %}
<li><a href="{{ entry.url }}"><code>{{ entry.url }}</code></a></li>
{%- endfor %}
</ul>
#}

View File

@ -27,13 +27,12 @@
},
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"dependencies": {
"@11ty/eleventy": "^2.0.0-beta.1",
"@11ty/eleventy": "2.0.0-beta.1",
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.2.0",
"@11ty/eleventy-plugin-webc": "^0.8.1",
"luxon": "^3.2.1",
"markdown-it-anchor": "^8.6.6",
"rosetta": "^1.1.0"
"markdown-it-anchor": "^8.6.6"
}
}

View File

@ -152,8 +152,7 @@ header {
.nav-item a[href]:not(:hover) {
text-decoration: none;
}
.nav-item-active {
font-weight: 700;
.nav a[href][aria-current="page"] {
text-decoration: underline;
}
@ -187,6 +186,8 @@ header {
word-spacing: -0.5px;
}
.postlist-link {
font-size: 1.1875em; /* 19px /16 */
font-weight: 700;
flex-basis: calc(100% - 1.5rem);
padding-left: .25em;
padding-right: .5em;
@ -197,11 +198,6 @@ header {
.postlist-item-active .postlist-link {
font-weight: bold;
}
.tmpl-home .postlist-link {
font-size: 1.1875em; /* 19px /16 */
font-weight: 700;
}
/* Tags */
.post-tag {

View File

@ -0,0 +1,18 @@
/* Message Box */
.message-box {
--color-message-box: #ffc;
display: block;
background-color: var(--color-message-box);
color: var(--color-gray-90);
padding: 1em 0.625em; /* 16px 10px /16 */
}
.message-box ol:only-child {
margin: 0;
}
@media (prefers-color-scheme: dark) {
.message-box {
--color-message-box: #082840;
}
}

View File

@ -9,13 +9,6 @@ eleventyExcludeFromCollections: true
<url>
<loc>{{ absoluteUrl }}</loc>
<lastmod>{{ page.date | htmlDateString }}</lastmod>
{%- set alternateUrls = page.url | locale_links %}
{%- if alternateUrls.length %}
<xhtml:link rel="alternate" hreflang="{{ page.data.page.lang }}" href="{{ absoluteUrl }}"/>
{%- for link in alternateUrls %}
<xhtml:link rel="alternate" hreflang="{{ link.lang }}" href="{{ link.url | htmlBaseUrl(metadata.url) }}"/>
{%- endfor %}
{%- endif %}
</url>
{%- endfor %}
</urlset>

View File

@ -1,6 +1,6 @@
---
permalink: /tags/
layout: layouts/home.webc
layout: layouts/home.njk
---
<h1>Tags</h1>

View File

@ -9,7 +9,7 @@ pagination:
- posts
- tagList
addAllPagesToCollections: true
layout: layouts/home.webc
layout: layouts/home.njk
eleventyComputed:
title: Tagged “{{ tag }}”
permalink: /tags/{{ tag | slugify }}/