@@ -6,26 +6,34 @@ const directoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output');
66const pfeAssetsPlugin = require ( './docs/_plugins/pfe-assets.cjs' ) ;
77const customElementsManifestPlugin = require ( './docs/_plugins/custom-elements-manifest.cjs' ) ;
88const orderTagsPlugin = require ( './docs/_plugins/order-tags.cjs' ) ;
9+ const todosPlugin = require ( './docs/_plugins/todos.cjs' ) ;
910
1011const markdownIt = require ( 'markdown-it' ) ;
1112const markdownItAnchor = require ( 'markdown-it-anchor' ) ;
1213
1314const pluginToc = require ( 'eleventy-plugin-toc' ) ;
1415
15- module . exports = function ( eleventyConfig ) {
16- const markdownLib = markdownIt ( { html : true } )
17- . use ( markdownItAnchor ) ;
16+ const markdownLib = markdownIt ( { html : true } )
17+ . use ( markdownItAnchor ) ;
1818
19+ module . exports = function ( eleventyConfig ) {
1920 eleventyConfig . setLibrary ( 'md' , markdownLib ) ;
2021
2122 eleventyConfig . setQuietMode ( process . env . npm_config_quiet ) ;
23+
2224 eleventyConfig . setWatchThrottleWaitTime ( 500 ) ;
2325
24- /** Table of Contents Shortcode */
25- eleventyConfig . addPlugin ( pluginToc , {
26- tags : [ 'h2' , 'h3' , 'h4' ] ,
26+ eleventyConfig . setBrowserSyncConfig ( {
27+ open : 'local' ,
28+ server : {
29+ baseDir : '_site' ,
30+ middleware : [ compress ( ) ] ,
31+ } ,
2732 } ) ;
2833
34+ /** Table of Contents Shortcode */
35+ eleventyConfig . addPlugin ( pluginToc , { tags : [ 'h2' , 'h3' , 'h4' ] } ) ;
36+
2937 /** Copy and manage site assets from the monorepo */
3038 eleventyConfig . addPlugin ( pfeAssetsPlugin ) ;
3139
@@ -38,10 +46,19 @@ module.exports = function(eleventyConfig) {
3846 /** Collections to organize by order instead of date */
3947 eleventyConfig . addPlugin ( orderTagsPlugin , { tags : [ 'develop' ] } ) ;
4048
41- eleventyConfig . addFilter ( 'prettyDate' , function ( dateStr ) {
42- return new Intl . DateTimeFormat ( 'en-US' , { dateStyle : 'medium' } ) . format ( new Date ( dateStr ) ) ;
49+ /** list todos */
50+ eleventyConfig . addPlugin ( todosPlugin ) ;
51+
52+ /** format date strings */
53+ eleventyConfig . addFilter ( 'prettyDate' , function ( dateStr , options = { } ) {
54+ const { dateStyle = 'medium' } = options ;
55+ return new Intl . DateTimeFormat ( 'en-US' , { dateStyle } )
56+ . format ( new Date ( dateStr ) ) ;
4357 } ) ;
4458
59+ /** fancy syntax highlighting with diff support */
60+ eleventyConfig . addPlugin ( syntaxHighlight ) ;
61+
4562 /** Add IDs to heading elements */
4663 eleventyConfig . addPlugin ( anchorsPlugin , {
4764 formatter ( element , existingids ) {
@@ -59,9 +76,6 @@ module.exports = function(eleventyConfig) {
5976 } ,
6077 } ) ;
6178
62- eleventyConfig . addPlugin ( syntaxHighlight ) ;
63-
64- eleventyConfig . setQuietMode ( true ) ;
6579 eleventyConfig . addPlugin ( directoryOutputPlugin , {
6680 // Customize columns
6781 columns : {
@@ -73,46 +87,6 @@ module.exports = function(eleventyConfig) {
7387 warningFileSize : 400 * 1000 ,
7488 } ) ;
7589
76- eleventyConfig . on ( 'eleventy.before' , async function generateTodos ( ) {
77- const start = performance . now ( ) ;
78- const fs = require ( 'fs/promises' ) ;
79- const leasot = require ( 'leasot' ) ;
80- const path = require ( 'path' ) ;
81- const { promisify } = require ( 'util' ) ;
82- const glob = promisify ( require ( 'glob' ) ) ;
83-
84- const todos = [ ] ;
85-
86- const files = await glob ( '{elements,core,tools}/**/*[!.spec].ts' , {
87- ignore : '**/node_modules/**/*' ,
88- } ) ;
89-
90- for ( const filename of files ) {
91- const contents = await fs . readFile ( filename , 'utf8' ) ;
92- const extension = path . extname ( filename ) ;
93- const parsed = leasot . parse ( contents , { extension, filename } ) ;
94- const output = leasot . report ( parsed , 'raw' ) ;
95- todos . push ( ...output ) ;
96- }
97-
98- await fs . writeFile (
99- path . join ( __dirname , 'docs' , '_data' , 'todos.json' ) ,
100- JSON . stringify ( todos , null , 2 ) ,
101- 'utf8'
102- ) ;
103- const end = performance . now ( ) ;
104- // eslint-disable-next-line no-console
105- console . log ( `Generated TODOs in ${ ( end - start ) / 1000 } s` ) ;
106- } ) ;
107-
108- eleventyConfig . setBrowserSyncConfig ( {
109- open : 'local' ,
110- server : {
111- baseDir : '_site' ,
112- middleware : [ compress ( ) ] ,
113- } ,
114- } ) ;
115-
11690 return {
11791 dir : {
11892 input : './docs' ,
0 commit comments