Skip to content

Commit

Permalink
fix: prev
Browse files Browse the repository at this point in the history
  • Loading branch information
TrebledJ committed Nov 8, 2023
1 parent 9ba5c88 commit cfb71d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/redirect-from.njk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{% endif %}

{% if redirect.page.data.excerpt %}
{% set meta_desc = (redirect.page.data.excerpt | mdInline | striptags) + "\n\n" + (redirect.page.data.content | annihilate('.article-header, .metadata-container, .metadata-tag-container, #toc-sidebar') | striptags | truncateWords(30)) %}
{% set meta_desc = (redirect.page.data.excerpt | mdInline | striptags) + "\n\n" + (redirect.page.content | annihilate('.article-header, .metadata-container, .metadata-tag-container, #toc-sidebar') | striptags | truncateWords(30)) %}
{% else %}
{% set meta_desc = site.description %}
{% endif %}
Expand Down
3 changes: 3 additions & 0 deletions eleventy/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ module.exports = function (eleventyConfig) {
return tags.reduce((acc, x) => acc.replace(dumbHTMLRegex(x), ''), html);
});
eleventyConfig.addFilter('annihilate', (html, selector) => {
if (typeof html !== 'string') {
throw new Error(`[11ty] annihilate: expected HTML string, got ${typeof html}`);
}
const $ = cheerio.load(html);
$(selector).remove();
return $.html();
Expand Down

0 comments on commit cfb71d3

Please sign in to comment.