@@ -6,21 +6,15 @@ import path from "path";
6
6
7
7
const handler = ( req : NextApiRequest , res : NextApiResponse ) => {
8
8
try {
9
- const __next__base__dirname = __dirname . split ( ".next" ) [ 0 ] as string ;
10
- let contentDir = path . join ( CONTENT_PATH ) ;
11
- if ( process . env . NODE_ENV === "production" ) {
12
- contentDir = path . join ( __next__base__dirname , CONTENT_PATH ) ;
13
- }
14
- const directories = fs . readdirSync ( path . join ( contentDir ) ) ;
9
+ const dir = path . resolve ( "./" , CONTENT_PATH ) ;
10
+ const directories = fs . readdirSync ( dir ) ;
15
11
const lessons : object [ ] = [ ] ;
16
12
directories . reverse ( ) . map ( ( folder ) => {
17
- if ( fs . lstatSync ( path . join ( contentDir , folder ) ) . isDirectory ( ) ) {
18
- fs . readdirSync ( path . join ( contentDir , folder ) ) . map ( ( file ) => {
19
- if (
20
- ! fs . lstatSync ( path . join ( contentDir , folder , file ) ) . isDirectory ( )
21
- ) {
13
+ if ( fs . lstatSync ( path . join ( dir , folder ) ) . isDirectory ( ) ) {
14
+ fs . readdirSync ( path . join ( dir , folder ) ) . map ( ( file ) => {
15
+ if ( ! fs . lstatSync ( path . join ( dir , folder , file ) ) . isDirectory ( ) ) {
22
16
const markdownWithMeta = fs . readFileSync (
23
- path . join ( contentDir , folder , file ) ,
17
+ path . join ( dir , folder , file ) ,
24
18
"utf-8" ,
25
19
) ;
26
20
0 commit comments