1
1
const EleventyPluginNavigation = require ( '@11ty/eleventy-navigation' )
2
2
const EleventyPluginRss = require ( '@11ty/eleventy-plugin-rss' )
3
3
const EleventyPluginSyntaxhighlight = require ( '@11ty/eleventy-plugin-syntaxhighlight' )
4
- // const EleventyPluginReadingTime = require('eleventy-plugin-reading-time')
5
4
const EleventyVitePlugin = require ( '@11ty/eleventy-plugin-vite' )
6
5
const { EleventyI18nPlugin } = require ( "@11ty/eleventy" )
7
6
const rollupPluginCritical = require ( 'rollup-plugin-critical' ) . default
@@ -17,6 +16,7 @@ const { execSync } = require('child_process')
17
16
// markdown
18
17
const markdownIt = require ( 'markdown-it' )
19
18
const markdownItAnchor = require ( 'markdown-it-anchor' )
19
+ const markdownItTocDoneRight = require ( 'markdown-it-toc-done-right' )
20
20
21
21
// image gallery
22
22
const Image = require ( '@11ty/eleventy-img' )
@@ -27,22 +27,20 @@ const LANDSCAPE_LIGHTBOX_IMAGE_WIDTH = 1440;
27
27
const PORTRAIT_LIGHTBOX_IMAGE_WIDTH = 720 ;
28
28
29
29
module . exports = function ( eleventyConfig ) {
30
- // eleventyConfig.setServerPassthroughCopyBehavior('copy')
31
30
eleventyConfig . addPassthroughCopy ( "public" )
32
31
33
32
// plugins
34
33
eleventyConfig . addPlugin ( EleventyPluginNavigation )
35
34
eleventyConfig . addPlugin ( EleventyPluginRss )
36
35
eleventyConfig . addPlugin ( EleventyPluginSyntaxhighlight )
37
- // eleventyConfig.addPlugin(EleventyPluginReadingTime)
38
36
eleventyConfig . addPlugin ( EleventyI18nPlugin , {
39
37
defaultLanguage : "en" ,
40
38
errorMode : "never"
41
39
} )
42
40
eleventyConfig . addPlugin ( EleventyVitePlugin , {
43
41
tempFolderName : './.11ty-vite' ,
44
42
viteOptions : {
45
- base : '/' , // '/danieletabellini/',
43
+ base : '/' ,
46
44
publicDir : 'public' ,
47
45
clearScreen : false ,
48
46
server : {
@@ -68,8 +66,8 @@ module.exports = function (eleventyConfig) {
68
66
chunkFileNames : 'assets/js/[name]-[hash].js' ,
69
67
entryFileNames : 'assets/js/[name]-[hash].js' ,
70
68
manualChunks : {
71
- // PhotoSwipe: ['photoswipe'],
72
- // PhotoSwipeLightbox: ['photoswipe/lightbox'],
69
+ PhotoSwipe : [ 'photoswipe' ] ,
70
+ PhotoSwipeLightbox : [ 'photoswipe/lightbox' ] ,
73
71
}
74
72
} ,
75
73
plugins : [ rollupPluginCritical ( {
@@ -129,10 +127,8 @@ module.exports = function (eleventyConfig) {
129
127
let imageSrc = `${ path . dirname ( this . page . inputPath ) } /${ src } `
130
128
let lightboxImageWidth = LANDSCAPE_LIGHTBOX_IMAGE_WIDTH
131
129
if ( alt === undefined ) throw new Error ( `Missing \`alt\` on image from: ${ src } ` )
132
-
133
130
let metadata = await sharp ( imageSrc ) . metadata ( )
134
131
if ( metadata . height > metadata . width ) lightboxImageWidth = PORTRAIT_LIGHTBOX_IMAGE_WIDTH
135
-
136
132
let genMetadata = await Image ( imageSrc , {
137
133
widths : [ GALLERY_IMAGE_WIDTH , lightboxImageWidth ] ,
138
134
formats : [ "avif" , "webp" , "jpeg" ] ,
@@ -143,7 +139,6 @@ module.exports = function (eleventyConfig) {
143
139
const imageWidth = genMetadata . jpeg [ 1 ] . width
144
140
const imageHeight = genMetadata . jpeg [ 1 ] . height
145
141
const thumbUrl = eleventyConfig . getFilter ( "url" ) ( genMetadata . jpeg [ 0 ] . url )
146
-
147
142
return `
148
143
<li>
149
144
<a href="${ imageUrl } "
@@ -155,6 +150,7 @@ module.exports = function (eleventyConfig) {
155
150
</li>
156
151
` . replace ( / ( \r \n | \n | \r ) / gm, "" )
157
152
} )
153
+
158
154
// Paired shortcodes
159
155
Object . keys ( pairedShortcodes ) . forEach ( ( pairedShortcodeName ) => {
160
156
eleventyConfig . addPairedLiquidShortcode ( pairedShortcodeName , pairedShortcodes [ pairedShortcodeName ] )
@@ -166,12 +162,12 @@ module.exports = function (eleventyConfig) {
166
162
breaks : true ,
167
163
linkify : true
168
164
} ) . use ( markdownItAnchor , {
169
- permalink : markdownItAnchor . permalink . ariaHidden ( {
170
- placement : 'after' ,
171
- class : 'direct-link' ,
172
- symbol : '#' ,
173
- level : [ 1 , 2 , 3 , 4 ]
174
- } ) ,
165
+ level : [ 2 ] ,
166
+ slugify : eleventyConfig . getFilter ( 'slug' )
167
+ } ) . use ( markdownItTocDoneRight , {
168
+ containerClass : "toc" ,
169
+ containerId : "toc" ,
170
+ level : [ 2 ] ,
175
171
slugify : eleventyConfig . getFilter ( 'slug' )
176
172
} )
177
173
eleventyConfig . setLibrary ( 'md' , markdownLibrary )
0 commit comments