Use new html base plugin!

Removes all the url filters
This commit is contained in:
Zach Leatherman 2022-08-19 11:05:22 -05:00
parent f57760d4d6
commit 9acd192d0d
14 changed files with 44 additions and 32 deletions

View File

@ -9,28 +9,28 @@
{#- Uncomment this if youd like folks to know that you used Eleventy to build your site! #}
{#- <meta name="generator" content="{{ eleventy.generator }}"> #}
<link rel="stylesheet" href="{{ '/css/prism-theme.css' | url }}">
<link rel="stylesheet" href="{{ '/css/prism-diff.css' | url }}">
<link rel="stylesheet" href="{{ '/css/index.css' | url }}">
<link rel="alternate" href="{{ '/feed/feed.xml' | url }}" type="application/atom+xml" title="{{ metadata.title }}">
<link rel="alternate" href="{{ '/feed/feed.json' | url }}" type="application/json" title="{{ metadata.title }}">
<link rel="stylesheet" href="/css/prism-theme.css">
<link rel="stylesheet" href="/css/prism-diff.css">
<link rel="stylesheet" href="/css/index.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 | absoluteUrl(metadata.url) }}">
<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 | absoluteUrl(metadata.url) }}">
<link rel="alternate" hreflang="{{ link.lang }}" href="{{ link.url | htmlBaseUrl(metadata.url) }}">
{%- endfor %}
{%- endif %}
</head>
<body>
<header>
<h1 class="home"><a href="{{ '/' | url }}">{{ metadata.title }}</a></h1>
<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 | url }}">{{ entry.title | i18n }}</a></li>
<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>
@ -53,6 +53,6 @@
<footer></footer>
<!-- Current page: {{ page.url | url }} -->
<!-- Current page: {{ page.url | htmlBaseUrl }} -->
</body>
</html>

View File

@ -8,7 +8,7 @@ templateClass: tmpl-post
<li><time datetime="{{ page.date | htmlDateString }}">{{ page.date | readableDate }}</time></li>
{%- for tag in tags | filterTagList %}
{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li><a href="{{ tagUrl | url }}" class="post-tag">{{ tag }}</a>{%- if not loop.last %}, {% endif %}</li>
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>{%- if not loop.last %}, {% endif %}</li>
{%- endfor %}
</ul>
@ -35,8 +35,8 @@ templateClass: tmpl-post
{%- set nextPost = collections.posts | getNextCollectionItem %}
{%- if nextPost or previousPost %}
<ul>
{%- if previousPost %}<li>{{ "i18n.previous" | i18n }}: <a href="{{ previousPost.url | url }}">{{ previousPost.data.title }}</a></li>{% endif %}
{%- if nextPost %}<li>{{ "i18n.next" | i18n }}: <a href="{{ nextPost.url | url }}">{{ nextPost.data.title }}</a></li>{% endif %}
{%- 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 %}
</ul>
{%- endif %}
{%- endif %}

View File

@ -1,7 +1,7 @@
<ol reversed class="postlist" style="counter-reset: start-from {{ (postslistCounter or postslist.length) + 1 }}">
{% for post in postslist | reverse %}
<li class="postlist-item{% if post.url == url %} postlist-item-active{% endif %}">
<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 }}" 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("LLLL yyyy") }}</time>
</li>
{% endfor %}

View File

