From 1893f3fb205f90d4aaf550c5d5a76bfc24f47a13 Mon Sep 17 00:00:00 2001 From: Ido Shamun Date: Mon, 24 Aug 2020 17:08:03 +0300 Subject: [PATCH 1/2] feat: home page Add temporary home page with link to the extension --- components/MainLayout.tsx | 2 +- pages/_app.tsx | 2 +- pages/index.tsx | 94 ++++++++++++++++++++++++++++++++------- 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/components/MainLayout.tsx b/components/MainLayout.tsx index f1256926b36..3671a1be938 100644 --- a/components/MainLayout.tsx +++ b/components/MainLayout.tsx @@ -101,7 +101,7 @@ export default function MainLayout({ children }: Props): ReactElement { return (
- + diff --git a/pages/_app.tsx b/pages/_app.tsx index 69cb18934a7..a27e97516e3 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -17,7 +17,7 @@ const LoginModal = dynamic(() => import('../components/LoginModal')); const ProfileModal = dynamic(() => import('../components/ProfileModal')); const CookieBanner = dynamic(() => import('../components/CookieBanner')); -interface PageProps { +export interface PageProps { user?: LoggedUser; trackingId: string; initialApolloState: NormalizedCacheObject; diff --git a/pages/index.tsx b/pages/index.tsx index 6c9916fada9..fc8a9d78b1d 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,22 +1,84 @@ -import { ReactElement } from 'react'; -import { useRouter } from 'next/router'; +import React, { ReactElement } from 'react'; import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next'; - -export default async function Home(): Promise { - const router = useRouter(); - // Make sure we're in the browser - if (typeof window !== 'undefined') { - await router.push('https://daily.dev'); - return; - } -} +import { getUser, LoggedUser } from '../lib/user'; +import { PageProps } from './_app'; +import MainLayout from '../components/MainLayout'; +import styled from 'styled-components'; +import { size4, size6, sizeN } from '../styles/sizes'; +import { typoJr, typoQuarter } from '../styles/typography'; +import { NextSeoProps } from 'next-seo/lib/types'; +import { NextSeo } from 'next-seo'; +import { InvertButton } from '../components/Buttons'; +import { laptop } from '../styles/media'; export async function getServerSideProps({ + req, res, -}: GetServerSidePropsContext): Promise> { - if (res) { - res.writeHead(302, { Location: 'https://daily.dev' }); - res.end(); +}: GetServerSidePropsContext): Promise> { + const userRes = await getUser({ req, res }); + return { + props: { + initialApolloState: null, + user: userRes.isLoggedIn ? (userRes.user as LoggedUser) : null, + trackingId: userRes.user.id, + }, + }; +} + +const Container = styled.div` + display: flex; + max-width: ${sizeN(144)}; + flex-direction: column; + align-items: center; + margin: 0 auto; + padding: ${size6}; + + ${laptop} { + height: 100vh; + justify-content: center; } - return { props: null }; +`; + +const Emoji = styled.div` + font-size: ${sizeN(30)}; +`; + +const Title = styled.h1` + margin: ${size6} 0 ${size4}; + text-align: center; + ${typoQuarter} +`; + +const Description = styled.div` + margin-bottom: ${size6}; + color: var(--theme-secondary); + text-align: center; + ${typoJr} +`; + +export default function Home(): ReactElement { + const Seo: NextSeoProps = { + title: 'daily.dev', + titleTemplate: '%s', + description: 'Source for busy developers', + }; + + return ( + + + + 🏗 + Something awesome is coming soon 👨‍💻 + + You requested, we listened. We’re busy building a new web app for + daily.dev. We wish we could show you more! In the meantime, you can + explore the latest dev news on our browser extension (if you don’t + have it already). + + + Get the extension + + + + ); } From 4feb741499d1c2e7c9f0509ed2f87ae186e164ca Mon Sep 17 00:00:00 2001 From: Ido Shamun Date: Mon, 24 Aug 2020 17:50:42 +0300 Subject: [PATCH 2/2] refactor(home): update seo settings --- pages/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index fc8a9d78b1d..adcd8daa0b6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -58,9 +58,11 @@ const Description = styled.div` export default function Home(): ReactElement { const Seo: NextSeoProps = { - title: 'daily.dev', + title: + 'Meet awesome developers by discussing trending dev news | powered by the daily.dev community', titleTemplate: '%s', - description: 'Source for busy developers', + description: + 'Join the live discussion about the latest programming articles. It’s a place for developers to create meaningful interactions and help each other learn cool things.', }; return (