From 5f0c3ff81b43bb9b14934b95cac09684e185da8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Thu, 6 Jun 2024 17:26:25 +0200 Subject: [PATCH] Optimize related include (#33104) --- plugins/site_pages.rb | 27 +++++++++++++++++++++++++++ source/_includes/related.html | 16 ++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 plugins/site_pages.rb diff --git a/plugins/site_pages.rb b/plugins/site_pages.rb new file mode 100644 index 00000000000..517f4571195 --- /dev/null +++ b/plugins/site_pages.rb @@ -0,0 +1,27 @@ +module Jekyll + class SitePagesGenerator < Jekyll::Generator + def generate(site) + all_pages = Array.new + + site.collections.each do |name, collection| + all_pages.concat(collection.docs) + end + + site.data["site_pages"] = all_pages + .concat(site.pages) + .concat(site.documents) + .map { |entry| + [ + entry.url.to_s, + { + "title" => entry["title"], + "description" => entry["description"], + "url" => entry.url, + "relative_path" => entry.relative_path + } + ] + } + .to_h + end + end +end \ No newline at end of file diff --git a/source/_includes/related.html b/source/_includes/related.html index 81fd4ba91d0..65ffe151326 100644 --- a/source/_includes/related.html +++ b/source/_includes/related.html @@ -11,23 +11,19 @@