mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-23 04:35:50 +00:00
Use function instead of const
This commit is contained in:
@@ -6,59 +6,59 @@ import Link from 'next/link'
|
||||
const name = '[Your Name]'
|
||||
export const siteTitle = 'Next.js Sample Website'
|
||||
|
||||
const Page = ({ children, home }) => (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
export default function Page({ children, home }) {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Page
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import '../styles/global.css'
|
||||
|
||||
const App = ({ Component, pageProps }) => <Component {...pageProps} />
|
||||
|
||||
export default App
|
||||
export default function App({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
|
||||
@@ -5,36 +5,38 @@ import { getSortedPostsData } from '../lib/posts'
|
||||
import Link from 'next/link'
|
||||
import Date from '../components/Date'
|
||||
|
||||
const Home = ({ allPostsData }) => (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
<Link href="/posts/[id]" as={`/posts/${id}`}>
|
||||
<a>{title}</a>
|
||||
</Link>
|
||||
<br />
|
||||
<small className={utilStyles.lightText}>
|
||||
<Date dateString={date} />
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
export default function Home({ allPostsData }) {
|
||||
return (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
<Link href="/posts/[id]" as={`/posts/${id}`}>
|
||||
<a>{title}</a>
|
||||
</Link>
|
||||
<br />
|
||||
<small className={utilStyles.lightText}>
|
||||
<Date dateString={date} />
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const allPostsData = getSortedPostsData()
|
||||
|
||||
@@ -4,20 +4,22 @@ import Head from 'next/head'
|
||||
import Date from '../../components/Date'
|
||||
import utilStyles from '../../styles/utils.module.css'
|
||||
|
||||
const Post = ({ postData }) => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>{postData.title}</title>
|
||||
</Head>
|
||||
<article>
|
||||
<h1 className={utilStyles.headingXl}>{postData.title}</h1>
|
||||
<div className={utilStyles.lightText}>
|
||||
<Date dateString={postData.date} />
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} />
|
||||
</article>
|
||||
</Layout>
|
||||
)
|
||||
export default function Post({ postData }) {
|
||||
return (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>{postData.title}</title>
|
||||
</Head>
|
||||
<article>
|
||||
<h1 className={utilStyles.headingXl}>{postData.title}</h1>
|
||||
<div className={utilStyles.lightText}>
|
||||
<Date dateString={postData.date} />
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} />
|
||||
</article>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const paths = getAllPostIds()
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
const FirstPost = () => (
|
||||
<>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)
|
||||
|
||||
export default FirstPost
|
||||
export default function FirstPost() {
|
||||
return (
|
||||
<>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,59 +6,59 @@ import Link from 'next/link'
|
||||
const name = 'Shu Uesugi'
|
||||
export const siteTitle = 'Next.js Sample Website'
|
||||
|
||||
const Page = ({ children, home }) => (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
export default function Page({ children, home }) {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Page
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import '../styles/global.css'
|
||||
|
||||
const App = ({ Component, pageProps }) => <Component {...pageProps} />
|
||||
|
||||
export default App
|
||||
export default function App({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
|
||||
@@ -5,42 +5,44 @@ import { getSortedPostsData } from '../lib/posts'
|
||||
import Link from 'next/link'
|
||||
import Date from '../components/Date'
|
||||
|
||||
const Home = ({ allPostsData }) => (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>
|
||||
Hello, I’m <strong>Shu</strong>. I write code at{' '}
|
||||
<a href="https://zeit.co">ZEIT</a>, the team behind{' '}
|
||||
<a href="https://nextjs.org/">Next.js</a>. You can contact me via{' '}
|
||||
<a href="https://twitter.com/chibicode">Twitter</a> or{' '}
|
||||
<a href="mailto:chibicode@zeit.co">email</a>.
|
||||
</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
<Link href="/posts/[id]" as={`/posts/${id}`}>
|
||||
<a>{title}</a>
|
||||
</Link>
|
||||
<br />
|
||||
<small className={utilStyles.lightText}>
|
||||
<Date dateString={date} />
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
export default function Home({ allPostsData }) {
|
||||
return (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>
|
||||
Hello, I’m <strong>Shu</strong>. I write code at{' '}
|
||||
<a href="https://zeit.co">ZEIT</a>, the team behind{' '}
|
||||
<a href="https://nextjs.org/">Next.js</a>. You can contact me via{' '}
|
||||
<a href="https://twitter.com/chibicode">Twitter</a> or{' '}
|
||||
<a href="mailto:chibicode@zeit.co">email</a>.
|
||||
</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
<Link href="/posts/[id]" as={`/posts/${id}`}>
|
||||
<a>{title}</a>
|
||||
</Link>
|
||||
<br />
|
||||
<small className={utilStyles.lightText}>
|
||||
<Date dateString={date} />
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const allPostsData = getSortedPostsData()
|
||||
@@ -50,5 +52,3 @@ export async function getStaticProps() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Home
|
||||
|
||||
@@ -4,20 +4,22 @@ import Head from 'next/head'
|
||||
import Date from '../../components/Date'
|
||||
import utilStyles from '../../styles/utils.module.css'
|
||||
|
||||
const Post = ({ postData }) => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>{postData.title}</title>
|
||||
</Head>
|
||||
<article>
|
||||
<h1 className={utilStyles.headingXl}>{postData.title}</h1>
|
||||
<div className={utilStyles.lightText}>
|
||||
<Date dateString={postData.date} />
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} />
|
||||
</article>
|
||||
</Layout>
|
||||
)
|
||||
export default function Post({ postData }) {
|
||||
return (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>{postData.title}</title>
|
||||
</Head>
|
||||
<article>
|
||||
<h1 className={utilStyles.headingXl}>{postData.title}</h1>
|
||||
<div className={utilStyles.lightText}>
|
||||
<Date dateString={postData.date} />
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} />
|
||||
</article>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const paths = getAllPostIds()
|
||||
@@ -35,5 +37,3 @@ export async function getStaticProps({ params }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Post
|
||||
|
||||
@@ -6,59 +6,59 @@ import Link from 'next/link'
|
||||
const name = '[Your Name]'
|
||||
export const siteTitle = 'Next.js Sample Website'
|
||||
|
||||
const Page = ({ children, home }) => (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
export default function Page({ children, home }) {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Page
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import '../styles/global.css'
|
||||
|
||||
const App = ({ Component, pageProps }) => <Component {...pageProps} />
|
||||
export default function App({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
|
||||
export default App
|
||||
|
||||
@@ -2,19 +2,19 @@ import Head from 'next/head'
|
||||
import Layout, { siteTitle } from '../components/Layout'
|
||||
import utilStyles from '../styles/utils.module.css'
|
||||
|
||||
const Home = () => (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
|
||||
export default Home
|
||||
export default function Home() {
|
||||
return (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
<p>
|
||||
(This is a sample website - you’ll be building a site like this on{' '}
|
||||
<a href="https://nextjs.org/learn">our Next.js tutorial</a>.)
|
||||
</p>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@ import Head from 'next/head'
|
||||
import Link from 'next/link'
|
||||
import Layout from '../../components/Layout'
|
||||
|
||||
const FirstPost = () => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>First Post</title>
|
||||
</Head>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</Layout>
|
||||
)
|
||||
|
||||
export default FirstPost
|
||||
export default function FirstPost() {
|
||||
return (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>First Post</title>
|
||||
</Head>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,59 +6,59 @@ import Link from 'next/link'
|
||||
const name = '[Your Name]'
|
||||
export const siteTitle = 'Next.js Sample Website'
|
||||
|
||||
const Page = ({ children, home }) => (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
export default function Page({ children, home }) {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Learn how to build a personal website using Next.js"
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`https://og-image.now.sh/${encodeURI(
|
||||
siteTitle
|
||||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`}
|
||||
/>
|
||||
</Head>
|
||||
<header className={styles.header}>
|
||||
{home ? (
|
||||
<>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerHomeImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
<h1 className={utilStyles.heading2Xl}>{name}</h1>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
<a>
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
className={`${styles.headerImage} ${utilStyles.borderCircle}`}
|
||||
alt={name}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
<h2 className={utilStyles.headingLg}>
|
||||
<Link href="/">
|
||||
<a className={utilStyles.colorInherit}>{name}</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
{!home && (
|
||||
<div className={styles.backToHome}>
|
||||
<Link href="/">
|
||||
<a>← Back to home</a>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Page
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import '../styles/global.css'
|
||||
|
||||
const App = ({ Component, pageProps }) => <Component {...pageProps} />
|
||||
export default function App({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
|
||||
export default App
|
||||
|
||||
@@ -3,38 +3,38 @@ import Layout, { siteTitle } from '../components/Layout'
|
||||
import utilStyles from '../styles/utils.module.css'
|
||||
import { getSortedPostsData } from '../lib/posts'
|
||||
|
||||
const Home = ({ allPostsData }) => (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
{title}
|
||||
<br />
|
||||
{id}
|
||||
<br />
|
||||
{date}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
export default function Home({ allPostsData }) {
|
||||
return (
|
||||
<Layout home>
|
||||
<Head>
|
||||
<title>{siteTitle}</title>
|
||||
</Head>
|
||||
<section className={utilStyles.headingMd}>
|
||||
<p>[Your Self Introduction]</p>
|
||||
</section>
|
||||
<section className={`${utilStyles.headingMd} ${utilStyles.padding1px}`}>
|
||||
<h2 className={utilStyles.headingLg}>Blog</h2>
|
||||
<ul className={utilStyles.list}>
|
||||
{allPostsData.map(({ id, date, title }) => (
|
||||
<li className={utilStyles.listItem}>
|
||||
{title}
|
||||
<br />
|
||||
{id}
|
||||
<br />
|
||||
{date}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
const allPostsData = getSortedPostsData()
|
||||
return {
|
||||
props: {
|
||||
allPostsData,
|
||||
},
|
||||
allPostsData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Home
|
||||
|
||||
@@ -2,18 +2,18 @@ import Head from 'next/head'
|
||||
import Link from 'next/link'
|
||||
import Layout from '../../components/Layout'
|
||||
|
||||
const FirstPost = () => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>First Post</title>
|
||||
</Head>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</Layout>
|
||||
)
|
||||
|
||||
export default FirstPost
|
||||
export default function FirstPost() {
|
||||
return (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>First Post</title>
|
||||
</Head>
|
||||
<h1>First Post</h1>
|
||||
<h2>
|
||||
<Link href="/">
|
||||
<a>Back to home</a>
|
||||
</Link>
|
||||
</h2>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user