@ -22,6 +22,8 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginSyntaxHighlight);
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(EleventyI18nPlugin, {
defaultLanguage: "en",
errorMode: "allow-fallback",

View File

@ -5,7 +5,7 @@ eleventyExcludeFromCollections: true
---
# Content not found.
Go <a href="{{ '/' | url }}">home</a>.
Go <a href="/">home</a>.
{#
Read more: https://www.11ty.dev/docs/quicktips/not-found/

View File

@ -10,8 +10,8 @@ Leverage agile frameworks to provide a robust synopsis for high level overviews.
## Section Header
<a href="{{ '/blog/firstpost/' | url }}">First post</a>
<a href="{{ '/blog/thirdpost/' | url }}">Third post</a>
<a href="/blog/firstpost/">First post</a>
<a href="/blog/thirdpost/">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.

View File

@ -4,6 +4,8 @@ module.exports = {
// 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

@ -11,7 +11,7 @@ eleventyNavigation:
{% set postslistCounter = collections.posts | length %}
{% include "postslist.njk" %}
<p>More posts can be found in <a href="{{ '/blog/' | url }}">the archive</a>.</p>
<p>More posts can be found in <a href="/blog/">the archive</a>.</p>
{# List all of the pages in the project
<ul>

View File

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

View File

@ -19,4 +19,4 @@ permalink: /tags/{{ tag | slugify }}/
{% set postslist = collections[ tag ] %}
{% include "postslist.njk" %}
<p>See <a href="{{ '/tags/' | url }}">all tags</a>.</p>
<p>See <a href="/tags/">all tags</a>.</p>

View File

@ -6,8 +6,8 @@ permalink: /feed/feed.xml
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.language }}">
<title>{{ metadata.title }}</title>
<subtitle>{{ metadata.description }}</subtitle>
<link href="{{ permalink | url | absoluteUrl(metadata.url) }}" rel="self"/>
<link href="{{ metadata.url }}"/>
<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self"/>
<link href="{{ metadata.url | addPathPrefixToFullUrl }}"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ metadata.url }}</id>
<author>
@ -15,13 +15,13 @@ permalink: /feed/feed.xml
<email>{{ metadata.author.email }}</email>
</author>
{%- for post in collections.posts | reverse %}
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %}
{% set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html">{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
<content type="html">{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) }}</content>
</entry>
{%- endfor %}
</feed>

View File

@ -6,8 +6,8 @@ permalink: /feed/feed.json
"version": "https://jsonfeed.org/version/1.1",
"title": "{{ metadata.title }}",
"language": "{{ metadata.language }}",
"home_page_url": "{{ metadata.url }}",
"feed_url": "{{ permalink | url | absoluteUrl(metadata.url) }}",
"home_page_url": "{{ metadata.url | addPathPrefixToFullUrl }}",
"feed_url": "{{ permalink | htmlBaseUrl(metadata.url) }}",
"description": "{{ metadata.description }}",
"author": {
"name": "{{ metadata.author.name }}",
@ -15,12 +15,12 @@ permalink: /feed/feed.json
},
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl = post.url | url | absoluteUrl(metadata.url) %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.data.title }}",
"content_html": {% if post.templateContent %}{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) | dump | safe }}{% else %}""{% endif %},
"content_html": {% if post.templateContent %}{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}{% else %}""{% endif %},
"date_published": "{{ post.date | dateToRfc3339 }}"
}
{% if not loop.last %},{% endif %}

View File

@ -4,6 +4,7 @@
"description": "A starter repository for a blog web site using the Eleventy static site generator.",
"scripts": {
"build": "npx @11ty/eleventy",
"build-ghpages": "npx @11ty/eleventy --pathprefix=/eleventy-base-blog/",
"bench": "DEBUG=Eleventy:Benchmark* npx @11ty/eleventy",
"watch": "npx @11ty/eleventy --watch",
"serve": "npx @11ty/eleventy --serve",
@ -26,8 +27,8 @@
},
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"dependencies": {
"@11ty/eleventy": "^2.0.0-canary.14",
"@11ty/eleventy-navigation": "^0.3.3",
"@11ty/eleventy": "^2.0.0-canary.15",
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.1.0",
"luxon": "^3.0.1",

View File

@ -3,12 +3,19 @@ permalink: /sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{%- for page in collections.all %}
{% set absoluteUrl %}{{ page.url | url | absoluteUrl(metadata.url) }}{% endset %}
{% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %}
<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>