Skip to content

Commit 9daae5b

Browse files
authored
Merge pull request #20 from 1024daniel/update-template-to-v1.61.3-29a4314c-d9c7-4a5a-9295-2eec94e7f45e
Update template to version 1.61.3
2 parents bd074d4 + 17be862 commit 9daae5b

13 files changed

+1956
-1300
lines changed

.eleventy.js

+28-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const matter = require("gray-matter");
55
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
66
const tocPlugin = require("eleventy-plugin-nesting-toc");
77
const { parse } = require("node-html-parser");
8-
const htmlMinifier = require("html-minifier");
8+
const htmlMinifier = require("html-minifier-terser");
99
const pluginRss = require("@11ty/eleventy-plugin-rss");
1010

1111
const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils");
@@ -94,12 +94,6 @@ function getAnchorAttributes(filePath, linkTitle) {
9494
const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g;
9595

9696
module.exports = function (eleventyConfig) {
97-
// add support for vercel speed insights
98-
// import { injectSpeedInsights } from '@vercel/speed-insights';
99-
// injectSpeedInsights();
100-
var vercel = require("@vercel/speed-insights")
101-
vercel.injectSpeedInsights()
102-
10397
eleventyConfig.setLiquidOptions({
10498
dynamicPartials: true,
10599
});
@@ -387,13 +381,26 @@ module.exports = function (eleventyConfig) {
387381
}
388382
);
389383

384+
/* Hacky fix for callouts with only a title:
385+
This will ensure callout-content isn't produced if
386+
the callout only has a title, like this:
387+
```md
388+
> [!info] i only have a title
389+
```
390+
Not sure why content has a random <p> tag in it,
391+
*/
392+
if (content === "\n<p>\n") {
393+
content = "";
394+
}
395+
let contentDiv = content ? `\n<div class="callout-content">${content}</div>` : "";
396+
390397
blockquote.tagName = "div";
391398
blockquote.classList.add("callout");
392399
blockquote.classList.add(isCollapsable ? "is-collapsible" : "");
393400
blockquote.classList.add(isCollapsed ? "is-collapsed" : "");
394401
blockquote.setAttribute("data-callout", calloutType.toLowerCase());
395402
calloutMetaData && blockquote.setAttribute("data-callout-metadata", calloutMetaData);
396-
blockquote.innerHTML = `${titleDiv}\n<div class="callout-content">${content}</div>`;
403+
blockquote.innerHTML = `${titleDiv}${contentDiv}`;
397404
}
398405
};
399406

@@ -438,10 +445,13 @@ module.exports = function (eleventyConfig) {
438445

439446

440447
eleventyConfig.addTransform("picture", function (str) {
448+
if(process.env.USE_FULL_RESOLUTION_IMAGES === "true"){
449+
return str;
450+
}
441451
const parsed = parse(str);
442452
for (const imageTag of parsed.querySelectorAll(".cm-s-obsidian img")) {
443453
const src = imageTag.getAttribute("src");
444-
if (src && src.startsWith("/") && !src.endsWith(".svg") && !src.endsWith(".png") && !src.endsWith(".gif")) {
454+
if (src && src.startsWith("/") && !src.endsWith(".svg")) {
445455
const cls = imageTag.classList.value;
446456
const alt = imageTag.getAttribute("alt");
447457
const width = imageTag.getAttribute("width") || '';
@@ -493,14 +503,16 @@ module.exports = function (eleventyConfig) {
493503

494504
eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => {
495505
if (
496-
process.env.NODE_ENV === "production" &&
506+
(process.env.NODE_ENV === "production" || process.env.ELEVENTY_ENV === "prod") &&
497507
outputPath &&
498508
outputPath.endsWith(".html")
499509
) {
500510
return htmlMinifier.minify(content, {
501511
useShortDoctype: true,
502512
removeComments: true,
503513
collapseWhitespace: true,
514+
conservativeCollapse: true,
515+
preserveLineBreaks: true,
504516
minifyCSS: true,
505517
minifyJS: true,
506518
keepClosingSlash: true,
@@ -520,9 +532,13 @@ module.exports = function (eleventyConfig) {
520532

521533

522534
eleventyConfig.addFilter("dateToZulu", function (date) {
523-
if (!date) return "";
524-
return new Date(date).toISOString("dd-MM-yyyyTHH:mm:ssZ");
535+
try {
536+
return new Date(date).toISOString("dd-MM-yyyyTHH:mm:ssZ");
537+
} catch {
538+
return "";
539+
}
525540
});
541+
526542
eleventyConfig.addFilter("jsonify", function (variable) {
527543
return JSON.stringify(variable) || '""';
528544
});
@@ -557,5 +573,3 @@ module.exports = function (eleventyConfig) {
557573
passthroughFileCopy: true,
558574
};
559575
};
560-
561-

0 commit comments

Comments
 (0)