Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { minify } from "html-minifier";

import { createRequire } from "node:module";
import { readFileSync } from "fs";

const require = createRequire(import.meta.url);
const collectionControl = require("./src/_data/collectionsControl.json");
Expand Down Expand Up @@ -51,13 +48,13 @@ export default function (eleventyConfig) {
"./src/pages/garden/node/Assets/*": "assets",
});

eleventyConfig.addTransform("html", function (content) {
eleventyConfig.addTransform("html", async function (content) {
if (
this.page.outputPath &&
this.page.outputPath.endsWith(".html") &&
process.env.ELEVENTY_ENV == "production"
) {
return minify(content, {
return (await import("html-minifier")).minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
Expand Down
10 changes: 6 additions & 4 deletions conf/templating/javascript.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { minify as minifyTs } from "terser";
import { build as esbuild } from "esbuild";
import textInject from "../../utils/text-inject.js";

function evalInContext(js, context) {
Expand All @@ -17,7 +15,9 @@ export default function javascript(eleventyConfig) {
compile: async function (inputContent, inputPath) {
return async (data) => {
let result = (
await esbuild({
await (
await import("esbuild")
).build({
entryPoints: [inputPath],
define: {},
//format: "esm",
Expand All @@ -30,7 +30,9 @@ export default function javascript(eleventyConfig) {
if (process.env.ELEVENTY_ENV === "production") {
// @ts-ignore
result = (
await minifyTs(result, {
await (
await import("terser")
).minify(result, {
module: true,
ecma: 2017,
compress: {
Expand Down
48 changes: 25 additions & 23 deletions conf/templating/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@ import slugify from "../../../utils/slugify.js";

import iterator from "markdown-it-for-inline";

import Shiki from "@shikijs/markdown-it";
import { transformerNotationDiff } from "@shikijs/transformers";
import { gruvBoxDarkHard } from "./highlight.js";
import { inject } from "./widgets/widgets.js";

const proxy = (tokens, idx, options, env, self) =>
self.renderToken(tokens, idx, options);

const shiki = await Shiki({
langs: [
"html",
"css",
"scss",
"javascript",
"typescript",
"json",
"yaml",
"shell",
"graphql",
"rust",
"swift",
"regex",
"toml",
"liquid",
],
theme: gruvBoxDarkHard,
transformers: [transformerNotationDiff()],
});
async function shiki() {
return (await import("@shikijs/markdown-it")).default({
langs: [
"html",
"css",
"scss",
"javascript",
"typescript",
"json",
"yaml",
"shell",
"graphql",
"rust",
"swift",
"regex",
"toml",
"liquid",
],
theme: gruvBoxDarkHard,
transformers: [transformerNotationDiff()],
});
}

let options = {
html: true,
Expand Down Expand Up @@ -204,7 +204,9 @@ export function markdownTemplate(eleventyConfig) {
}
result = markdownIt.render(result, data);
if (result.includes("___")) {
result = await inject(result);
result = await (
await import("./widgets/widgets.js")
).inject(result);
}
return result;
};
Expand Down
12 changes: 7 additions & 5 deletions conf/templating/scss.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as sass from "sass";
import postcss from "postcss";
import path from "path";
import postcsso from "postcss-csso";
Expand All @@ -11,10 +10,13 @@ export default function scss(eleventyConfig) {
compile: async function (inputContent, inputPath) {
if (inputPath.split("/").at(-1).startsWith("_")) return;

let { css, loadedUrls } = sass.compileString(inputContent, {
loadPaths: [path.parse(inputPath).dir || "."],
sourceMap: false,
});
let { css, loadedUrls } = (await import("sass")).compileString(
inputContent,
{
loadPaths: [path.parse(inputPath).dir || "."],
sourceMap: false,
},
);

this.addDependencies(inputPath, loadedUrls);

Expand Down
13 changes: 7 additions & 6 deletions src/og.11ty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { svg } from "../utils/ogHelpers.js";
import { Resvg } from "@resvg/resvg-js";

export default class Og {
data() {
return {
Expand All @@ -25,7 +22,9 @@ export default class Og {
};
}
async render(page) {
let svgd = await svg({
let svgd = await (
await import("../utils/ogHelpers.js")
).svg({
title: page.entry.data.title,
desc: page.entry.data.description,
date: page.entry.data.date?.toLocaleDateString(),
Expand All @@ -35,7 +34,7 @@ export default class Og {
}
}

function renderSvg(svgd) {
async function renderSvg(svgd) {
/**
* @type {import("@resvg/resvg-js").ResvgRenderOptions}
*/
Expand All @@ -44,6 +43,8 @@ function renderSvg(svgd) {
loadSystemFonts: false,
},
};
const png = new Resvg(svgd, options).render().asPng();
const png = new (await import("@resvg/resvg-js")).Resvg(svgd, options)
.render()
.asPng();
return png;
}