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(metagen);
eleventyConfig.addPlugin(emojiReadTime);
// Eleventy bundle plugin
eleventyConfig.addBundle("css");
eleventyConfig.addBundle("js");
// Add content categories to a collection
eleventyConfig.addCollection("categories", function(collectionApi) {

View File

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

View File

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

View File

@ -11,11 +11,6 @@
{% include "global/css-bundle.njk" %}
{% if hasTooltips %}
<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 %}
<style>{% getBundle "css" %}</style>
@ -38,12 +33,10 @@
{% block favicon %}{% include "global/favicon.njk" %}{% endblock %}
{# JavaScript #}
{% if toc %}
<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 %}
<script>{% getBundle "js" %}</script>
<title>
{% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %}

View File

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

View File

@ -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>