Skip to content

Commit

Permalink
fix issue with getting tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
torztomasz committed Aug 28, 2023
1 parent 650bdba commit 1976315
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/backend/src/core/TutorialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import fs from 'fs'

export class TutorialService {
getTutorials(): HomeTutorialEntry[] {
const files = fs.readdirSync('src/content/tutorials')
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) => {
const filenameWithoutExt = filename.replace('.md', '')
return {
title: filenameWithoutExt.replaceAll('-', ' '),
imageUrl: `/images/${filenameWithoutExt}.jpg`,
slug: filenameWithoutExt.toLowerCase(),
}
})
} catch {
return []
}
}
}

0 comments on commit 1976315

Please sign in to comment.