Skip to content

Commit 54a632b

Browse files
committed
optional contributor fetch
1 parent 05dae8c commit 54a632b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

gatsby-node.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ exports.createPages = ({ actions, graphql }) => {
3939
const edges = res.data.allFile.edges
4040
for (let i = 0; i < edges.length; i++) {
4141
const filename = edges[i].node.name
42-
const { data: contributorsRaw } = await axios.get(
43-
`https://api.github.com/repos/devsonket/devsonket.github.io/commits?path=data/${filename}.json`,
44-
{
45-
headers: {
46-
Authorization: `Bearer ${process.env.GATSBY_GITHUB_TOKEN}`,
47-
},
48-
}
49-
)
50-
contributors[filename] = contributorMap(contributorsRaw)
42+
try {
43+
const { data: contributorsRaw } = await axios.get(
44+
`https://api.github.com/repos/devsonket/devsonket.github.io/commits?path=data/${filename}.json`,
45+
{
46+
headers: {
47+
Authorization: `Bearer ${process.env.GATSBY_GITHUB_TOKEN}`,
48+
},
49+
}
50+
)
51+
contributors[filename] = contributorMap(contributorsRaw)
52+
} catch {
53+
contributors[filename] = {}
54+
}
5155
}
5256
res.data.allFile.edges.map(({ node }) => {
5357
const filename = node.name

0 commit comments

Comments
 (0)