Replace custom CSS and JavaScript frontmatter with bundles

This commit is contained in:
Helen Chong 2024-07-18 22:11:18 +08:00
parent aa536e42bc
commit 72b878ef81
6 changed files with 12 additions and 20 deletions

View File

@ -22,7 +22,10 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(eleventyNavigationPlugin); eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(metagen); eleventyConfig.addPlugin(metagen);
eleventyConfig.addPlugin(emojiReadTime); eleventyConfig.addPlugin(emojiReadTime);
// Eleventy bundle plugin
eleventyConfig.addBundle("css"); eleventyConfig.addBundle("css");
eleventyConfig.addBundle("js");
// Add content categories to a collection // Add content categories to a collection
eleventyConfig.addCollection("categories", function(collectionApi) { eleventyConfig.addCollection("categories", function(collectionApi) {

View File

@ -1,6 +1,4 @@
--- {%- css %}{% include "src/assets/css/asummersend.css" %}{%- endcss %}
customCSSSheets: ["asummersend"]
---
{% extends "global/baselayout.njk" %} {% extends "global/baselayout.njk" %}

View File

@ -1,6 +1,4 @@
--- {%- css %}{% include "src/assets/css/cassettebeasts.css" %}{%- endcss %}
customCSSSheets: ["cassettebeasts"]
---
{% extends "global/baselayout.njk" %} {% extends "global/baselayout.njk" %}

View File

@ -11,11 +11,6 @@
{% include "global/css-bundle.njk" %} {% include "global/css-bundle.njk" %}
{% if hasTooltips %} {% if hasTooltips %}
<link rel="stylesheet" href="{{'/assets/css/tooltips.css' | url | safe}}"> <link rel="stylesheet" href="{{'/assets/css/tooltips.css' | url | safe}}">
{% endif %}
{% if customCSSSheets %}
{%- for sheet in customCSSSheets -%}
<link rel="stylesheet" href="{{'/assets/css/' + sheet + '.css' | url | safe}}">
{%- endfor -%}
{% endif %} {% endif %}
<style>{% getBundle "css" %}</style> <style>{% getBundle "css" %}</style>
@ -38,12 +33,10 @@
{% block favicon %}{% include "global/favicon.njk" %}{% endblock %} {% block favicon %}{% include "global/favicon.njk" %}{% endblock %}
{# JavaScript #} {# JavaScript #}
{% if toc %}
<script src="{{'/assets/js/details-utils.js'}}" defer></script> <script src="{{'/assets/js/details-utils.js'}}" defer></script>
{% if customJSFiles %}
{%- for jsFile in customJSFiles -%}
<script src="{{'/assets/js/' + jsFile + '.js' | url | safe}}" defer></script>
{%- endfor -%}
{% endif %} {% endif %}
<script>{% getBundle "js" %}</script>
<title> <title>
{% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %} {% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %}

View File

@ -1,6 +1,4 @@
--- {%- css %}{% include "src/assets/css/starwarskotor.css" %}{%- endcss %}
customCSSSheets: ["starwarskotor"]
---
{% extends "global/baselayout.njk" %} {% extends "global/baselayout.njk" %}

View File

@ -1,12 +1,14 @@
--- ---
title: Guestbook title: Guestbook
customCSSSheets: ["comments"]
customJSFiles: ["svgIconControl", "googleSheetsReaderGizmo", "comments"]
eleventyNavigation: eleventyNavigation:
order: 10 order: 10
eleventyComputed: eleventyComputed:
desc: Leave a message for {{ sitemeta.siteAuthor.name }}. 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> <p class="center-text">Guestbook Archive: <a href="https://web.archive.org/web/20240528231121/https%3A%2F%2Fleilukin.123guestbook.com%2F">123Guestbook</a></p>