Skip to content

Commit

Permalink
add image name to info
Browse files Browse the repository at this point in the history
  • Loading branch information
gcharang committed Aug 28, 2023
1 parent bf46076 commit 697e82e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 10 additions & 5 deletions authors.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"linkedin": ""
},
"id": 21151592,
"avatar_url": "https://avatars.githubusercontent.com/u/21151592?v=4"
"avatar_url": "https://avatars.githubusercontent.com/u/21151592?v=4",
"image": "gcharang.jpeg"
},
"smk762": {
"username": "smk762",
Expand All @@ -23,7 +24,8 @@
"linkedin": ""
},
"id": 35845239,
"avatar_url": "https://avatars.githubusercontent.com/u/35845239?v=4"
"avatar_url": "https://avatars.githubusercontent.com/u/35845239?v=4",
"image": "smk762.png"
},
"Emmaccen": {
"username": "Emmaccen",
Expand All @@ -36,7 +38,8 @@
"linkedin": "https://www.linkedin.com/in/emmanuel-lucius-emmaccen/"
},
"id": 58217705,
"avatar_url": "https://avatars.githubusercontent.com/u/58217705?v=4"
"avatar_url": "https://avatars.githubusercontent.com/u/58217705?v=4",
"image": "Emmaccen.jpeg"
},
"gaeacodes": {
"username": "gaeacodes",
Expand All @@ -48,7 +51,8 @@
"linkedin": ""
},
"id": 77043250,
"avatar_url": "https://avatars.githubusercontent.com/u/77043250?v=4"
"avatar_url": "https://avatars.githubusercontent.com/u/77043250?v=4",
"image": "gaeacodes.png"
},
"borngraced": {
"username": "borngraced",
Expand All @@ -58,6 +62,7 @@
"linkedin": ""
},
"id": 51881311,
"avatar_url": "https://avatars.githubusercontent.com/u/51881311?v=4"
"avatar_url": "https://avatars.githubusercontent.com/u/51881311?v=4",
"image": "borngraced.png"
}
}
9 changes: 6 additions & 3 deletions utils/get_file_author_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const fileData = {};
authorsData[contributor.login].id = contributor.id
authorsData[contributor.login].avatar_url = contributor.avatar_url
});
fs.writeFileSync("authors.json", JSON.stringify(authorsData, null, 4))
} catch (error) {
console.error(error);
}
Expand All @@ -46,9 +45,13 @@ const fileData = {};
// const fileExt = respHeaders["content-type"].split("/")[1]
// const imgFilename = `./src/images/authors/${username}.${fileExt}`
// fs.writeFileSync(imgFilename, imgResponse)
await downloadImage(imageUrl, username)
const imgName = await downloadImage(imageUrl, username)
authorsData[username].image = imgName
}

fs.writeFileSync("authors.json", JSON.stringify(authorsData, null, 4))


walkDir("./src/pages", getAllFileData);
fs.writeFileSync("./utils/_fileData.json", JSON.stringify(fileData, null, 2));
})();
Expand Down Expand Up @@ -104,7 +107,7 @@ async function downloadImage(url, username) {
file.on('finish', () => {
file.close();
console.log('Image downloaded successfully: ' + filename);
resolve(true)
resolve(`${username}.${fileExt}`)
});
}).on('error', (error) => {
fs.unlink(filename);
Expand Down

0 comments on commit 697e82e

Please sign in to comment.