Unverified Commit dbad9db6 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Update Examples for Fast Refresh (#13068)

parent 86160a51
{ {
"root": true, "root": true,
"parser": "babel-eslint", "parser": "babel-eslint",
"plugins": ["react", "react-hooks", "jest"], "plugins": ["react", "react-hooks", "jest", "import"],
"env": { "env": {
"browser": true, "browser": true,
"commonjs": true, "commonjs": true,
...@@ -91,6 +91,26 @@ ...@@ -91,6 +91,26 @@
"packages/create-next-app/templates/**/*" "packages/create-next-app/templates/**/*"
], ],
"rules": { "react/react-in-jsx-scope": "off" } "rules": { "react/react-in-jsx-scope": "off" }
},
{
"files": ["examples/**/*"],
"rules": {
"import/no-anonymous-default-export": [
"error",
{
// React components:
"allowArrowFunction": false,
"allowAnonymousClass": false,
"allowAnonymousFunction": false,
// Non-React stuff:
"allowArray": true,
"allowCallExpression": true,
"allowLiteral": true,
"allowObject": true
}
]
}
} }
], ],
"rules": { "rules": {
......
...@@ -2,122 +2,124 @@ import Head from 'next/head' ...@@ -2,122 +2,124 @@ import Head from 'next/head'
export const config = { amp: true } export const config = { amp: true }
export default () => ( export default function Home() {
<> return (
<Head> <>
<title>Example AMP Story in Next.js</title> <Head>
<script <title>Example AMP Story in Next.js</title>
async <script
key="amp-story" async
custom-element="amp-story" key="amp-story"
src="https://cdn.ampproject.org/v0/amp-story-1.0.js" custom-element="amp-story"
/> src="https://cdn.ampproject.org/v0/amp-story-1.0.js"
<script />
async <script
key="amp-video" async
custom-element="amp-video" key="amp-video"
src="https://cdn.ampproject.org/v0/amp-video-0.1.js" custom-element="amp-video"
/> src="https://cdn.ampproject.org/v0/amp-video-0.1.js"
</Head> />
</Head>
<amp-story <amp-story
standalone="" standalone=""
title="Stories in AMP - Hello World" title="Stories in AMP - Hello World"
publisher="AMP Project" publisher="AMP Project"
publisher-logo-src="https://amp.dev/favicons/coast-228x228.png" publisher-logo-src="https://amp.dev/favicons/coast-228x228.png"
poster-portrait-src="https://amp.dev/static/samples/img/story_dog2_portrait.jpg" poster-portrait-src="https://amp.dev/static/samples/img/story_dog2_portrait.jpg"
poster-square-src="https://amp.dev/static/samples/img/story_dog2_square.jpg" poster-square-src="https://amp.dev/static/samples/img/story_dog2_square.jpg"
poster-landscape-src="https://amp.dev/static/samples/img/story_dog2_landscape.jpg" poster-landscape-src="https://amp.dev/static/samples/img/story_dog2_landscape.jpg"
> >
{/* <!-- A story consists of one or more pages. Each page is declared by an `amp-story-page` element. Pages are designed by layering videos, images and text. Here we have a page that uses two layers. One layer filling the available space with an image and one text layer that shows a heading. --> */} {/* <!-- A story consists of one or more pages. Each page is declared by an `amp-story-page` element. Pages are designed by layering videos, images and text. Here we have a page that uses two layers. One layer filling the available space with an image and one text layer that shows a heading. --> */}
<amp-story-page id="page-1"> <amp-story-page id="page-1">
<amp-story-grid-layer template="fill"> <amp-story-grid-layer template="fill">
<amp-img <amp-img
src="https://amp.dev/static/samples/img/story_dog2.jpg" src="https://amp.dev/static/samples/img/story_dog2.jpg"
width="720" width="720"
height="1280" height="1280"
layout="responsive" layout="responsive"
/>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<h1>Hello World</h1>
<p>This is an AMP Story.</p>
</amp-story-grid-layer>
</amp-story-page>
{/* <!-- Here we have a page consisting of a video which autoplays and loops. --> */}
<amp-story-page id="page-2">
<amp-story-grid-layer template="fill">
<amp-video
autoplay=""
loop=""
width="720"
height="960"
poster="https://amp.dev/static/samples/img/story_video_dog_cover.jpg"
layout="responsive"
>
<source
src="https://amp.dev/static/samples/video/story_video_dog.mp4"
type="video/mp4"
/> />
</amp-video> </amp-story-grid-layer>
</amp-story-grid-layer> <amp-story-grid-layer template="vertical">
</amp-story-page> <h1>Hello World</h1>
<p>This is an AMP Story.</p>
</amp-story-grid-layer>
</amp-story-page>
{/* <!-- Here we have a page consisting of a video which autoplays and loops. --> */}
<amp-story-page id="page-2">
<amp-story-grid-layer template="fill">
<amp-video
autoplay=""
loop=""
width="720"
height="960"
poster="https://amp.dev/static/samples/img/story_video_dog_cover.jpg"
layout="responsive"
>
<source
src="https://amp.dev/static/samples/video/story_video_dog.mp4"
type="video/mp4"
/>
</amp-video>
</amp-story-grid-layer>
</amp-story-page>
{/* <!-- Pre-defined entry animations make it possible to create dynamic pages without videos. The length and initial delay can be customized using the `animate-in-duration` and `animate-in-delay` properties. The [animations sample](/documentation/examples/visual-effects/amp_story_animations/) shows all available animantions in action. --> */} {/* <!-- Pre-defined entry animations make it possible to create dynamic pages without videos. The length and initial delay can be customized using the `animate-in-duration` and `animate-in-delay` properties. The [animations sample](/documentation/examples/visual-effects/amp_story_animations/) shows all available animantions in action. --> */}
<amp-story-page id="animation-demo"> <amp-story-page id="animation-demo">
<amp-story-grid-layer template="fill"> <amp-story-grid-layer template="fill">
<amp-img <amp-img
src="https://amp.dev/static/samples/img/story_dog4.jpg" src="https://amp.dev/static/samples/img/story_dog4.jpg"
animate-in="fly-in-top" animate-in="fly-in-top"
width="720" width="720"
height="1280" height="1280"
layout="responsive" layout="responsive"
/> />
</amp-story-grid-layer> </amp-story-grid-layer>
<amp-story-grid-layer template="thirds"> <amp-story-grid-layer template="thirds">
<h2 <h2
animate-in="fly-in-bottom" animate-in="fly-in-bottom"
grid-area="lower-third" grid-area="lower-third"
animate-in-delay="0.4s" animate-in-delay="0.4s"
> >
Best walk ever! Best walk ever!
</h2> </h2>
</amp-story-grid-layer> </amp-story-grid-layer>
</amp-story-page> </amp-story-page>
{/* <!-- Stories can use predefined layouts to style the page. Here we're using the `thirds` template. For an overview about the available layouts take a look at the [layouts sample](/documentation/examples/style-layout/amp_story_layouts/). --> */} {/* <!-- Stories can use predefined layouts to style the page. Here we're using the `thirds` template. For an overview about the available layouts take a look at the [layouts sample](/documentation/examples/style-layout/amp_story_layouts/). --> */}
<amp-story-page id="layout-demo"> <amp-story-page id="layout-demo">
<amp-story-grid-layer template="thirds"> <amp-story-grid-layer template="thirds">
<amp-img <amp-img
grid-area="upper-third" grid-area="upper-third"
src="https://amp.dev/static/samples/img/story_thirds_1.jpg" src="https://amp.dev/static/samples/img/story_thirds_1.jpg"
width="560" width="560"
height="420" height="420"
layout="responsive" layout="responsive"
/> />
<amp-img <amp-img
grid-area="middle-third" grid-area="middle-third"
src="https://amp.dev/static/samples/img/story_thirds_2.jpg" src="https://amp.dev/static/samples/img/story_thirds_2.jpg"
width="560" width="560"
height="420" height="420"
layout="responsive" layout="responsive"
/> />
<amp-img <amp-img
grid-area="lower-third" grid-area="lower-third"
src="https://amp.dev/static/samples/img/story_thirds_3.jpg" src="https://amp.dev/static/samples/img/story_thirds_3.jpg"
width="560" width="560"
height="420" height="420"
layout="responsive" layout="responsive"
/> />
</amp-story-grid-layer> </amp-story-grid-layer>
</amp-story-page> </amp-story-page>
{/* <!-- A "bookend" panel containing links to other resources will appear on the last page of your story if you include an `amp-story-bookend` that references a [bookend JSON config](/static/samples/json/bookend.json). --> */} {/* <!-- A "bookend" panel containing links to other resources will appear on the last page of your story if you include an `amp-story-bookend` that references a [bookend JSON config](/static/samples/json/bookend.json). --> */}
<amp-story-bookend <amp-story-bookend
src="https://amp.dev/static/samples/json/bookend.json" src="https://amp.dev/static/samples/json/bookend.json"
layout="nodisplay" layout="nodisplay"
/> />
</amp-story> </amp-story>
</> </>
) )
}
export default () => <div>About us</div> export default function About() {
return <div>About us</div>
}
export default () => <div>This is the contact page.</div> export default function Contact() {
return <div>This is the contact page.</div>
}
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function About() {
<div> return (
This is a static page goto{' '} <div>
<Link href="/"> This is a static page goto{' '}
<a>dynamic</a> <Link href="/">
</Link>{' '} <a>dynamic</a>
page. </Link>{' '}
</div> page.
) </div>
)
}
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function About() {
<div> return (
This is a static page goto{' '} <div>
<Link href="/"> This is a static page goto{' '}
<a>dynamic</a> <Link href="/">
</Link>{' '} <a>dynamic</a>
page. </Link>{' '}
</div> page.
) </div>
)
}
export default (req, res) => { export default function userHandler(req, res) {
const { const {
query: { id, name }, query: { id, name },
method, method,
......
// Fake users data // Fake users data
const users = [{ id: 1 }, { id: 2 }, { id: 3 }] const users = [{ id: 1 }, { id: 2 }, { id: 3 }]
export default (req, res) => { export default function handler(req, res) {
// Get data from your database // Get data from your database
res.status(200).json(users) res.status(200).json(users)
} }
import Link from 'next/link' import Link from 'next/link'
export default ({ person }) => ( export default function Person({ person }) {
<li> return (
<Link href="/person/[id]" as={`/person/${person.id}`}> <li>
<a>{person.name}</a> <Link href="/person/[id]" as={`/person/${person.id}`}>
</Link> <a>{person.name}</a>
</li> </Link>
) </li>
)
}
import { people } from '../../../data' import { people } from '../../../data'
export default ({ query: { id } }, res) => { export default function personHandler({ query: { id } }, res) {
const filtered = people.filter((p) => p.id === id) const filtered = people.filter((p) => p.id === id)
// User with id exists // User with id exists
......
import { people } from '../../../data' import { people } from '../../../data'
export default (req, res) => { export default function handler(req, res) {
res.status(200).json(people) res.status(200).json(people)
} }
export default () => ( export default function Home() {
<div className="hello"> return (
<p>Hello World</p> <div className="hello">
<style jsx>{` <p>Hello World</p>
.hello { <style jsx>{`
font: 15px Helvetica, Arial, sans-serif; .hello {
background: #eee; font: 15px Helvetica, Arial, sans-serif;
padding: 100px; background: #eee;
text-align: center; padding: 100px;
transition: 100ms ease-in background; text-align: center;
} transition: 100ms ease-in background;
.hello:hover { }
background: #ccc; .hello:hover {
} background: #ccc;
`}</style> }
</div> `}</style>
) </div>
)
}
export default () => <div>About us</div> export default function About() {
return <div>About us</div>
}
export default () => <div>About 2</div> export default function About2() {
return <div>About 2</div>
}
export default () => <div>Hello Day</div> export default function Day() {
return <div>Hello Day</div>
}
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<div> return (
Hello World.{' '} <div>
<Link href="/about"> Hello World.{' '}
<a>About</a> <Link href="/about">
</Link> <a>About</a>
</div> </Link>
) </div>
)
}
import { format } from 'date-fns' import { format } from 'date-fns'
export default ({ dateString }) => ( export default function Date({ dateString }) {
<time dateTime={dateString}> return (
{format(new Date(dateString), 'LLLL d, yyyy')} <time dateTime={dateString}>
</time> {format(new Date(dateString), 'LLLL d, yyyy')}
) </time>
)
}
export default async (_, res) => { export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args. // Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData() res.clearPreviewData()
......
import { getPreviewPostBySlug } from '../../lib/api' import { getPreviewPostBySlug } from '../../lib/api'
export default async (req, res) => { export default async function preview(req, res) {
const { secret, slug } = req.query const { secret, slug } = req.query
if ( if (
......
export default async (_, res) => { export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args. // Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData() res.clearPreviewData()
......
import { getPreviewPostBySlug } from '../../lib/api' import { getPreviewPostBySlug } from '../../lib/api'
export default async (req, res) => { export default async function preview(req, res) {
// Check the secret and next parameters // Check the secret and next parameters
// This secret should only be known to this API route and the CMS // This secret should only be known to this API route and the CMS
if ( if (
......
export default async (_, res) => { export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args. // Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData() res.clearPreviewData()
......
...@@ -10,7 +10,7 @@ function linkResolver(doc) { ...@@ -10,7 +10,7 @@ function linkResolver(doc) {
return `/${doc.uid}` return `/${doc.uid}`
} }
export default async (req, res) => { export default async function preview(req, res) {
const ref = req.query.token const ref = req.query.token
// Check the token parameter against the Prismic SDK // Check the token parameter against the Prismic SDK
......
export default async (_, res) => { export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args. // Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData() res.clearPreviewData()
......
import { getPreviewPostBySlug } from '../../lib/api' import { getPreviewPostBySlug } from '../../lib/api'
export default async (req, res) => { export default async function preview(req, res) {
// Check the secret and next parameters // Check the secret and next parameters
// This secret should only be known to this API route and the CMS // This secret should only be known to this API route and the CMS
if ( if (
......
export default async (_, res) => { export default async function exit(_, res) {
// Exit the current user from "Preview Mode". This function accepts no args. // Exit the current user from "Preview Mode". This function accepts no args.
res.clearPreviewData() res.clearPreviewData()
......
import { getPreviewPostBySlug } from '../../lib/api' import { getPreviewPostBySlug } from '../../lib/api'
export default async (req, res) => { export default async function preview(req, res) {
// Check the secret and next parameters // Check the secret and next parameters
// This secret should only be known to this API route and the CMS // This secret should only be known to this API route and the CMS
if ( if (
......
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import React from 'react' import React from 'react'
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
import React from 'react' import React from 'react'
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import React from 'react' import React from 'react'
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
import React from 'react' import React from 'react'
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import React from 'react' import React from 'react'
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
import React from 'react' import React from 'react'
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/a" as="/a"> <li>
<a>a</a> <Link href="/a" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/b" as="/b"> <li>
<a>b</a> <Link href="/b" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import React from 'react' import React from 'react'
export default () => <div>a</div> export default function A() {
return <div>a</div>
}
import React from 'react' import React from 'react'
export default () => <div>b</div> export default function B() {
return <div>b</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/b" as="/a"> <li>
<a>a</a> <Link href="/b" as="/a">
</Link> <a>a</a>
</li> </Link>
<li> </li>
<Link href="/a" as="/b"> <li>
<a>b</a> <Link href="/a" as="/b">
</Link> <a>b</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function About() {
<div> return (
<div>About us</div>
<div> <div>
Back to{' '} <div>About us</div>
<Link href="/" as={process.env.BACKEND_URL + '/'}> <div>
<a>Home</a> Back to{' '}
</Link> <Link href="/" as={process.env.BACKEND_URL + '/'}>
<a>Home</a>
</Link>
</div>
</div> </div>
</div> )
) }
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<div> return (
Hello World.{' '} <div>
<Link href="/about" as={process.env.BACKEND_URL + '/about'}> Hello World.{' '}
<a>About</a> <Link href="/about" as={process.env.BACKEND_URL + '/about'}>
</Link> <a>About</a>
</div> </Link>
) </div>
)
}
import Head from 'next/head' import Head from 'next/head'
export default () => ( export default function Home() {
<div> return (
<Head> <div>
<title>This page has a title 🤔</title> <Head>
<meta charSet="utf-8" /> <title>This page has a title 🤔</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" /> <meta charSet="utf-8" />
</Head> <meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<h1>This page has a title 🤔</h1> <h1>This page has a title 🤔</h1>
</div> </div>
) )
}
import Link from 'next/link' import Link from 'next/link'
import Head from 'next/head' import Head from 'next/head'
export default ({ children, title = 'This is the default title' }) => ( export default function Layout({
<div> children,
<Head> title = 'This is the default title',
<title>{title}</title> }) {
<meta charSet="utf-8" /> return (
<meta name="viewport" content="initial-scale=1.0, width=device-width" /> <div>
</Head> <Head>
<header> <title>{title}</title>
<nav> <meta charSet="utf-8" />
<Link href="/"> <meta name="viewport" content="initial-scale=1.0, width=device-width" />
<a>Home</a> </Head>
</Link>{' '} <header>
| <nav>
<Link href="/about"> <Link href="/">
<a>About</a> <a>Home</a>
</Link>{' '} </Link>{' '}
| |
<Link href="/contact"> <Link href="/about">
<a>Contact</a> <a>About</a>
</Link> </Link>{' '}
</nav> |
</header> <Link href="/contact">
<a>Contact</a>
</Link>
</nav>
</header>
{children} {children}
<footer>{'I`m here to stay'}</footer> <footer>{'I`m here to stay'}</footer>
</div> </div>
) )
}
import Layout from '../components/layout' import Layout from '../components/layout'
export default () => ( export default function About() {
<Layout title="About us"> return (
<div>About us</div> <Layout title="About us">
</Layout> <div>About us</div>
) </Layout>
)
}
import Layout from '../components/layout' import Layout from '../components/layout'
export default () => ( export default function Contact() {
<Layout title="Contact us"> return (
<div>Contact</div> <Layout title="Contact us">
</Layout> <div>Contact</div>
) </Layout>
)
}
import Layout from '../components/layout' import Layout from '../components/layout'
export default () => ( export default function Home() {
<Layout> return (
<div>Hello World.</div> <Layout>
</Layout> <div>Hello World.</div>
) </Layout>
)
}
export default ({ children }) => ( export default function Paragraph({ children }) {
<p> return (
{children} <p>
<style jsx>{` {children}
p { <style jsx>{`
font: 13px Helvetica, Arial; p {
margin: 10px 0; font: 13px Helvetica, Arial;
} margin: 10px 0;
`}</style> }
</p> `}</style>
) </p>
)
}
export default ({ title, children }) => ( export default function Post({ title, children }) {
<div className="main"> return (
<h1>{title}</h1> <div className="main">
{children} <h1>{title}</h1>
<style jsx>{` {children}
.main { <style jsx>{`
font: 15px Helvetica, Arial; .main {
border: 1px solid #eee; font: 15px Helvetica, Arial;
padding: 0 10px; border: 1px solid #eee;
} padding: 0 10px;
}
h1 { h1 {
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
margin: 10px 0; margin: 10px 0;
} }
`}</style> `}</style>
</div> </div>
) )
}
import P from '../components/paragraph' import P from '../components/paragraph'
import Post from '../components/post' import Post from '../components/post'
export default () => ( export default function Home() {
<div className="main"> return (
<Post title="My first blog post"> <div className="main">
<P>Hello there</P> <Post title="My first blog post">
<P>This is an example of a componentized blog post</P> <P>Hello there</P>
</Post> <P>This is an example of a componentized blog post</P>
</Post>
<hr />
<hr />
<Post title="My second blog post">
<P>Hello there</P> <Post title="My second blog post">
<P>This is another example.</P> <P>Hello there</P>
<P>Wa-hoo!</P> <P>This is another example.</P>
</Post> <P>Wa-hoo!</P>
</Post>
<hr />
<hr />
<Post title="The final blog post">
<P>C’est fin</P> <Post title="The final blog post">
</Post> <P>C’est fin</P>
</Post>
<style jsx>{`
.main { <style jsx>{`
margin: auto; .main {
max-width: 420px; margin: auto;
padding: 10px; max-width: 420px;
} padding: 10px;
}
hr {
width: 100px; hr {
border-width: 0; width: 100px;
margin: 20px auto; border-width: 0;
text-align: center; margin: 20px auto;
} text-align: center;
}
hr::before {
content: '***'; hr::before {
color: #ccc; content: '***';
} color: #ccc;
`}</style> }
</div> `}</style>
) </div>
)
}
import React from 'react' import React from 'react'
export default () => ( export default function Loading() {
<div> return (
<h3>Loading...</h3> <div>
<style jsx>{` <h3>Loading...</h3>
div { <style jsx>{`
align-items: center; div {
display: flex; align-items: center;
height: 50vh; display: flex;
justify-content: center; height: 50vh;
} justify-content: center;
`}</style> }
</div> `}</style>
) </div>
)
}
import React from 'react' import React from 'react'
export default function (props) { export default function Post(props) {
return ( return (
<div> <div>
<h1>My {props.id} blog post</h1> <h1>My {props.id} blog post</h1>
......
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<ul> return (
<li> <ul>
<Link href="/blog?id=first" as="/blog/first"> <li>
<a>My first blog post</a> <Link href="/blog?id=first" as="/blog/first">
</Link> <a>My first blog post</a>
</li> </Link>
<li> </li>
<Link href="/blog?id=second" as="/blog/second"> <li>
<a>My second blog post</a> <Link href="/blog?id=second" as="/blog/second">
</Link> <a>My second blog post</a>
</li> </Link>
<li> </li>
<Link href="/blog?id=last" as="/blog/last"> <li>
<a>My last blog post</a> <Link href="/blog?id=last" as="/blog/last">
</Link> <a>My last blog post</a>
</li> </Link>
</ul> </li>
) </ul>
)
}
import React from 'react' import React from 'react'
import Cat from '../svgs/cat.svg' import Cat from '../svgs/cat.svg'
export default () => ( export default function Home() {
<div className="container"> return (
<marquee>SVG Cat!</marquee> <div className="container">
<Cat /> <marquee>SVG Cat!</marquee>
<style jsx>{` <Cat />
.container { <style jsx>{`
width: 600px; .container {
margin: 100px auto; width: 600px;
} margin: 100px auto;
`}</style> }
</div> `}</style>
) </div>
)
}
import React from 'react' import React from 'react'
export default () => <div>About us</div> export default function About() {
return <div>About us</div>
}
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<div> return (
Hello World.{' '} <div>
<Link href="/about"> Hello World.{' '}
<a>About</a> <Link href="/about">
</Link> <a>About</a>
</div> </Link>
) </div>
)
}
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
export default () => ( export default function Header() {
<div> return (
<Link href="/">Home</Link> <div>
<Link href="/about">About</Link> <Link href="/">Home</Link>
</div> <Link href="/about">About</Link>
) </div>
)
}
const Link = ({ children, href }) => { const Link = ({ children, href }) => {
const router = useRouter() const router = useRouter()
......
import Header from '../components/header' import Header from '../components/header'
export default () => ( export default function About() {
<div> return (
<Header /> <div>
<p>This is the about page.</p> <Header />
</div> <p>This is the about page.</p>
) </div>
)
}
import Header from '../components/header' import Header from '../components/header'
export default () => ( export default function Home() {
<div> return (
<Header /> <div>
<p>HOME PAGE is here!</p> <Header />
</div> <p>HOME PAGE is here!</p>
) </div>
)
}
export default () => ( export default function Header() {
<header> return (
<h1>Hello world!</h1> <header>
</header> <h1>Hello world!</h1>
) </header>
)
}
import Header from 'components/header.js' import Header from 'components/header.js'
export default () => ( export default function Home() {
<div> return (
<Header /> <div>
</div> <Header />
) </div>
)
}
...@@ -37,7 +37,7 @@ HitComponent.propTypes = { ...@@ -37,7 +37,7 @@ HitComponent.propTypes = {
hit: PropTypes.object, hit: PropTypes.object,
} }
export default class extends React.Component { export default class App extends React.Component {
static propTypes = { static propTypes = {
searchState: PropTypes.object, searchState: PropTypes.object,
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
......
...@@ -9,7 +9,7 @@ const updateAfter = 700 ...@@ -9,7 +9,7 @@ const updateAfter = 700
const searchStateToUrl = (searchState) => const searchStateToUrl = (searchState) =>
searchState ? `${window.location.pathname}?${qs.stringify(searchState)}` : '' searchState ? `${window.location.pathname}?${qs.stringify(searchState)}` : ''
export default class extends React.Component { export default class Home extends React.Component {
static propTypes = { static propTypes = {
resultsState: PropTypes.object, resultsState: PropTypes.object,
searchState: PropTypes.object, searchState: PropTypes.object,
......
...@@ -11,64 +11,78 @@ import { ...@@ -11,64 +11,78 @@ import {
const FormItem = Form.Item const FormItem = Form.Item
const Option = Select.Option const Option = Select.Option
export default () => ( export default function Home() {
<div style={{ marginTop: 100 }}> return (
<Form layout="horizontal"> <div style={{ marginTop: 100 }}>
<FormItem <Form layout="horizontal">
label="Input Number" <FormItem
labelCol={{ span: 8 }} label="Input Number"
wrapperCol={{ span: 8 }} labelCol={{ span: 8 }}
> wrapperCol={{ span: 8 }}
<InputNumber >
size="large" <InputNumber
min={1} size="large"
max={10} min={1}
style={{ width: 100 }} max={10}
defaultValue={3} style={{ width: 100 }}
name="inputNumber" defaultValue={3}
/> name="inputNumber"
<a href="#">Link</a> />
</FormItem> <a href="#">Link</a>
</FormItem>
<FormItem label="Switch" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Switch defaultChecked name="switch" /> label="Switch"
</FormItem> labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Switch defaultChecked name="switch" />
</FormItem>
<FormItem label="Slider" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Slider defaultValue={70} /> label="Slider"
</FormItem> labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Slider defaultValue={70} />
</FormItem>
<FormItem label="Select" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Select label="Select"
size="large" labelCol={{ span: 8 }}
defaultValue="lucy" wrapperCol={{ span: 8 }}
style={{ width: 192 }}
name="select"
> >
<Option value="jack">jack</Option> <Select
<Option value="lucy">lucy</Option> size="large"
<Option value="disabled" disabled> defaultValue="lucy"
disabled style={{ width: 192 }}
</Option> name="select"
<Option value="yiminghe">yiminghe</Option> >
</Select> <Option value="jack">jack</Option>
</FormItem> <Option value="lucy">lucy</Option>
<Option value="disabled" disabled>
disabled
</Option>
<Option value="yiminghe">yiminghe</Option>
</Select>
</FormItem>
<FormItem <FormItem
label="DatePicker" label="DatePicker"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<DatePicker name="startDate" /> <DatePicker name="startDate" />
</FormItem> </FormItem>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}> <FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}>
<Button size="large" type="primary" htmlType="submit"> <Button size="large" type="primary" htmlType="submit">
OK OK
</Button> </Button>
<Button size="large" style={{ marginLeft: 8 }}> <Button size="large" style={{ marginLeft: 8 }}>
Cancel Cancel
</Button> </Button>
</FormItem> </FormItem>
</Form> </Form>
</div> </div>
) )
}
...@@ -2,10 +2,12 @@ import Layout from '../components/Layout' ...@@ -2,10 +2,12 @@ import Layout from '../components/Layout'
import { Button } from 'antd-mobile' import { Button } from 'antd-mobile'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function About() {
<Layout title="About"> return (
<Link href="/"> <Layout title="About">
<Button>Go to Index</Button> <Link href="/">
</Link> <Button>Go to Index</Button>
</Layout> </Link>
) </Layout>
)
}
...@@ -2,10 +2,12 @@ import Layout from '../components/Layout' ...@@ -2,10 +2,12 @@ import Layout from '../components/Layout'
import { Button } from 'antd-mobile' import { Button } from 'antd-mobile'
import Link from 'next/link' import Link from 'next/link'
export default () => ( export default function Home() {
<Layout title="Index"> return (
<Link href="/about"> <Layout title="Index">
<Button>Go to About</Button> <Link href="/about">
</Link> <Button>Go to About</Button>
</Layout> </Link>
) </Layout>
)
}
...@@ -56,13 +56,15 @@ const menuItemRender = (options: MenuDataItem, element: React.ReactNode) => ( ...@@ -56,13 +56,15 @@ const menuItemRender = (options: MenuDataItem, element: React.ReactNode) => (
</Link> </Link>
) )
export default ({ children }) => ( export default function Main({ children }) {
<ProLayout return (
style={{ minHeight: '100vh' }} <ProLayout
route={ROUTES} style={{ minHeight: '100vh' }}
menuItemRender={menuItemRender} route={ROUTES}
menuHeaderRender={menuHeaderRender} menuItemRender={menuItemRender}
> menuHeaderRender={menuHeaderRender}
{children} >
</ProLayout> {children}
) </ProLayout>
)
}
import MainLayout from '../layouts/main' import MainLayout from '../layouts/main'
export default () => <MainLayout>Example page</MainLayout> export default function Example() {
return <MainLayout>Example page</MainLayout>
}
...@@ -13,59 +13,73 @@ import MainLayout from '../layouts/main' ...@@ -13,59 +13,73 @@ import MainLayout from '../layouts/main'
const FormItem = Form.Item const FormItem = Form.Item
const Option = Select.Option const Option = Select.Option
export default () => ( export default function Home() {
<MainLayout> return (
<Form layout="horizontal"> <MainLayout>
<FormItem <Form layout="horizontal">
label="Input Number" <FormItem
labelCol={{ span: 8 }} label="Input Number"
wrapperCol={{ span: 8 }} labelCol={{ span: 8 }}
> wrapperCol={{ span: 8 }}
<InputNumber >
size="large" <InputNumber
min={1} size="large"
max={10} min={1}
style={{ width: 100 }} max={10}
defaultValue={3} style={{ width: 100 }}
name="inputNumber" defaultValue={3}
/> name="inputNumber"
<a href="#">Link</a> />
</FormItem> <a href="#">Link</a>
</FormItem>
<FormItem label="Switch" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Switch defaultChecked /> label="Switch"
</FormItem> labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Switch defaultChecked />
</FormItem>
<FormItem label="Slider" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Slider defaultValue={70} /> label="Slider"
</FormItem> labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Slider defaultValue={70} />
</FormItem>
<FormItem label="Select" labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}> <FormItem
<Select size="large" defaultValue="lucy" style={{ width: 192 }}> label="Select"
<Option value="jack">jack</Option> labelCol={{ span: 8 }}
<Option value="lucy">lucy</Option> wrapperCol={{ span: 8 }}
<Option value="disabled" disabled> >
disabled <Select size="large" defaultValue="lucy" style={{ width: 192 }}>
</Option> <Option value="jack">jack</Option>
<Option value="yiminghe">yiminghe</Option> <Option value="lucy">lucy</Option>
</Select> <Option value="disabled" disabled>
</FormItem> disabled
</Option>
<Option value="yiminghe">yiminghe</Option>
</Select>
</FormItem>
<FormItem <FormItem
label="DatePicker" label="DatePicker"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<DatePicker name="startDate" /> <DatePicker name="startDate" />
</FormItem> </FormItem>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}> <FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}>
<Button size="large" type="primary" htmlType="submit"> <Button size="large" type="primary" htmlType="submit">
OK OK
</Button> </Button>
<Button size="large" style={{ marginLeft: 8 }}> <Button size="large" style={{ marginLeft: 8 }}>
Cancel Cancel
</Button> </Button>
</FormItem> </FormItem>
</Form> </Form>
</MainLayout> </MainLayout>
) )
}
import MainLayout from '../layouts/main' import MainLayout from '../layouts/main'
export default () => <MainLayout>Welcome!</MainLayout> export default function Welcome() {
return <MainLayout>Welcome!</MainLayout>
}
...@@ -15,86 +15,91 @@ const content = { ...@@ -15,86 +15,91 @@ const content = {
marginTop: '100px', marginTop: '100px',
} }
export default () => ( export default function Home() {
<div style={content}> return (
<div className="text-center mb-5"> <div style={content}>
<Link href="#"> <div className="text-center mb-5">
<a className="logo mr-0"> <Link href="#">
<SmileFilled size={48} strokeWidth={1} /> <a className="logo mr-0">
</a> <SmileFilled size={48} strokeWidth={1} />
</Link> </a>
</Link>
<p className="mb-0 mt-3 text-disabled">Welcome to the world !</p> <p className="mb-0 mt-3 text-disabled">Welcome to the world !</p>
</div> </div>
<div> <div>
<Form layout="horizontal"> <Form layout="horizontal">
<FormItem <FormItem
label="Input Number" label="Input Number"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<InputNumber <InputNumber
size="large" size="large"
min={1} min={1}
max={10} max={10}
style={{ width: 100 }} style={{ width: 100 }}
defaultValue={3} defaultValue={3}
name="inputNumber" name="inputNumber"
/> />
</FormItem> </FormItem>
<FormItem <FormItem
label="Switch" label="Switch"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<Switch defaultChecked name="switch" /> <Switch defaultChecked name="switch" />
</FormItem> </FormItem>
<FormItem <FormItem
label="Slider" label="Slider"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<Slider defaultValue={70} /> <Slider defaultValue={70} />
</FormItem> </FormItem>
<FormItem <FormItem
label="Select" label="Select"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
>
<Select
size="large"
defaultValue="lucy"
style={{ width: 192 }}
name="select"
> >
<Option value="jack">jack</Option> <Select
<Option value="lucy">lucy</Option> size="large"
<Option value="disabled" disabled> defaultValue="lucy"
disabled style={{ width: 192 }}
</Option> name="select"
<Option value="yiminghe">yiminghe</Option> >
</Select> <Option value="jack">jack</Option>
</FormItem> <Option value="lucy">lucy</Option>
<Option value="disabled" disabled>
disabled
</Option>
<Option value="yiminghe">yiminghe</Option>
</Select>
</FormItem>
<FormItem <FormItem
label="DatePicker" label="DatePicker"
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
> >
<DatePicker name="startDate" /> <DatePicker name="startDate" />
</FormItem> </FormItem>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}> <FormItem
<Button size="large" type="primary" htmlType="submit"> style={{ marginTop: 48 }}
OK wrapperCol={{ span: 8, offset: 8 }}
</Button> >
<Button size="large" style={{ marginLeft: 8 }}> <Button size="large" type="primary" htmlType="submit">
Cancel OK
</Button> </Button>
</FormItem> <Button size="large" style={{ marginLeft: 8 }}>
</Form> Cancel
</Button>
</FormItem>
</Form>
</div>
</div> </div>
</div> )
) }
...@@ -8,11 +8,13 @@ if (typeof window !== 'undefined') { ...@@ -8,11 +8,13 @@ if (typeof window !== 'undefined') {
StyleSheet.rehydrate(window.__NEXT_DATA__.ids) StyleSheet.rehydrate(window.__NEXT_DATA__.ids)
} }
export default () => ( export default function Home() {
<div className={css(styles.root)}> return (
<h1 className={css(styles.title)}>My page</h1> <div className={css(styles.root)}>
</div> <h1 className={css(styles.title)}>My page</h1>
) </div>
)
}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
root: { root: {
......
export default ({ children }) => ( export default function App({ children }) {
<main> return (
{children} <main>
<style jsx global>{` {children}
* { <style jsx global>{`
font-family: Menlo, Monaco, 'Lucida Console', 'Liberation Mono', * {
'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', font-family: Menlo, Monaco, 'Lucida Console', 'Liberation Mono',
monospace, serif; 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New',
} monospace, serif;
body { }
margin: 0; body {
padding: 25px 50px; margin: 0;
} padding: 25px 50px;
a { }
color: #22bad9; a {
} color: #22bad9;
p { }
font-size: 14px; p {
line-height: 24px; font-size: 14px;
} line-height: 24px;
article { }
margin: 0 auto; article {
max-width: 650px; margin: 0 auto;
} max-width: 650px;
button { }
align-items: center; button {
background-color: #22bad9; align-items: center;
border: 0; background-color: #22bad9;
color: white; border: 0;
display: flex; color: white;
padding: 5px 7px; display: flex;
transition: background-color 0.3s; padding: 5px 7px;
} transition: background-color 0.3s;
button:active { }
background-color: #1b9db7; button:active {
} background-color: #1b9db7;
button:disabled { }
background-color: #b5bebf; button:disabled {
} background-color: #b5bebf;
button:focus { }
outline: none; button:focus {
} outline: none;
`}</style> }
</main> `}</style>
) </main>
)
}
export default ({ message }) => ( export default function ErrorMessage({ message }) {
<aside> return (
{message} <aside>
<style jsx>{` {message}
aside { <style jsx>{`
padding: 1.5em; aside {
font-size: 14px; padding: 1.5em;
color: white; font-size: 14px;
background-color: red; color: white;
} background-color: red;
`}</style> }
</aside> `}</style>
) </aside>
)
}
...@@ -2,8 +2,10 @@ import React from 'react' ...@@ -2,8 +2,10 @@ import React from 'react'
const Layout = ({ children }) => <div className="layout">{children}</div> const Layout = ({ children }) => <div className="layout">{children}</div>
export default ({ Component, pageProps }) => ( export default function App({ Component, pageProps }) {
<Layout> return (
<Component {...pageProps} /> <Layout>
</Layout> <Component {...pageProps} />
) </Layout>
)
}
export default () => { export default function Home() {
return <div>test</div> return <div>test</div>
} }
import React from 'react' import React from 'react'
import Button, { ButtonGroup } from '@atlaskit/button' import Button, { ButtonGroup } from '@atlaskit/button'
export default () => { export default function ButtonComponent() {
return ( return (
<React.Fragment> <React.Fragment>
<Button style={{ margin: 10 }}>Button</Button> <Button style={{ margin: 10 }}>Button</Button>
......
import React from 'react' import React from 'react'
import { Checkbox } from '@atlaskit/checkbox' import { Checkbox } from '@atlaskit/checkbox'
export default () => { export default function CheckboxComponent() {
return ( return (
<React.Fragment> <React.Fragment>
<Checkbox <Checkbox
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
} from '@atlaskit/datetime-picker' } from '@atlaskit/datetime-picker'
import { Label } from '@atlaskit/field-base' import { Label } from '@atlaskit/field-base'
export default () => { export default function DateTimePickerComponent() {
return ( return (
<React.Fragment> <React.Fragment>
<Label label="TimePicker - timeFormat (h:mm a)" /> <Label label="TimePicker - timeFormat (h:mm a)" />
......
...@@ -5,7 +5,7 @@ import DropdownMenu, { ...@@ -5,7 +5,7 @@ import DropdownMenu, {
} from '@atlaskit/dropdown-menu' } from '@atlaskit/dropdown-menu'
import { Label } from '@atlaskit/field-base' import { Label } from '@atlaskit/field-base'
export default () => { export default function DropdownMenuComponent() {
return ( return (
<React.Fragment> <React.Fragment>
<Label label="DropdownMenu" /> <Label label="DropdownMenu" />
......
...@@ -4,7 +4,7 @@ import CheckboxComponent from '../components/CheckboxComponent' ...@@ -4,7 +4,7 @@ import CheckboxComponent from '../components/CheckboxComponent'
import DateTimePickerComponent from '../components/DateTimePickerComponent' import DateTimePickerComponent from '../components/DateTimePickerComponent'
import DropdownMenuComponent from '../components/DropdownMenuComponent' import DropdownMenuComponent from '../components/DropdownMenuComponent'
export default () => { export default function Home() {
return ( return (
<React.Fragment> <React.Fragment>
<ButtonComponent /> <ButtonComponent />
......
export default (props) => { export default function Clock(props) {
return ( return (
<div className={props.light ? 'light' : ''}> <div className={props.light ? 'light' : ''}>
{format(new Date(props.lastUpdate))} {format(new Date(props.lastUpdate))}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
const SECOND = 1000 const SECOND = 1000
let timer = null let timer = null
export default (context) => { export default function provider(context) {
context.clock = { context.clock = {
start(signalPath) { start(signalPath) {
const signal = context.controller.getSignal(signalPath) const signal = context.controller.getSignal(signalPath)
......
import { query as q } from 'faunadb' import { query as q } from 'faunadb'
import { serverClient, serializeFaunaCookie } from '../../utils/fauna-auth' import { serverClient, serializeFaunaCookie } from '../../utils/fauna-auth'
export default async (req, res) => { export default async function login(req, res) {
const { email, password } = await req.body const { email, password } = await req.body
try { try {
......
...@@ -2,7 +2,7 @@ import { query as q } from 'faunadb' ...@@ -2,7 +2,7 @@ import { query as q } from 'faunadb'
import cookie from 'cookie' import cookie from 'cookie'
import { faunaClient, FAUNA_SECRET_COOKIE } from '../../utils/fauna-auth' import { faunaClient, FAUNA_SECRET_COOKIE } from '../../utils/fauna-auth'
export default async (req, res) => { export default async function logout(req, res) {
const cookies = cookie.parse(req.headers.cookie ?? '') const cookies = cookie.parse(req.headers.cookie ?? '')
const faunaSecret = cookies[FAUNA_SECRET_COOKIE] const faunaSecret = cookies[FAUNA_SECRET_COOKIE]
if (!faunaSecret) { if (!faunaSecret) {
......
...@@ -7,7 +7,7 @@ export const profileApi = async (faunaSecret) => { ...@@ -7,7 +7,7 @@ export const profileApi = async (faunaSecret) => {
return ref.id return ref.id
} }
export default async (req, res) => { export default async function profile(req, res) {
const cookies = cookie.parse(req.headers.cookie ?? '') const cookies = cookie.parse(req.headers.cookie ?? '')
const faunaSecret = cookies[FAUNA_SECRET_COOKIE] const faunaSecret = cookies[FAUNA_SECRET_COOKIE]
......
import { query as q } from 'faunadb' import { query as q } from 'faunadb'
import { serverClient, serializeFaunaCookie } from '../../utils/fauna-auth' import { serverClient, serializeFaunaCookie } from '../../utils/fauna-auth'
export default async (req, res) => { export default async function signuo(req, res) {
const { email, password } = await req.body const { email, password } = await req.body
try { try {
......
...@@ -9,11 +9,13 @@ if (typeof window !== 'undefined') { ...@@ -9,11 +9,13 @@ if (typeof window !== 'undefined') {
cxs.rehydrate(serverCss) cxs.rehydrate(serverCss)
} }
export default () => ( export default function Home() {
<div className={cx.root}> return (
<h1 className={cx.title}>My page</h1> <div className={cx.root}>
</div> <h1 className={cx.title}>My page</h1>
) </div>
)
}
const cx = { const cx = {
root: cxs({ root: cxs({
......
export default () => { export default function Home() {
return ( return (
<> <>
<h1>Hello World!</h1> <h1>Hello World!</h1>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment