File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 55const { stripHTML } = require ( 'hexo-util' ) ;
66
77const getWordCount = ( post ) => {
8- const lang = post . lang . toLowerCase ( ) ;
98 // post.origin is the original post content of hexo-blog-encrypt
109 const content = stripHTML ( post . origin || post . content ) . replace ( / \r ? \n | \r / g, '' ) . replace ( / \s + / g, '' ) ;
1110
1211 if ( ! post . wordcount ) {
13- if ( [ 'zh-cn' , 'zh-hk' , 'zh-tw' ] . includes ( lang ) ) {
14- post . wordcount = ( content . match ( / [ \u4E00 - \u9FA5 ] / g) || [ ] ) . length ;
15- } else {
16- post . wordcount = ( content . replace ( / [ \u4E00 - \u9FA5 ] / g, '' ) . match ( / [ a - z A - Z 0 - 9 _ \u0392 - \u03c9 \u0400 - \u04FF ] + | [ \u4E00 - \u9FFF \u3400 - \u4dbf \uf900 - \ufaff \u3040 - \u309f \uac00 - \ud7af \u0400 - \u04FF ] + | [ \u00E4 \u00C4 \u00E5 \u00C5 \u00F6 \u00D6 ] + | \w + / g) || [ ] ) . length ;
17- }
12+ const zhCount = ( content . match ( / [ \u4E00 - \u9FA5 ] / g) || [ ] ) . length ;
13+ const enCount = ( content . replace ( / [ \u4E00 - \u9FA5 ] / g, '' ) . match ( / [ a - z A - Z 0 - 9 _ \u0392 - \u03c9 \u0400 - \u04FF ] + | [ \u4E00 - \u9FFF \u3400 - \u4dbf \uf900 - \ufaff \u3040 - \u309f \uac00 - \ud7af \u0400 - \u04FF ] + | [ \u00E4 \u00C4 \u00E5 \u00C5 \u00F6 \u00D6 ] + | \w + / g) || [ ] ) . length ;
14+ post . wordcount = zhCount + enCount
1815 }
1916 return post . wordcount ;
2017} ;
You can’t perform that action at this time.
0 commit comments