@@ -13,33 +13,134 @@ const OUTPUT = path.join(ROOT_DIR, 'public/docs-index.json');
1313function  extractKeywords ( text ,  minLength  =  3 ,  maxCount  =  20 )  { 
1414  // Common stop words 
1515  const  stopWords  =  new  Set ( [ 
16-     'the' ,  'is' ,  'at' ,  'which' ,  'on' ,  'and' ,  'a' ,  'to' ,  'are' ,  'as' ,  'was' ,  'were' , 
17-     'been' ,  'be' ,  'have' ,  'has' ,  'had' ,  'do' ,  'does' ,  'did' ,  'will' ,  'would' ,  'could' , 
18-     'should' ,  'may' ,  'might' ,  'can' ,  'must' ,  'shall' ,  'of' ,  'in' ,  'for' ,  'with' ,  'by' , 
19-     'from' ,  'up' ,  'about' ,  'into' ,  'through' ,  'during' ,  'before' ,  'after' ,  'above' , 
20-     'below' ,  'to' ,  'under' ,  'again' ,  'further' ,  'then' ,  'once' ,  'here' ,  'there' , 
21-     'when' ,  'where' ,  'why' ,  'how' ,  'all' ,  'any' ,  'both' ,  'each' ,  'few' ,  'more' , 
22-     'most' ,  'other' ,  'some' ,  'such' ,  'no' ,  'nor' ,  'not' ,  'only' ,  'own' ,  'same' , 
23-     'so' ,  'than' ,  'too' ,  'very' ,  'can' ,  'just' ,  'now' ,  'also' ,  'if' ,  'this' , 
24-     'that' ,  'these' ,  'those' ,  'i' ,  'me' ,  'my' ,  'myself' ,  'we' ,  'our' ,  'ours' , 
25-     'ourselves' ,  'you' ,  'your' ,  'yours' ,  'yourself' ,  'yourselves' ,  'he' ,  'him' , 
26-     'his' ,  'himself' ,  'she' ,  'her' ,  'hers' ,  'herself' ,  'it' ,  'its' ,  'itself' , 
27-     'they' ,  'them' ,  'their' ,  'theirs' ,  'themselves' 
16+     'the' , 
17+     'is' , 
18+     'at' , 
19+     'which' , 
20+     'on' , 
21+     'and' , 
22+     'a' , 
23+     'to' , 
24+     'are' , 
25+     'as' , 
26+     'was' , 
27+     'were' , 
28+     'been' , 
29+     'be' , 
30+     'have' , 
31+     'has' , 
32+     'had' , 
33+     'do' , 
34+     'does' , 
35+     'did' , 
36+     'will' , 
37+     'would' , 
38+     'could' , 
39+     'should' , 
40+     'may' , 
41+     'might' , 
42+     'can' , 
43+     'must' , 
44+     'shall' , 
45+     'of' , 
46+     'in' , 
47+     'for' , 
48+     'with' , 
49+     'by' , 
50+     'from' , 
51+     'up' , 
52+     'about' , 
53+     'into' , 
54+     'through' , 
55+     'during' , 
56+     'before' , 
57+     'after' , 
58+     'above' , 
59+     'below' , 
60+     'to' , 
61+     'under' , 
62+     'again' , 
63+     'further' , 
64+     'then' , 
65+     'once' , 
66+     'here' , 
67+     'there' , 
68+     'when' , 
69+     'where' , 
70+     'why' , 
71+     'how' , 
72+     'all' , 
73+     'any' , 
74+     'both' , 
75+     'each' , 
76+     'few' , 
77+     'more' , 
78+     'most' , 
79+     'other' , 
80+     'some' , 
81+     'such' , 
82+     'no' , 
83+     'nor' , 
84+     'not' , 
85+     'only' , 
86+     'own' , 
87+     'same' , 
88+     'so' , 
89+     'than' , 
90+     'too' , 
91+     'very' , 
92+     'can' , 
93+     'just' , 
94+     'now' , 
95+     'also' , 
96+     'if' , 
97+     'this' , 
98+     'that' , 
99+     'these' , 
100+     'those' , 
101+     'i' , 
102+     'me' , 
103+     'my' , 
104+     'myself' , 
105+     'we' , 
106+     'our' , 
107+     'ours' , 
108+     'ourselves' , 
109+     'you' , 
110+     'your' , 
111+     'yours' , 
112+     'yourself' , 
113+     'yourselves' , 
114+     'he' , 
115+     'him' , 
116+     'his' , 
117+     'himself' , 
118+     'she' , 
119+     'her' , 
120+     'hers' , 
121+     'herself' , 
122+     'it' , 
123+     'its' , 
124+     'itself' , 
125+     'they' , 
126+     'them' , 
127+     'their' , 
128+     'theirs' , 
129+     'themselves' , 
28130  ] ) ; 
29131
30132  const  words  =  text 
31133    . toLowerCase ( ) 
32134    . replace ( / [ ^ \w \s ] / g,  ' ' ) 
33135    . split ( / \s + / ) 
34-     . filter ( word  => 
35-       word . length  >=  minLength  && 
36-       ! stopWords . has ( word )  && 
37-       ! / ^ \d + $ / . test ( word ) 
136+     . filter ( 
137+       ( word )  => 
138+         word . length  >=  minLength  &&  ! stopWords . has ( word )  &&  ! / ^ \d + $ / . test ( word ) , 
38139    ) ; 
39140
40141  // Calculate word frequency 
41142  const  wordCounts  =  { } ; 
42-   words . forEach ( word  =>  { 
143+   words . forEach ( ( word )  =>  { 
43144    wordCounts [ word ]  =  ( wordCounts [ word ]  ||  0 )  +  1 ; 
44145  } ) ; 
45146
@@ -73,7 +174,7 @@ function generateSummary(content, maxLength = 200) {
73174  const  lastSentenceEnd  =  Math . max ( 
74175    truncated . lastIndexOf ( '.' ) , 
75176    truncated . lastIndexOf ( '!' ) , 
76-     truncated . lastIndexOf ( '?' ) 
177+     truncated . lastIndexOf ( '?' ) , 
77178  ) ; 
78179
79180  if  ( lastSentenceEnd  >  maxLength  *  0.7 )  { 
@@ -96,7 +197,9 @@ function extractMetadata(filePath, frontmatter) {
96197    docType  =  'documentation' ; 
97198
98199    // 从路径中提取产品类别 
99-     const  productMatch  =  filePath . match ( / d o c s \/ e n \/ [ ^ / ] * \/ k u b e b l o c k s - f o r - ( [ ^ / ] + ) / ) ; 
200+     const  productMatch  =  filePath . match ( 
201+       / d o c s \/ e n \/ [ ^ / ] * \/ k u b e b l o c k s - f o r - ( [ ^ / ] + ) / , 
202+     ) ; 
100203    if  ( productMatch )  { 
101204      category  =  productMatch [ 1 ] ; 
102205    }  else  if  ( filePath . includes ( 'user_docs' ) )  { 
@@ -129,7 +232,7 @@ async function main() {
129232      'blogs/en/**/*.mdx' , 
130233      '!docs/en/preview/**/cli/**' , 
131234      '!docs/en/preview/**/release_notes/**' , 
132-       '!docs/en/release-*/**' ,    // 明确排除所有release版本目录 
235+       '!docs/en/release-*/**' ,  // 明确排除所有release版本目录 
133236    ] , 
134237    {  cwd : ROOT_DIR ,  absolute : true  } , 
135238  ) ; 
@@ -172,7 +275,7 @@ async function main() {
172275    const  headings  =  [ ] ; 
173276    const  headingMatches  =  content . match ( / ^ # { 1 , 6 } \s + .+ $ / gm) ; 
174277    if  ( headingMatches )  { 
175-       headingMatches . forEach ( heading  =>  { 
278+       headingMatches . forEach ( ( heading )  =>  { 
176279        const  level  =  ( heading . match ( / ^ # + / )  ||  [ '' ] ) [ 0 ] . length ; 
177280        const  text  =  heading . replace ( / ^ # + \s + / ,  '' ) . trim ( ) ; 
178281        headings . push ( {  level,  text } ) ; 
@@ -181,7 +284,10 @@ async function main() {
181284
182285    return  { 
183286      id : relPath . replace ( / \/ / g,  '_' ) . replace ( / \. ( m d | m d x ) $ / ,  '' ) , 
184-       title : data . title  ||  data . sidebar_label  ||  path . basename ( file ,  path . extname ( file ) ) , 
287+       title :
288+         data . title  || 
289+         data . sidebar_label  || 
290+         path . basename ( file ,  path . extname ( file ) ) , 
185291      content : fullContent , 
186292      path : normPath , 
187293      description : data . description  ||  summary , 
0 commit comments