Skip to content

Commit

Permalink
add to entry fn
Browse files Browse the repository at this point in the history
  • Loading branch information
torztomasz committed Aug 28, 2023
1 parent 1976315 commit c0f57fd
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/backend/src/core/TutorialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ export class TutorialService {
try {
const files = fs.readdirSync('src/content/tutorials')

return files.map((filename) => {
const filenameWithoutExt = filename.replace('.md', '')
return {
title: filenameWithoutExt.replaceAll('-', ' '),
imageUrl: `/images/${filenameWithoutExt}.jpg`,
slug: filenameWithoutExt.toLowerCase(),
}
})
return files.map(this.toTutorialEntry)
} catch {
return []
}
}

private toTutorialEntry(filename: string): HomeTutorialEntry {
const filenameWithoutExt = filename.replace('.md', '')
return {
title: filenameWithoutExt.replaceAll('-', ' '),
imageUrl: `/images/${filenameWithoutExt}.jpg`,
slug: filenameWithoutExt.toLowerCase(),
}
}
}

0 comments on commit c0f57fd

Please sign in to comment.