File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,18 @@ export function getAllCategories(): string[] {
7979 return Array . from ( categories ) . sort ( )
8080}
8181
82- export function countAllImages ( ) : number {
83- // @todo
84- return 0 ;
82+ export function countAllImages ( dir : string = 'public' ) : number {
83+ let count = 0 ;
84+ const entries = fs . readdirSync ( dir , { withFileTypes : true } ) ;
85+ for ( const entry of entries ) {
86+ const fullPath = path . join ( dir , entry . name ) ;
87+ if ( entry . isDirectory ( ) ) {
88+ count += countAllImages ( fullPath ) ;
89+ } else if ( entry . isFile ( ) && / \. ( p n g | j p e ? g ) $ / i. test ( entry . name ) ) {
90+ count ++ ;
91+ }
92+ }
93+ return count ;
8594}
8695
8796export async function markdownToHtml ( markdown : string ) : Promise < string > {
Original file line number Diff line number Diff line change 1-
21export const capitalize = ( s : string ) => s . charAt ( 0 ) . toUpperCase ( ) + s . slice ( 1 ) ;
32
43export const toDate = ( date : string ) => new Date ( date ) . toLocaleDateString ( 'ru-RU' ) ;
You can’t perform that action at this time.
0 commit comments