Eleventy Setup for Sri's Digital Garden

Posted Saturday, October 29, 2022 by Sri. Tagged EXPEDITION, SRI KMS
EDITING PHASE:gathering info...

Eleventy Version 1.0.0 installation Notes

following video link: Eleventy: Key Features & Getting Started

npm init -y
npm install @11ty/eleventy

Next:

  • add .eleventy.js exports input, output directory
  • update package.json scripts to start: "eleventy --serve", build: "eleventy"

Syntax Highlighting and Formatting on Save

  • The better nunjucks highlighter in extensions: Better Nunjucks. It's pretty new (March 2022), but it fixes the issue with nunjucks + frontmatter collapsing into one line that all the other popular extensions suffer from.

RSS Feeds

RSS is not ATOM;

Canonical URLS

would like to copy everything into an /link/name-of-thing, but need canonical URLs and still manage to find some way of supporting moved content.

This article has information about other head markup

Search/Replace markdown without trailing slash

For permalinks, we don't want to rely on server redirects from /url/to/directory with /url/to/directory/. When using markdown like [banana](/trope/banana) to refer to a banana.md file that is creating a banana/index.html file, we need to make sure the trailing slash is there.

This regex attempt to search for these patterns in visual studio code: \]\((\/.+?[^\/])\) which can be replaced with ]($1/).

\]\)

match literal ]( in an expression like [banana](/trope/banana)

(

open group capture

\/

match literal / and match one or more characters

.+?

match any character one-or-more times NON-GREEDILY

[^\/]

don't match a following /

)

close group capture

\)

match a literal )

Pagination Concepts

TL;DR: The Pagination System is a dictionary string-based iterator utility. It does NOT provide template objects as you might expect. It just spits out key strings.

The pagination parameters do NOT obey the data cascade rules as of 1.0.0 as you might expect, because the parameters are not actually referring to page objects or data despite using the same nomenclature. The reference Tip 004: Zero Maintenance Tags is particularly misleading.

For example, this is what they're doing (refactored for markdown):


---
pagination:
data: collections
size: 1
alias: tag
permalink: /tags/{{ tag }}/
---
## {{ tag }}
{% set taglist = collections[ tag ] %}
{% for post in taglist | reverse %}
* [ {{ post.data.title }} ]( {{ post.url | url }} )
{% endfor %}

data: collections is not the same as the one in {% set taglist = collections[ tag ]. If it were, you would think that you could substitute data: collections[tag] or some variation of that, but it will fail. That's because "collections" is (I'm guessing) a string intended to be used as a dictionary key in the full data object (which is not accessible to pages). dataKey or dataSelector might be a better name for the concept.

This is an example of how simple documentation inadvertently relies on computing concepts that it fails to explain, thus becoming bad documentation.

On a similar note, the pagination.alias property is set to tag. But an alias for what? It's just the iterated value, as in a {% for tag in collections %} which would retrieve a collection object. But for pagination, tag is supplied a string , which is why there is that {%set taglist ... %} line before the post iterator.