File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const fs = require ( 'fs' ) ;
2- const posthtml = require ( ' posthtml' ) ;
3- const { insertAt } = require ( ' posthtml-insert-at' ) ;
1+ const fs = require ( "fs" ) ;
2+ const posthtml = require ( " posthtml" ) ;
3+ const { insertAt } = require ( " posthtml-insert-at" ) ;
44
5- const html = fs . readFileSync ( ' ./src/index.html' ) ;
5+ const html = fs . readFileSync ( " ./src/index.html" ) ;
66
77posthtml ( )
88 . use (
99 insertAt ( {
10- selector : ' .foo' ,
10+ selector : " .foo" ,
1111 append : `
1212 <footer id="footer">
1313 © ${ new Date ( ) . getFullYear ( ) }
1414 </footer>
1515 ` ,
16- behavior : ' outside'
16+ behavior : " outside" ,
1717 } )
1818 )
1919 . process ( html )
20- . then ( result => fs . writeFileSync ( ' ./src/after.html' , result . html ) ) ;
20+ . then ( ( result ) => fs . writeFileSync ( " ./src/after.html" , result . html ) ) ;
Original file line number Diff line number Diff line change 1- const fs = require ( 'fs' ) ;
2- const posthtml = require ( ' posthtml' ) ;
3- const { insertAt } = require ( ' posthtml-insert-at' ) ;
1+ const fs = require ( "fs" ) ;
2+ const posthtml = require ( " posthtml" ) ;
3+ const { insertAt } = require ( " posthtml-insert-at" ) ;
44
5- const html = fs . readFileSync ( ' ./src/index.html' ) ;
5+ const html = fs . readFileSync ( " ./src/index.html" ) ;
66
77posthtml ( )
88 . use (
99 insertAt ( {
10- selector : ' main' ,
10+ selector : " main" ,
1111 prepend : `
1212 <header>
1313 <a href="/">Home</a>
1414 </header>
1515 ` ,
16- behavior : ' outside'
16+ behavior : " outside" ,
1717 } )
1818 )
1919 . process ( html )
20- . then ( result => fs . writeFileSync ( ' ./src/after.html' , result . html ) ) ;
20+ . then ( ( result ) => fs . writeFileSync ( " ./src/after.html" , result . html ) ) ;
Original file line number Diff line number Diff line change 11declare module "posthtml-match-helper" {
2- function createMatcher ( matcher : string | string [ ] ) : string [ ] ;
3- export default createMatcher ;
2+ interface Matcher {
3+ tag ?: string ;
4+ attrs : {
5+ id ?: string ;
6+ class ?: RegExp ;
7+ [ attr : string ] : any ;
8+ } ;
9+ }
10+
11+ export default function createMatcher (
12+ matcher : string | string [ ]
13+ ) : Matcher | Matcher [ ] ;
414}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export function insertAt(options: Options) {
3333
3434 const matchingNode = siblingNode as PostHTML . Node [ "content" ] ;
3535
36- tree . match ( { content : [ matcher ] } , ( node ) =>
36+ tree . match ( { content : [ matcher as PostHTML . ContentMatcher ] } , ( node ) =>
3737 insertNode ( { node, option, content : [ matchingNode ] } )
3838 ) ;
3939 }
You can’t perform that action at this time.
0 commit comments