section splitter
This commit is contained in:
parent
a6a086aa32
commit
b94e627a0a
5 changed files with 43 additions and 15 deletions
6
_includes/updates.njk
Normal file
6
_includes/updates.njk
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
{% for section in content | sections %}
|
||||||
|
START SECTION
|
||||||
|
{{ section | safe }}
|
||||||
|
END SECTION
|
||||||
|
{% endfor %}
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
permalink: /sitemap.xml
|
|
||||||
eleventyExcludeFromCollections: true
|
|
||||||
---
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<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 | htmlBaseUrl(metadata.url) }}{% endset %}
|
|
||||||
<url>
|
|
||||||
<loc>{{ absoluteUrl }}</loc>
|
|
||||||
<lastmod>{{ page.date | htmlDateString }}</lastmod>
|
|
||||||
</url>
|
|
||||||
{%- endfor %}
|
|
||||||
</urlset>
|
|
11
content/updates.md
Normal file
11
content/updates.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
layout: updates.njk
|
||||||
|
---
|
||||||
|
|
||||||
|
# first update
|
||||||
|
|
||||||
|
content
|
||||||
|
|
||||||
|
# second update
|
||||||
|
|
||||||
|
more content
|
|
@ -1,7 +1,8 @@
|
||||||
import { DateTime } from "luxon";
|
|
||||||
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
||||||
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
|
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
|
||||||
import pluginRss from '@11ty/eleventy-plugin-rss';
|
import pluginRss from '@11ty/eleventy-plugin-rss';
|
||||||
|
import { JSDOM } from 'jsdom';
|
||||||
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
||||||
export default function(eleventyConfig) {
|
export default function(eleventyConfig) {
|
||||||
|
@ -92,6 +93,29 @@ export default function(eleventyConfig) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/74005383
|
||||||
|
eleventyConfig.addFilter('sections', (html) => {
|
||||||
|
const dom = new JSDOM(html);
|
||||||
|
const document = dom.window.document;
|
||||||
|
const chunks = [];
|
||||||
|
for (const h1 of document.querySelectorAll('h1')) {
|
||||||
|
let chunk = '';
|
||||||
|
let elem = h1;
|
||||||
|
while (true) {
|
||||||
|
chunk += elem.outerHTML;
|
||||||
|
elem = document.evaluate(
|
||||||
|
"following-sibling::*[1]",
|
||||||
|
elem,
|
||||||
|
function() {},
|
||||||
|
dom.window.XPathResult.FIRST_ORDERED_NODE_TYPE
|
||||||
|
).singleNodeValue;
|
||||||
|
if (!elem || elem.nodeName === 'H1') break;
|
||||||
|
}
|
||||||
|
chunks.push(chunk);
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
});
|
||||||
|
|
||||||
eleventyConfig.addShortcode("currentBuildDate", () => {
|
eleventyConfig.addShortcode("currentBuildDate", () => {
|
||||||
return (new Date()).toISOString();
|
return (new Date()).toISOString();
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"@11ty/eleventy-plugin-rss": "^2.0.2",
|
"@11ty/eleventy-plugin-rss": "^2.0.2",
|
||||||
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
"jsdom": "^25.0.1",
|
||||||
"luxon": "^3.3.0",
|
"luxon": "^3.3.0",
|
||||||
"markdown-it-anchor": "^8.6.7"
|
"markdown-it-anchor": "^8.6.7"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue