-
Notifications
You must be signed in to change notification settings - Fork 8
/
gatsby-node.ts
38 lines (36 loc) · 939 Bytes
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { GatsbyNode } from 'gatsby'
import { resolve } from 'path'
import { extractRepositories, repositoryAttributes, QueryData } from './src/data/github'
export const createPages: GatsbyNode['createPages'] = async ({
actions,
graphql
}) => {
const query: {
errors?: any
data?: QueryData
} = await graphql(`
query {
github {
search(type: REPOSITORY, first: 20, query: "org:near-examples topic:ready-to-use") {
repositoryCount
pageInfo {
hasNextPage
endCursor
}
repositories: nodes {
... on GitHub_Repository {
${repositoryAttributes}
}
}
}
}
}
`)
query.data && extractRepositories(query.data).forEach(repo => {
actions.createPage({
path: repo.name,
component: resolve('./src/templates/repository.tsx'),
context: { name: repo.name }
})
})
}