diff --git a/conferences/big-party-v/schedule.tsx b/conferences/big-party-v/schedule.tsx index 009ef2a..345207a 100644 --- a/conferences/big-party-v/schedule.tsx +++ b/conferences/big-party-v/schedule.tsx @@ -1,4 +1,5 @@ import { styles } from './schedule.styles' +import { Fragment } from 'react' const DATA: ScheduleItemModel[] = [ { @@ -176,7 +177,7 @@ const ScheduleItem = (props: ScheduleItemModel) => { {speakerBios.map((item, idx) => { return ( - <> + { company={item.company} /> {isMultiple ?
: null} - +
) })}
{speakerTalk}
diff --git a/globals.d.ts b/globals.d.ts index 9ccfe06..ab3fd94 100644 --- a/globals.d.ts +++ b/globals.d.ts @@ -5,6 +5,7 @@ declare namespace JSX { 'amp-analytics': AMP.AmpAnalytics 'amp-sidebar': AMP.AmpSidebar 'amp-lightbox': AMP.AmpLightBox + 'amp-script': AMP.AmpScript } } diff --git a/pages/big-party-i/index.tsx b/pages/big-party-i/index.tsx new file mode 100644 index 0000000..d342683 --- /dev/null +++ b/pages/big-party-i/index.tsx @@ -0,0 +1,5 @@ +import { redirectTo } from '../../shared' + +export default redirectTo( + 'https://www.eventbrite.com/e/ngbigparty-tickets-18241722483' +) diff --git a/pages/big-party-ii/index.tsx b/pages/big-party-ii/index.tsx new file mode 100644 index 0000000..51151ce --- /dev/null +++ b/pages/big-party-ii/index.tsx @@ -0,0 +1,3 @@ +import { redirectTo } from '../../shared' + +export default redirectTo('https://www.ngparty.cz/ngBigParty-II') diff --git a/pages/big-party-iii/index.tsx b/pages/big-party-iii/index.tsx new file mode 100644 index 0000000..5aff3ab --- /dev/null +++ b/pages/big-party-iii/index.tsx @@ -0,0 +1,3 @@ +import { redirectTo } from '../../shared' + +export default redirectTo('https://www.meetup.com/ngParty/events/231965205/') diff --git a/shared/environment.ts b/shared/environment.ts new file mode 100644 index 0000000..44ce80e --- /dev/null +++ b/shared/environment.ts @@ -0,0 +1,10 @@ +import { NextPageContext } from 'next' + +export const isClient = typeof window !== 'undefined' + +/** + * + * helper for getInitialProps, if you need to use it with `next export` + */ +export const isStaticExport = (ctx: NextPageContext) => + typeof ctx.res!.writeHead !== 'function' diff --git a/shared/external-redirect.tsx b/shared/external-redirect.tsx new file mode 100644 index 0000000..8f44d85 --- /dev/null +++ b/shared/external-redirect.tsx @@ -0,0 +1,49 @@ +import React, { useEffect } from 'react' +import { NextPageContext } from 'next' +import Head from 'next/head' +import { useRouter } from 'next/router' + +/** + * @experimental + * + * NOTE: this doesn't work as `http-equiv="refresh"` is forbidden within AMP + */ +export const ampRedirectTo = (redirectUrl: string) => { + const Redirect = () => { + return ( + <> + + + +

Redirecting...

+ + ) + } + + return Redirect +} + +export const redirectTo = (redirectUrl: string, { external = true } = {}) => { + const Redirect = () => { + const router = useRouter() + + useEffect(() => { + if (external) { + window.location.href = redirectUrl + return + } + router.push(redirectUrl) + }, []) + + return React.createElement('div', null, 'Redirecting...') + } + + return Redirect +} + +function serverRedirect(res: NextPageContext['res'], redirectUrl: string) { + if (res) { + res.writeHead(302, { Location: redirectUrl }) + res.end() + } +} diff --git a/shared/index.ts b/shared/index.ts index 7f16534..a8c2ffa 100644 --- a/shared/index.ts +++ b/shared/index.ts @@ -1 +1,3 @@ export * from './data' +export * from './external-redirect' +export * from './environment' diff --git a/typings/amp.d.ts b/typings/amp.d.ts index 4496aa7..1b80e57 100644 --- a/typings/amp.d.ts +++ b/typings/amp.d.ts @@ -1,4 +1,13 @@ declare namespace AMP { + type Layouts = + | 'responsive' + | 'fixed' + | 'fill' + | 'fixed-height' + | 'flex-item' + | 'container' + | 'nodisplay' + | 'intrinsic' interface AmpBaseElement extends JSX.IntrinsicAttributes {} interface AmpLightBox extends AmpBaseElement { @@ -18,15 +27,7 @@ declare namespace AMP { src?: string width?: string height?: string - layout?: - | 'responsive' - | 'fixed' - | 'fill' - | 'fixed-height' - | 'flex-item' - | 'container' - | 'nodisplay' - | 'intrinsic' + layout?: Layouts className?: string children?: React.ReactNode } @@ -42,4 +43,13 @@ declare namespace AMP { children?: React.ReactNode } interface AmpAnalytics extends AmpBaseElement {} + + interface AmpScript { + width?: string + height?: string + script?: string + src?: string + layout?: Layouts + children?: React.ReactNode + } }