Skip to content

Commit e4d1fd8

Browse files
author
chandan-reddy-k
committed
contributor file fix
1 parent f60dede commit e4d1fd8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pages/contributors/[slug].js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ export async function getServerSideProps({ params }) {
3131
let contributorsArray = []
3232
contributorFiles.map(filename => {
3333
const filePath = path.join(contributorsDirectory, filename)
34-
const fileContents = JSON.parse(fs.readFileSync(filePath, 'utf8'))
35-
contributorsArray.push(fileContents)
34+
try {
35+
const fileContents = JSON.parse(fs.readFileSync(filePath, 'utf8'))
36+
contributorsArray.push(fileContents)
37+
}
38+
catch (e) {
39+
console.log('Error reading file -' + filename)
40+
}
41+
3642
})
37-
43+
3844
let obj = contributorsArray.find(o => o["github-username"] === `${params.slug}`);
3945

4046
return {

0 commit comments

Comments
 (0)