-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
149 lines (135 loc) · 3.23 KB
/
gatsby-node.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
const { publicDecrypt } = require("crypto")
const path = require(`path`)
const papers = require("./src/content/acml-papers.json")
const talkTutorialVideos = require("./src/content/talk-tutorial-videos.json")
const sectionMenuGroup = {
calls:[
{
name: `Information`,
slug: `/calls`
},
{
name: `Conference Track`,
slug: `/calls/conference-track`
},
{
name: `Journal Track`,
slug: `/calls/journal-track`
},
{
name: `Tutorials`,
slug: `/calls/tutorials`
},
{
name: `Workshops`,
slug: `/calls/workshops`
},
{
name: `ACML Distinguished Contribution Award`,
slug: `/calls/nominations`
},
],
program: [
{
name: `Main Conference`,
slug: `/program/papers`
},
{
name: `Invited Speakers`,
slug: `/program/invited-speakers`
},
{
name: `Awards`,
slug: `/program/awards`
},
{
name: `Tutorials`,
slug: `/program/tutorials`
},
{
name: `Workshops`,
slug: `/program/workshops`
},
]
}
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions
const blogPostTemplate = path.resolve(`src/templates/page.js`)
const callTemplate = path.resolve(`src/templates/pageWithMenu.js`)
const videoTemplate = path.resolve(`src/templates/videoPage.js`)
const result = await graphql(`
{
allMarkdownRemark(
limit: 1000
) {
edges {
node {
frontmatter {
path
withSectionMenu
}
}
}
}
}
`)
// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`)
return
}
const pages = result.data.allMarkdownRemark.edges
.filter(n => n.node.frontmatter.path)
const normalPages = pages.filter(n => !n.node.frontmatter.withSectionMenu)
normalPages.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: blogPostTemplate,
context: {}, // additional data can be passed via context
})
})
pages.filter(n => n.node.frontmatter.withSectionMenu).forEach(({ node }) => {
const group = node.frontmatter.path.split("/")[1]
createPage({
path: node.frontmatter.path,
component: callTemplate,
context: {
sectionMenu: sectionMenuGroup[group],
sectionName: group
}, // additional data can be passed via context
})
const videos = papers.map(p => {
const urls = p.crossref === "acml20" ?
{
pmlrURL: `http://proceedings.mlr.press/v129/${p.ID}.html`,
pdfURL: `http://proceedings.mlr.press/v129/${p.ID}/${p.ID}.pdf`,
} :
{
jmlrURL: ``,
pdfURL: p.url,
}
return {
type: "paper",
id: p.ID,
title: p.title,
by: p.author,
abstract: p.abstract,
videolectureId: p.ID,
...urls
}
}).concat(talkTutorialVideos.map(t => {
return {
id: t.by.toLowerCase().replace(/ /g, "-"),
...t
}
}))
videos.forEach( p => {
console.log(`Creating video page for ${p.type}-${p.title}`)
createPage({
path: `video/${p.type}/${p.id}`,
component: videoTemplate,
context: p
})
})
})
}