From cf647eed90cd890f647d3ec45d2f6b5c42b39dda Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Mon, 5 Aug 2024 15:13:56 -0700 Subject: [PATCH] chore: slice entries before processing to reduce filter runs --- config/filters/index.js | 5 +++-- package-lock.json | 4 ++-- package.json | 2 +- src/includes/partials/feeds/rss.liquid | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config/filters/index.js b/config/filters/index.js index af5bf586..53a46712 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -85,7 +85,7 @@ export default { }, // feeds - normalizeEntries: (entries) => { + normalizeEntries: (entries, limit) => { const posts = [] const mdGenerator = () => { const md = markdownIt({ html: true, linkify: true }) @@ -112,8 +112,9 @@ export default { return md } + const entryData = limit ? entries.slice(0, limit) : entries - entries.forEach((entry) => { + entryData.forEach((entry) => { const dateKey = Object.keys(entry).find(key => key.includes('date')) const date = new Date(entry[dateKey]) const md = mdGenerator() diff --git a/package-lock.json b/package-lock.json index 2978a680..f8919d09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "21.4.4", + "version": "21.4.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "21.4.4", + "version": "21.4.5", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", diff --git a/package.json b/package.json index 15086e08..8f0bb1ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "21.4.4", + "version": "21.4.5", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "scripts": { diff --git a/src/includes/partials/feeds/rss.liquid b/src/includes/partials/feeds/rss.liquid index ee6a2f76..4030f601 100644 --- a/src/includes/partials/feeds/rss.liquid +++ b/src/includes/partials/feeds/rss.liquid @@ -2,7 +2,7 @@ - {%- assign entries = data | normalizeEntries -%} + {%- assign entries = data | normalizeEntries: 20 -%} {{ title }} {{ description }} {{ permalink | absoluteUrl: globals.url }} @@ -14,7 +14,7 @@ 144 144 - {% for entry in entries limit: 20 -%} + {% for entry in entries -%} {%- assign rating = entry.rating -%} {%- capture entryTitle -%} {{ entry.title | escape }}