Skip to content

Commit 0b31af5

Browse files
committed
Display chapter-specific sponsors
- Add city context to chapter nodes in gatsby-node.js - Add city field to seattle sponsors data - Add list of sponsors to chapter template - Add query for filtered sponsors based on city to chapter template - Add city to CMS config sponsor schema
1 parent d954d39 commit 0b31af5

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

content/sponsors/climate-corporation.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
"url": "https://climate.com/",
44
"logo": "/images/climate-corporation.jpg",
55
"sponsorships": [
6-
{ "year": "2019", "level": "Local Meetup SEA", "conf_sponsor": false },
7-
{ "year": "2019", "level": "Local Meetup SF", "conf_sponsor": false }
6+
{
7+
"year": "2019",
8+
"level": "Local Meetup SEA",
9+
"conf_sponsor": false,
10+
"city": "Seattle"
11+
},
12+
{
13+
"year": "2019",
14+
"level": "Local Meetup SF",
15+
"conf_sponsor": false,
16+
"city": "San Francisco"
17+
}
818
]
919
}

content/sponsors/glympse.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"url": "https://www.glympse.com",
44
"logo": "/images/glympse.jpg",
55
"sponsorships": [
6-
{ "year": "2019", "level": "Local Meetup SEA", "conf_sponsor": false }
6+
{
7+
"year": "2019",
8+
"level": "Local Meetup SEA",
9+
"conf_sponsor": false,
10+
"city": "Seattle"
11+
}
712
]
813
}

gatsby-node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ exports.createPages = ({ actions, graphql }) => {
8080

8181
chapterPages.forEach(edge => {
8282
const id = edge.node.id
83+
const city = edge.node.city
8384
createPage({
8485
path: edge.node.fields.slug,
8586
component: path.resolve(`src/templates/chapter.js`),
8687
context: {
8788
id,
89+
city,
8890
},
8991
})
9092
})

src/templates/chapter.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import { graphql } from 'gatsby'
33
import Layout from '../layouts/default'
44

55
const ChapterTemplate = ({ data }) => {
6-
const { chaptersJson: chapter } = data
6+
const { chaptersJson: chapter, allSponsorsJson: sponsors } = data
77
return (
88
<Layout>
99
<section>
1010
<h1>{chapter.city}</h1>
11+
<ul>
12+
{sponsors.edges.map(sponsor => (
13+
<li key={sponsor.node.id}>{sponsor.node.name}</li>
14+
))}
15+
</ul>
1116
</section>
1217
</Layout>
1318
)
@@ -16,9 +21,21 @@ const ChapterTemplate = ({ data }) => {
1621
export default ChapterTemplate
1722

1823
export const chapterQuery = graphql`
19-
query Chapter($id: String!) {
24+
query Chapter($id: String!, $city: String!) {
2025
chaptersJson(id: { eq: $id }) {
2126
city
2227
}
28+
allSponsorsJson(
29+
filter: { sponsorships: { elemMatch: { city: { eq: $city } } } }
30+
) {
31+
edges {
32+
node {
33+
id
34+
name
35+
logo
36+
url
37+
}
38+
}
39+
}
2340
}
2441
`

static/admin/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ collections:
197197
widget: 'boolean'
198198
default: false
199199
required: false
200+
- label: 'City'
201+
name: 'city'
202+
widget: 'string'
203+
required: false
200204

201205
- name: 'organizers'
202206
label: 'Organizers'

0 commit comments

Comments
 (0)