1+ /** @format */
2+
13// warning: This file is overwritten by Astro Accelerator
24
35import { Accelerator , PostFiltering } from 'astro-accelerator-utils' ;
@@ -14,9 +16,7 @@ const getData = async () => {
1416 const accelerator = new Accelerator ( SITE ) ;
1517
1618 for ( const path in allPages ) {
17- const page = ( await allPages [ path ] ( ) ) as MarkdownInstance <
18- Record < string , any >
19- > ;
19+ const page = ( await allPages [ path ] ( ) ) as MarkdownInstance < Record < string , any > > ;
2020
2121 if ( ! PostFiltering . showInSearch ( page ) ) {
2222 continue ;
@@ -29,14 +29,20 @@ const getData = async () => {
2929 }
3030
3131 const headings = await page . getHeadings ( ) ;
32- const title = await accelerator . markdown . getTextFrom (
33- page . frontmatter . title ?? ''
34- ) ;
35- const content = page . compiledContent ? page . compiledContent ( ) : '' ;
32+ const title = await accelerator . markdown . getTextFrom ( page . frontmatter ?. title ) ;
33+ const content = page . compiledContent ? await page . compiledContent ( ) : '' ;
3634 let counted : { word : string ; count : number } [ ] = [ ] ;
3735
3836 if ( content ) {
39- const text = convert ( content , { wordwrap : false } ) ;
37+ const options = {
38+ wordwrap : false ,
39+ selectors : [
40+ { selector : 'a' , options : { ignoreHref : true } } ,
41+ { selector : 'img' , format : 'skip' } ,
42+ { selector : 'h1' , options : { uppercase : false } } ,
43+ ] ,
44+ } ;
45+ const text = convert ( content , options ) ;
4046
4147 const words = keywordExtractor . extract ( text , {
4248 language : 'english' ,
@@ -45,19 +51,22 @@ const getData = async () => {
4551 } ) ;
4652
4753 counted = words
48- . map ( ( w ) => {
49- return { word : w , count : words . filter ( ( wd ) => wd === w ) . length } ;
54+ . map ( w => {
55+ return {
56+ word : w ,
57+ count : words . filter ( wd => wd === w ) . length ,
58+ } ;
5059 } )
51- . filter ( ( e ) => e . word . replace ( / [ ^ a - z ] + / g, '' ) . length > 1 ) ;
60+ . filter ( e => e . word . replace ( / [ ^ a - z ] + / g, '' ) . length > 1 ) ;
5261 }
5362
5463 items . push ( {
5564 title : title ,
56- headings : headings . map ( ( h ) => {
65+ headings : headings . map ( h => {
5766 return { text : h . text , slug : h . slug } ;
5867 } ) ,
5968 description : page . frontmatter . description ?? '' ,
60- keywords : counted . map ( ( c ) => c . word ) . join ( ' ' ) ,
69+ keywords : counted . map ( c => c . word ) . join ( ' ' ) ,
6170 tags : page . frontmatter . tags ?? [ ] ,
6271 url : SITE . url + accelerator . urlFormatter . formatAddress ( url ) ,
6372 date : page . frontmatter . pubDate ?? '' ,
0 commit comments