From 72b878ef81088e365a846d2cd483f0bd3a525077 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:11:18 +0800 Subject: [PATCH] Replace custom CSS and JavaScript frontmatter with bundles --- eleventy.config.js | 3 +++ src/_includes/asummersend/base.njk | 4 +--- src/_includes/cassettebeasts/base.njk | 4 +--- src/_includes/global/baselayout.njk | 11 ++--------- src/_includes/starwarskotor/base.njk | 4 +--- src/pages/guestbook.njk | 6 ++++-- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index d619c185..d87097a9 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -22,7 +22,10 @@ module.exports = function (eleventyConfig) { eleventyConfig.addPlugin(eleventyNavigationPlugin); eleventyConfig.addPlugin(metagen); eleventyConfig.addPlugin(emojiReadTime); + + // Eleventy bundle plugin eleventyConfig.addBundle("css"); + eleventyConfig.addBundle("js"); // Add content categories to a collection eleventyConfig.addCollection("categories", function(collectionApi) { diff --git a/src/_includes/asummersend/base.njk b/src/_includes/asummersend/base.njk index 41144419..797b3183 100644 --- a/src/_includes/asummersend/base.njk +++ b/src/_includes/asummersend/base.njk @@ -1,6 +1,4 @@ ---- -customCSSSheets: ["asummersend"] ---- +{%- css %}{% include "src/assets/css/asummersend.css" %}{%- endcss %} {% extends "global/baselayout.njk" %} diff --git a/src/_includes/cassettebeasts/base.njk b/src/_includes/cassettebeasts/base.njk index 92d5f798..fa411f03 100644 --- a/src/_includes/cassettebeasts/base.njk +++ b/src/_includes/cassettebeasts/base.njk @@ -1,6 +1,4 @@ ---- -customCSSSheets: ["cassettebeasts"] ---- +{%- css %}{% include "src/assets/css/cassettebeasts.css" %}{%- endcss %} {% extends "global/baselayout.njk" %} diff --git a/src/_includes/global/baselayout.njk b/src/_includes/global/baselayout.njk index 484168d1..4aa6a79c 100644 --- a/src/_includes/global/baselayout.njk +++ b/src/_includes/global/baselayout.njk @@ -11,11 +11,6 @@ {% include "global/css-bundle.njk" %} {% if hasTooltips %} - {% endif %} - {% if customCSSSheets %} - {%- for sheet in customCSSSheets -%} - - {%- endfor -%} {% endif %} @@ -38,12 +33,10 @@ {% block favicon %}{% include "global/favicon.njk" %}{% endblock %} {# JavaScript #} + {% if toc %} - {% if customJSFiles %} - {%- for jsFile in customJSFiles -%} - - {%- endfor -%} {% endif %} + {% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %} diff --git a/src/_includes/starwarskotor/base.njk b/src/_includes/starwarskotor/base.njk index 38b7d6e6..31c226f0 100644 --- a/src/_includes/starwarskotor/base.njk +++ b/src/_includes/starwarskotor/base.njk @@ -1,6 +1,4 @@ ---- -customCSSSheets: ["starwarskotor"] ---- +{%- css %}{% include "src/assets/css/starwarskotor.css" %}{%- endcss %} {% extends "global/baselayout.njk" %} diff --git a/src/pages/guestbook.njk b/src/pages/guestbook.njk index 1475f41e..4d612194 100644 --- a/src/pages/guestbook.njk +++ b/src/pages/guestbook.njk @@ -1,12 +1,14 @@ --- title: Guestbook -customCSSSheets: ["comments"] -customJSFiles: ["svgIconControl", "googleSheetsReaderGizmo", "comments"] eleventyNavigation: order: 10 eleventyComputed: desc: Leave a message for {{ sitemeta.siteAuthor.name }}. --- +{%- css %}{% include "src/assets/css/comments.css" %}{%- endcss %} +{%- js %}{% include "src/assets/js/svgIconControl.js" %}{%- endjs %} +{%- js %}{% include "src/assets/js/googleSheetsReaderGizmo.js" %}{%- endjs %} +{%- js %}{% include "src/assets/js/comments.js" %}{%- endjs %} <p class="center-text">Guestbook Archive: <a href="https://web.archive.org/web/20240528231121/https%3A%2F%2Fleilukin.123guestbook.com%2F">123Guestbook</a></p>