|
| 1 | +import { useEffect, useRef } from 'react' |
| 2 | + |
| 3 | +import Head from 'next/head' |
| 4 | + |
| 5 | +import { getLiteral } from '../../common/i18n' |
| 6 | +import { getDataFromMD, parseGetInvolvedData } from '../../common/api' |
| 7 | +import { getEvents, parseEvents } from '../../api/events' |
| 8 | +import * as ROUTES from '../../common/routes' |
| 9 | + |
| 10 | +import Hero from '../../components/home/hero/Hero' |
| 11 | +import About from '../../components/home/about/About2022' |
| 12 | +import GetInvolved from '../../components/home/get-involved/GetInvolved2022' |
| 13 | +import Events from '../../components/home/events/Events' |
| 14 | +import AnchorNavigation from '../../components/home/anchor-navigation/AnchorNavigation' |
| 15 | +import { useBackground } from '../../contexts/BackgroundContext' |
| 16 | + |
| 17 | +export default function Home({ hero, about, getInvolved, events, connection }) { |
| 18 | + const containerRef = useRef(null) |
| 19 | + |
| 20 | + const { setAnimationStep } = useBackground() |
| 21 | + |
| 22 | + useEffect(() => { |
| 23 | + setAnimationStep(0) |
| 24 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 25 | + }, []) |
| 26 | + |
| 27 | + return ( |
| 28 | + <div> |
| 29 | + <Head> |
| 30 | + <title>{getLiteral('meta:title')}</title> |
| 31 | + <meta name="description" content={getLiteral('meta:description')} /> |
| 32 | + |
| 33 | + {/* <!-- Facebook Meta Tags --> */} |
| 34 | + <meta property="og:title" content={getLiteral('meta:title')} /> |
| 35 | + <meta |
| 36 | + property="og:description" |
| 37 | + content={getLiteral('meta:description')} |
| 38 | + /> |
| 39 | + <meta |
| 40 | + property="og:image" |
| 41 | + content="https://maintainermonth.github.com/images/og/generic.png" |
| 42 | + /> |
| 43 | + |
| 44 | + {/* <!-- Twitter Meta Tags --> */} |
| 45 | + <meta name="twitter:card" content="summary_large_image" /> |
| 46 | + <meta name="twitter:title" content={getLiteral('meta:title')} /> |
| 47 | + <meta |
| 48 | + name="twitter:description" |
| 49 | + content={getLiteral('meta:description')} |
| 50 | + /> |
| 51 | + <meta |
| 52 | + name="twitter:image" |
| 53 | + content="https://maintainermonth.github.com/images/og/generic.png" |
| 54 | + /> |
| 55 | + </Head> |
| 56 | + |
| 57 | + <div> |
| 58 | + <AnchorNavigation containerRef={containerRef} /> |
| 59 | + |
| 60 | + <div ref={containerRef}> |
| 61 | + <Hero |
| 62 | + date={hero.date} |
| 63 | + title={hero.title} |
| 64 | + buttonText={hero.buttonText} |
| 65 | + buttonLink={ROUTES.SCHEDULE.getPath("2022")} |
| 66 | + /> |
| 67 | + <About title={about.title} content={about.content} /> |
| 68 | + <GetInvolved |
| 69 | + title={getInvolved.title} |
| 70 | + content={getInvolved.content} |
| 71 | + examplesTitle={getInvolved.examplesTitle} |
| 72 | + examples={getInvolved.examples} |
| 73 | + /> |
| 74 | + <Events |
| 75 | + title={events.title} |
| 76 | + list={events.list} |
| 77 | + connectionTitle={connection.title} |
| 78 | + connectionButtonText={connection.buttonText} |
| 79 | + /> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + ) |
| 84 | +} |
| 85 | + |
| 86 | +export async function getStaticProps() { |
| 87 | + const hero = getDataFromMD('content/2022/home/1-hero.md') |
| 88 | + const about = getDataFromMD('content/2022/home/2-about.md') |
| 89 | + const getInvolved = parseGetInvolvedData( |
| 90 | + getDataFromMD('content/2022/home/3-get-involved.md'), |
| 91 | + ) |
| 92 | + const events = getDataFromMD('content/2022/home/4-events.md') |
| 93 | + const connection = getDataFromMD('content/2022/home/5-connection.md') |
| 94 | + |
| 95 | + const eventsList = parseEvents(getEvents('2022')) |
| 96 | + |
| 97 | + return { |
| 98 | + props: { |
| 99 | + hero, |
| 100 | + about, |
| 101 | + getInvolved, |
| 102 | + events: { |
| 103 | + ...events, |
| 104 | + list: eventsList, |
| 105 | + }, |
| 106 | + connection, |
| 107 | + }, |
| 108 | + } |
| 109 | +} |
0 commit comments