-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
173 lines (158 loc) · 5.42 KB
/
gatsby-node.js
File metadata and controls
173 lines (158 loc) · 5.42 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
const _ = require("lodash");
const path = require("path");
const { createFilePath } = require("gatsby-source-filesystem");
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions;
const typeDefs = [
"type MarkdownRemark implements Node { frontmatter: Frontmatter }",
`type PluripotencyRow {
marker: String
positive_cells: Float
}
type TrilineageRow {
germ_layer: String
marker: String
percent_positive_cells: String
}
type CardiomyocyteDifferentiation {
troponin_percent_positive: String
day_of_beating_percent: String
day_of_beating_range: String
}
type RnaSeqRow {
image: File @fileByRelativePath
caption: String
}
type StemCellCharacteristics {
pluripotency_analysis: [PluripotencyRow]
pluripotency_caption: String
trilineage_differentiation: [TrilineageRow]
trilineage_caption: String
cardiomyocyte_differentiation: CardiomyocyteDifferentiation
cardiomyocyte_differentiation_caption: String
rnaseq_analysis: [RnaSeqRow]
}
type NavBarDropdownItem {
label: String
href: String
}
type NavBarDropdownItemGroup {
label: String
options: [NavBarDropdownItem]
}
`,
`type GeneticModification {
gene: MarkdownRemark @link(by: "frontmatter.geneId", from: "gene")
allele_count: String
tag_location: String
fluorescent_tag: String
}`,
` type ImgWithCaption {
image: File @fileByRelativePath
caption: String
}
type Diagram {
title: String
images: [ImgWithCaption]
}
type DdpcrRow {
tag: String
clone: Float
fp_ratio: Float
plasmid: Float
}
type AmplifiedJunction {
edited_gene: String
junction: String
expected_size: String
confirmed_sequence: String
}
type OffTargetRow {
clones_analyzed: Float
off_targets_sequenced_per_clone: Float
total_sites_sequenced: Float
mutations_identified: Float
}
type MarkdownRemarkFrontmatterGenomic_characterization {
diagrams: [Diagram]
amplified_junctions: [AmplifiedJunction]
junction_table_caption: String
ddpcr: [DdpcrRow]
ddpcr_caption: String
cr_rna_off_targets: [OffTargetRow]
off_targets_caption: String
} `,
`type Frontmatter {
disease: MarkdownRemark @link(by: "frontmatter.name")
genetic_modifications: [GeneticModification]
gene: [MarkdownRemark] @link(by: "frontmatter.symbol", from: "gene")
parental_line: MarkdownRemark @link(by: "frontmatter.cell_line_id")
funding_text: String @md
footer_text: String @md
genomic_characterization: MarkdownRemarkFrontmatterGenomic_characterization
stem_cell_characteristics: StemCellCharacteristics
catalogs: [NavBarDropdownItem]
protocols: [NavBarDropdownItemGroup]
normalCollections: [NavBarDropdownItem]
diseaseCollections: [NavBarDropdownItem]
}`,
];
createTypes(typeDefs);
};
exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions;
return graphql(`
{
allMarkdownRemark(limit: 1000) {
edges {
node {
id
fields {
slug
}
frontmatter {
templateKey
}
}
}
}
}
`).then((result) => {
if (result.errors) {
result.errors.forEach((e) => console.error(e.toString()));
return Promise.reject(result.errors);
}
const edges = result.data.allMarkdownRemark.edges;
edges.forEach((edge) => {
const id = edge.node.id;
const templateKey = edge.node.frontmatter.templateKey;
// Skip creating pages for data-only markdown files
if (templateKey === "nav-bar") {
return;
}
createPage({
path: edge.node.fields.slug,
component: path.resolve(
`src/templates/${String(
edge.node.frontmatter.templateKey,
)}.tsx`,
),
// additional data can be passed via context
context: {
id,
},
});
});
});
};
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode });
createNodeField({
name: `slug`,
node,
value,
});
}
};