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 7967097
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/backend/src/core/TutorialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ export class TutorialService {
getTutorials(): HomeTutorialEntry[] {
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((filename) => this.toTutorialEntry(filename))
} 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 7967097

Please sign in to comment.