-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.ts
65 lines (61 loc) · 1.6 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { AboutSectionType, SectionGroupType } from "./src/types"
const titleToPath = (title: string) => title.toLowerCase().replace(" ", "-")
exports.createPages = async ({ actions, graphql }) => {
const {
data: {
site: {
siteMetadata: { projects },
},
},
} = await graphql(`
query DocumentationQuery {
site {
siteMetadata {
projects {
description
documentation {
path
sectionGroups {
sections {
path
title
type
}
title
type
}
}
name
}
}
}
}
`)
projects.forEach(project => {
actions.createPage({
context: { projectConfiguration: project },
component: require.resolve(
`./src/documentation/${project.name}/about/overview.tsx`
),
path: project.documentation.path,
})
project.documentation.sectionGroups.forEach(sectionGroup => {
sectionGroup.sections.forEach(section => {
if (
sectionGroup.title === SectionGroupType.About &&
section.type === AboutSectionType.Overview
)
return
actions.createPage({
context: { projectConfiguration: project },
component: require.resolve(
`./src/documentation/${project.name}/${titleToPath(
sectionGroup.title
)}/${section.path}.tsx`
),
path: `${project.documentation.path}${section.path}`,
})
})
})
})
}