@@ -5,7 +5,7 @@ const matter = require("gray-matter");
5
5
const faviconsPlugin = require ( "eleventy-plugin-gen-favicons" ) ;
6
6
const tocPlugin = require ( "eleventy-plugin-nesting-toc" ) ;
7
7
const { parse } = require ( "node-html-parser" ) ;
8
- const htmlMinifier = require ( "html-minifier" ) ;
8
+ const htmlMinifier = require ( "html-minifier-terser " ) ;
9
9
const pluginRss = require ( "@11ty/eleventy-plugin-rss" ) ;
10
10
11
11
const { headerToId, namedHeadingsFilter } = require ( "./src/helpers/utils" ) ;
@@ -94,12 +94,6 @@ function getAnchorAttributes(filePath, linkTitle) {
94
94
const tagRegex = / ( ^ | \s | \> ) ( # [ ^ \s ! @ # $ % ^ & * ( ) = + \. , \[ { \] } ; : ' " ? > < ] + ) (? ! ( [ ^ < ] * > ) ) / g;
95
95
96
96
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
-
103
97
eleventyConfig . setLiquidOptions ( {
104
98
dynamicPartials : true ,
105
99
} ) ;
@@ -387,13 +381,26 @@ module.exports = function (eleventyConfig) {
387
381
}
388
382
) ;
389
383
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
+
390
397
blockquote . tagName = "div" ;
391
398
blockquote . classList . add ( "callout" ) ;
392
399
blockquote . classList . add ( isCollapsable ? "is-collapsible" : "" ) ;
393
400
blockquote . classList . add ( isCollapsed ? "is-collapsed" : "" ) ;
394
401
blockquote . setAttribute ( "data-callout" , calloutType . toLowerCase ( ) ) ;
395
402
calloutMetaData && blockquote . setAttribute ( "data-callout-metadata" , calloutMetaData ) ;
396
- blockquote . innerHTML = `${ titleDiv } \n<div class="callout-content"> ${ content } </div> ` ;
403
+ blockquote . innerHTML = `${ titleDiv } ${ contentDiv } ` ;
397
404
}
398
405
} ;
399
406
@@ -438,10 +445,13 @@ module.exports = function (eleventyConfig) {
438
445
439
446
440
447
eleventyConfig . addTransform ( "picture" , function ( str ) {
448
+ if ( process . env . USE_FULL_RESOLUTION_IMAGES === "true" ) {
449
+ return str ;
450
+ }
441
451
const parsed = parse ( str ) ;
442
452
for ( const imageTag of parsed . querySelectorAll ( ".cm-s-obsidian img" ) ) {
443
453
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" ) ) {
445
455
const cls = imageTag . classList . value ;
446
456
const alt = imageTag . getAttribute ( "alt" ) ;
447
457
const width = imageTag . getAttribute ( "width" ) || '' ;
@@ -493,14 +503,16 @@ module.exports = function (eleventyConfig) {
493
503
494
504
eleventyConfig . addTransform ( "htmlMinifier" , ( content , outputPath ) => {
495
505
if (
496
- process . env . NODE_ENV === "production" &&
506
+ ( process . env . NODE_ENV === "production" || process . env . ELEVENTY_ENV === "prod" ) &&
497
507
outputPath &&
498
508
outputPath . endsWith ( ".html" )
499
509
) {
500
510
return htmlMinifier . minify ( content , {
501
511
useShortDoctype : true ,
502
512
removeComments : true ,
503
513
collapseWhitespace : true ,
514
+ conservativeCollapse : true ,
515
+ preserveLineBreaks : true ,
504
516
minifyCSS : true ,
505
517
minifyJS : true ,
506
518
keepClosingSlash : true ,
@@ -520,9 +532,13 @@ module.exports = function (eleventyConfig) {
520
532
521
533
522
534
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
+ }
525
540
} ) ;
541
+
526
542
eleventyConfig . addFilter ( "jsonify" , function ( variable ) {
527
543
return JSON . stringify ( variable ) || '""' ;
528
544
} ) ;
@@ -557,5 +573,3 @@ module.exports = function (eleventyConfig) {
557
573
passthroughFileCopy : true ,
558
574
} ;
559
575
} ;
560
-
561
-
0 commit comments