diff --git a/README.md b/README.md index 0582cf9..6e73c17 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Stuff you need installed ahead of time: Clone it! - $ git clone https://github.com/hackclub/hackathons + $ git clone https://github.com/hackclub/hackathons.git Go into the directory! diff --git a/components/banner.js b/components/banner.js new file mode 100644 index 0000000..b7207db --- /dev/null +++ b/components/banner.js @@ -0,0 +1,68 @@ +import { Card, Text } from 'theme-ui' +import { keyframes } from '@emotion/react' +import Icon from '@hackclub/icons' + +const flip = keyframes({ + from: { transform: 'scaleY(0)' }, + to: { transform: 'scaleY(100%)' } +}) + +const Banner = ({ + caption, + copy, + iconLeft, + iconRight, + color = 'accent', + sx = {}, + ...props +}) => ( + + {iconLeft && ( + + )} + + {copy} + {caption && ( + + {' '} + {caption} + + )} + + {iconRight && } + +) + +export default Banner diff --git a/lib/data.js b/lib/data.js index 54e2337..59d958c 100644 --- a/lib/data.js +++ b/lib/data.js @@ -14,7 +14,7 @@ const normalizeWebsite = url => { export const getEvents = async () => { let events = await getJSON( - 'https://airbridge.hackclub.com/v0/hackathons.hackclub.com/applications?select=%7B%22filterByFormula%22:%22approved=1%22%7D' + 'https://api2.hackclub.com/v0.1/hackathons.hackclub.com/applications?select%7B%22filterByFormula%22:%22approved=1%22%7D' ) events = filter(events, 'fields.approved') events = events.map( @@ -34,7 +34,8 @@ export const getEvents = async () => { latitude: fields.lat, longitude: fields.lng, virtual: fields.virtual || false, - mlhAssociated: fields.mlh_associated || false + mlhAssociated: fields.mlh_associated || false, + apac: fields.apac || false }) ) diff --git a/lib/regions.json b/lib/regions.json index db382fe..616c819 100644 --- a/lib/regions.json +++ b/lib/regions.json @@ -6,6 +6,6 @@ "the Bay Area": "https://images.unsplash.com/photo-1501196788499-459dbea97736?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=512&q=80", "the USA": "https://www.nps.gov/yose/planyourvisit/images/20170618_155330.jpg?maxwidth=512&maxheight=400&autorotate=false", "Canada": "https://images.unsplash.com/photo-1479854851860-18d97e109331?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDk0fQ&auto=format&fit=crop&w=512&q=80", - "India": "https://images.unsplash.com/photo-1564507592333-c60657eea523?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=512&q=80" + "Asia-Pacific": "https://cdn.britannica.com/86/170586-050-AB7FEFAE/Taj-Mahal-Agra-India.jpg?maxwidth=512&maxheight=400&autorotate=false" } } diff --git a/next.config.js b/next.config.js index 23afcff..e600116 100644 --- a/next.config.js +++ b/next.config.js @@ -3,8 +3,28 @@ const nextConfig = { pageExtensions: ['js', 'jsx', 'mdx'], eslint: { ignoreDuringBuilds: true + }, + async redirects() { + return [ + { + source: '/india', + destination: '/apac', + permanent: false + }, + { + source: '/list-of-hackathons-in-asia-pacific', + destination: '/apac', + permanent: false + }, + { + source: '/list-of-hackathons-in-india', + destination: '/apac', + permanent: false + } + ] } } + const withPlugins = require('next-compose-plugins') const withMDX = require('@next/mdx')({ extension: /\.mdx?$/ }) diff --git a/pages/[region].js b/pages/[region].js index 9ee0ccf..10e45de 100644 --- a/pages/[region].js +++ b/pages/[region].js @@ -17,9 +17,16 @@ export default ({ name, events, emailStats }) => { desc={`Find, register, and compete in ${events.length} student-led hackathons around ${name}.`} events={events} header={} - footer={<> } - > - + footer={ + <> + {' '} + + {' '} + {' '} + {' '} + + } + > ) } @@ -44,11 +51,11 @@ const distance = (lat1, lon1, lat2, lon2) => { let regions = [ { name: 'Los Angeles', - filter: (event) => event.city === 'Los Angeles' + filter: event => event.city === 'Los Angeles' }, { name: 'Chicago', - filter: (event) => { + filter: event => { const position = [41.969649, -87.720643] return ( distance(position[0], position[1], event.latitude, event.longitude) @@ -58,7 +65,7 @@ let regions = [ }, { name: 'New York', - filter: (event) => { + filter: event => { const position = [40.7128, -74.006] return ( distance(position[0], position[1], event.latitude, event.longitude) @@ -68,7 +75,7 @@ let regions = [ }, { name: 'the Bay Area', - filter: (event) => { + filter: event => { const position = [37.641045, -122.228916] return ( distance(position[0], position[1], event.latitude, event.longitude) @@ -78,21 +85,17 @@ let regions = [ }, { name: 'the USA', - filter: (event) => ['US', 'USA', 'United States'].includes(event.country) + filter: event => ['US', 'USA', 'United States'].includes(event.country) }, { name: 'Canada', - filter: (event) => ['CA', 'Canada'].includes(event.country) - }, - { - name: 'India', - filter: (event) => ['IN', 'India'].includes(event.country) + filter: event => ['CA', 'Canada'].includes(event.country) } ] -regions = map(regions, (region) => ({ id: kebabCase(region.name), ...region })) +regions = map(regions, region => ({ id: kebabCase(region.name), ...region })) export const getStaticPaths = () => { - const paths = map(map(regions, 'id'), (id) => ({ + const paths = map(map(regions, 'id'), id => ({ params: { region: `list-of-hackathons-in-${id}` } })) return { paths, fallback: false } @@ -103,7 +106,7 @@ export const getStaticProps = async ({ params }) => { region = find(regions, ['id', region.replace('list-of-hackathons-in-', '')]) let { name } = region let { events, emailStats } = await getGroupingData() - events = events.filter((event) => region.filter(event)) + events = events.filter(event => region.filter(event)) events = orderBy(events, 'start', 'desc') return { props: { name, events, emailStats }, revalidate: 10 } } diff --git a/pages/apac.js b/pages/apac.js new file mode 100644 index 0000000..afd54c9 --- /dev/null +++ b/pages/apac.js @@ -0,0 +1,56 @@ +import Grouping from '../components/grouping' +import Regions from '../components/regions' +import Meta from '@hackclub/meta' +import { Heading, Text, Link } from 'theme-ui' +import Head from 'next/head' +import { orderBy, filter } from 'lodash' +import { getEvents } from '../lib/data' + +export default ({ name, events, emailStats }) => { + const title = `High School Hackathons in ${new Date().getFullYear()}` + + return ( + + + + High School Hackathons in the Asia-Pacific Region + + + A curated list of in-person and online high school hackathons. + + {' '} + Maintained by the{' '} + Hack Club staff. + + + + } + events={events} + footer={ +
+ {/* At the moment, the email signup is broken. */} + + Explore popular regions + + +
+ } + /> + ) +} + +export const getStaticProps = async (req, res) => { + let events = await getEvents() + // events where the field apac = true + events = filter(events, 'apac') + // upcoming events first + events = orderBy(events, 'start', 'desc') + return { props: { events }, revalidate: 10 } +} diff --git a/pages/index.js b/pages/index.js index e854ccf..15528b3 100644 --- a/pages/index.js +++ b/pages/index.js @@ -5,9 +5,10 @@ import Meta from '@hackclub/meta' import Signup from '../components/signup' import Years from '../components/years' import Regions from '../components/regions' -import { filter, orderBy, slice, last } from 'lodash' +import { filter, orderBy, slice, last, remove } from 'lodash' import { timeSince, humanizedDateRange } from '../lib/util' import { getGroupingData } from '../lib/data' +import Banner from '../components/banner' const title = `High School Hackathons in ${new Date().getFullYear()}` const eventsPreview = events => @@ -53,6 +54,13 @@ export default ({ stats, emailStats, events }) => ( {' '} staff. + {/* */} } events={events}