Skip to content

Commit 155c13c

Browse files
committed
almost done
1 parent 7fa3ef3 commit 155c13c

File tree

9 files changed

+65
-55
lines changed

9 files changed

+65
-55
lines changed

web/.env.production

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
GATSBY_SANITY_PROJECT_ID="atggkqis"
2-
GATSBY_SANITY_DATASET="production"
1+
GATSBY_AIRTABLE_KEY=keyJugfwdJzOyL7Aa

web/gatsby-config.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Load variables from `.env` as soon as possible
22
require('dotenv').config({
3-
path: `.env.${process.env.NODE_ENV || 'development'}`
3+
path: `.env.production`
44
})
55

6-
const isProd = process.env.NODE_ENV === 'production'
7-
86
module.exports = {
97
plugins: [
108
`gatsby-plugin-styled-components`,
@@ -22,6 +20,19 @@ module.exports = {
2220
}
2321
}
2422
},
23+
{
24+
resolve: `gatsby-source-airtable`,
25+
options: {
26+
apiKey: process.env.GATSBY_AIRTABLE_KEY,
27+
tables: [
28+
{
29+
baseId: `appXX3u6yUPjqQFrE`,
30+
tableName: `all`,
31+
queryName: `attendees` // optional
32+
}
33+
]
34+
}
35+
},
2536
'gatsby-transformer-javascript-frontmatter',
2637
{
2738
resolve: `gatsby-source-filesystem`,

web/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
},
2424
"dependencies": {
2525
"@sanity/client": "0.141.5",
26+
"airtable": "^0.7.1",
2627
"animate.css": "^3.7.2",
2728
"babel-plugin-styled-components": "1.10.6",
2829
"gatsby-image": "2.2.4",
2930
"gatsby-plugin-styled-components": "3.1.0",
3031
"gatsby-plugin-webfonts": "1.0.12",
32+
"gatsby-source-airtable": "^2.0.8",
3133
"gatsby-source-filesystem": "^2.1.18",
3234
"gatsby-source-graphql": "2.1.0",
3335
"gatsby-transformer-javascript-frontmatter": "^2.1.5",

web/src/components/Attendees/index.js

+15-22
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import React from 'react'
33
import { Attendees } from './elements'
44
import shuffle from '../../helpers/shuffle'
55

6-
const dedupeAttendees = (attendeesArray) => {
7-
const list = [];
6+
const dedupeAttendees = attendeesArray => {
7+
const list = []
88
const deduped = attendeesArray.reduce((acc, current) => {
9-
const cleanGhLink = current.ghLink.startsWith('@') ? current.ghLink.slice(1) : current.ghLink
10-
9+
const cleanGhLink = current.data.ghLink.startsWith('@')
10+
? current.data.ghLink.slice(1)
11+
: current.data.ghLink
1112

1213
if (list.includes(cleanGhLink)) {
13-
return acc;
14+
return acc
1415
}
1516

1617
list.push(cleanGhLink)
@@ -23,31 +24,23 @@ const dedupeAttendees = (attendeesArray) => {
2324
}
2425

2526
export default ({ attendees }) => {
26-
2727
const dedupedAttendees = dedupeAttendees(attendees)
2828

2929
return (
3030
<Attendees>
31-
{shuffle(dedupedAttendees).map(a => {
31+
{shuffle(dedupedAttendees).map(({ data: a }) => {
3232
// Pretty ugly but this way we do not get duplicate https://github.com urls
3333

3434
const cleanGhLink = a.ghLink.startsWith('@') ? a.ghLink.slice(1) : a.ghLink
3535

36-
const ghLink = `https://github.com/${cleanGhLink.trim().replace('https://github.com/', '')}`;
37-
return (<li key={a.id}>
38-
<a
39-
href={ghLink}
40-
target="_blank"
41-
title={a.name}
42-
rel="noopener noreferrer"
43-
>
44-
<img
45-
src={`${ghLink}.png?size=50`}
46-
alt={a.name}
47-
width="50"
48-
/>
49-
</a>
50-
</li>);
36+
const ghLink = `https://github.com/${cleanGhLink.trim().replace('https://github.com/', '')}`
37+
return (
38+
<li key={a.id}>
39+
<a href={ghLink} target="_blank" title={a.name} rel="noopener noreferrer">
40+
<img src={`${ghLink}.png?size=50`} alt={a.name} width="50" />
41+
</a>
42+
</li>
43+
)
5144
})}
5245
</Attendees>
5346
)

web/src/components/Figure.js

-13
This file was deleted.

web/src/components/Info/index.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React, { useState } from 'react'
22
import format from 'date-fns/format'
3+
import Airtable from 'airtable'
34

45
import Flag from '../icons/flag'
56
import Calendar from '../icons/calendar'
67

78
import { Info, Button, RsvpButton, Form, Blinker, Bouncer } from './elements'
8-
import client from '../../helpers/sanity'
99

10-
export default ({ site, dataset }) => {
10+
var base = new Airtable({ apiKey: process.env.GATSBY_AIRTABLE_KEY }).base('appXX3u6yUPjqQFrE')
11+
12+
export default ({ site, city }) => {
1113
const [open, setOpen] = useState(false)
1214
const [name, setName] = useState('')
1315
const [gh, setGH] = useState('')
@@ -16,16 +18,19 @@ export default ({ site, dataset }) => {
1618
const createUser = () => {
1719
if (name && gh) {
1820
const doc = {
19-
_type: 'attendee',
21+
city: city,
2022
name: name,
2123
ghLink: gh
2224
}
2325

24-
client(dataset)
25-
.create(doc)
26-
.then(res => {
27-
console.log(`Human was created, document ID is ${res._id}`)
28-
})
26+
base('all').create(doc, function(err, record) {
27+
if (err) {
28+
console.error(err)
29+
return
30+
}
31+
console.log(`Human was created, document ID is ${record.getId()}`)
32+
console.log(record.getId())
33+
})
2934
}
3035
}
3136

web/src/components/Speakers/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import Figure from '../Figure'
32
import RainbowWithClicker from '../rainbow/RainbowWithClicker'
43

54
import {

web/src/pages/_main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import Layout from '../containers/layout'
44
import Sponsors from '../components/Sponsors'
55
import Info from '../components/Info'
66
import Speakers from '../components/Speakers'
7+
import Attendees from '../components/Attendees'
78
import Thanks from '../components/Thanks'
89
import Panel from '../components/Panel'
910
import Heading from '../components/Heading'
1011

11-
const Main = ({ city }) => {
12+
const Main = ({ city, attendees }) => {
1213
const { site, organizers, mainOrganizer, thanks, speakers, sponsors, info } = city
1314

1415
return (
1516
<Layout>
1617
<SEO title={site.title} description={site.description} />
1718
<main>
1819
<Heading sub="queerjs @">{info.city}</Heading>
19-
<Info site={site} />
20+
<Info site={site} city={info.link} />
2021
<Panel heading="What?">
2122
<p>
2223
This is a meetup where anyone is welcome to attend and support the speakers and the idea
@@ -35,9 +36,10 @@ const Main = ({ city }) => {
3536
<Speakers noSpeak cfp={site.cfp} speakers={speakers.filter(s => s.mc)} />
3637
</Panel>
3738
) : null}
38-
{/* <Panel heading={`Attendees (${attendees.length})`}>
39+
{console.log(attendees)}
40+
<Panel heading={`Attendees (${attendees.length})`}>
3941
<Attendees attendees={attendees} />
40-
</Panel> */}
42+
</Panel>
4143

4244
<Panel heading="Sponsors">
4345
<Sponsors sponsors={sponsors} />

web/src/templates/city.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ import Main from '../pages/_main'
44

55
export default ({ data = {} }) => {
66
const {
7-
javascriptFrontmatter: { frontmatter }
7+
javascriptFrontmatter: { frontmatter },
8+
allAirtable: { edges }
89
} = data
9-
return <Main city={frontmatter} />
10+
return <Main city={frontmatter} attendees={edges.map(edge => edge.node)} />
1011
}
1112

1213
export const query = graphql`
1314
query($slug: String!) {
15+
allAirtable(filter: { data: { city: { eq: $slug } } }) {
16+
edges {
17+
node {
18+
data {
19+
city
20+
ghLink
21+
name
22+
}
23+
}
24+
}
25+
}
1426
javascriptFrontmatter(frontmatter: { info: { link: { eq: $slug } } }) {
1527
frontmatter {
1628
info {

0 commit comments

Comments
 (0)