@@ -18,10 +18,13 @@ import { toPosixPath } from "./relativePath"
18
18
19
19
import { ITutorial } from "@/pages/developers/tutorials"
20
20
21
- const CURRENT_CONTENT_DIR = join ( process . cwd ( ) , CONTENT_DIR )
21
+ function getCurrentDir ( ) {
22
+ return join ( process . cwd ( ) , CONTENT_DIR )
23
+ }
22
24
23
25
const getPostSlugs = ( dir : string , files : string [ ] = [ ] ) => {
24
- const contentDir = join ( CURRENT_CONTENT_DIR , dir )
26
+ const currentDir = getCurrentDir ( )
27
+ const contentDir = join ( currentDir , dir )
25
28
// Temporal list of content pages allowed to be compiled
26
29
// When a content page is migrated (and he components being used), should be added to this list
27
30
const temporalAllowedPages = [
@@ -290,14 +293,12 @@ const getPostSlugs = (dir: string, files: string[] = []) => {
290
293
if ( fileExtension === ".md" ) {
291
294
// If it is a .md file (allowed content page), push the path to the files array
292
295
for ( const page of temporalAllowedPages ) {
293
- const fullPagePath = join ( CURRENT_CONTENT_DIR , page )
296
+ const fullPagePath = join ( currentDir , page )
294
297
295
298
if ( name . includes ( fullPagePath ) ) {
296
299
files . push (
297
300
toPosixPath (
298
- fullPagePath
299
- . replace ( CURRENT_CONTENT_DIR , "" )
300
- . replace ( "/index.md" , "" )
301
+ fullPagePath . replace ( currentDir , "" ) . replace ( "/index.md" , "" )
301
302
)
302
303
)
303
304
}
@@ -320,7 +321,8 @@ export const getContentBySlug = (slug: string) => {
320
321
}
321
322
}
322
323
323
- let fullPath = toPosixPath ( join ( CURRENT_CONTENT_DIR , realSlug ) )
324
+ const currentDir = getCurrentDir ( )
325
+ let fullPath = toPosixPath ( join ( currentDir , realSlug ) )
324
326
let contentNotTranslated = false
325
327
326
328
// If content is not translated, use english content fallback
@@ -350,8 +352,9 @@ export const getContent = (dir: string) => {
350
352
}
351
353
352
354
export const getTutorialsData = ( locale : string ) : ITutorial [ ] => {
355
+ const currentDir = getCurrentDir ( )
353
356
const fullPath = join (
354
- CURRENT_CONTENT_DIR ,
357
+ currentDir ,
355
358
locale !== "en" ? `translations/${ locale ! } ` : "" ,
356
359
"developers/tutorials"
357
360
)
@@ -362,7 +365,7 @@ export const getTutorialsData = (locale: string): ITutorial[] => {
362
365
363
366
tutorialData = languageTutorialFiles . map ( ( dir ) => {
364
367
const filePath = join (
365
- CURRENT_CONTENT_DIR ,
368
+ currentDir ,
366
369
locale !== "en" ? `translations/${ locale ! } ` : "" ,
367
370
"developers/tutorials" ,
368
371
dir ,
0 commit comments