diff --git a/.eleventy.js b/.eleventy.js index 1649d5b..aba42b5 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -35,6 +35,20 @@ module.exports = function (config) { return striptags(content); }); + // Prepare content for table of contents, at time of writing used on the docs.html layout + config.addFilter("prepTOCContent", (content) => { + const toc = config.getFilter("toc"); + const strip = config.getFilter("strip"); + const strip_newlines = config.getFilter("strip_newlines") + return strip_newlines(strip(toc(content))); + }); + + // Determine if the table of contents should be shown, at time of writing used on the docs.html layout + config.addFilter("shouldShowTOC", (content, showToc) => { + return !!showToc && content !== "" && content !== '
${htmlEntities(token.content)}
`;
+ };
+ })
+ .use(markdownItAnchor, {
+ permalink: markdownItAnchor.permalink.ariaHidden({
+ placement: 'after',
+ class: 'direct-link',
+ symbol: '',
+ level: [1, 2, 3, 4],
+ }),
+ slugify: config.getFilter('slug'),
+ })
+ .use(markdownItTable);
+
config.addFilter("markdown", (content) => {
return markdownLibrary.render(content);
});
- markdownLibrary.renderer.rules.link_open = function (tokens, idx, options, env, self) {
- const href = tokens[idx].attrGet("href");
- if (href && href.startsWith("http")) {
- tokens[idx].attrPush(["target", "_blank"]);
- tokens[idx].attrPush(["rel", "noopener noreferrer"]);
- }
- return self.renderToken(tokens, idx, options);
- };
- markdownLibrary.renderer.rules.code_inline = (tokens, idx, {langPrefix = ''}) => {
- const token = tokens[idx];
- return `${htmlEntities(token.content)}
`;
- };
config.setLibrary('md', markdownLibrary);
// Override Browsersync defaults (used only with --serve)
diff --git a/_includes/collection-item.html b/_includes/collection-item.html
index b495650..6423d1e 100644
--- a/_includes/collection-item.html
+++ b/_includes/collection-item.html
@@ -1,28 +1,33 @@
-- {{ post.templateContent | truncatewords: 10 }} + {%- if post.data.excerpt -%} + {{ post.data.excerpt | truncatewords: 50 }} + {%- else -%} + {{ post.content | striptags | truncatewords: 50 }} + {%- endif -%}
+