Skip to content
This repository was archived by the owner on Feb 14, 2022. It is now read-only.

Commit 78e0d74

Browse files
committed
Add initial post page
1 parent 4f583c4 commit 78e0d74

File tree

3 files changed

+87
-11
lines changed

3 files changed

+87
-11
lines changed

src/components/PageTitle.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function PageTitle({ children }) {
2+
return (
3+
<h1 className="text-3xl leading-9 font-extrabold text-gray-900 tracking-tighter sm:text-4xl sm:leading-10 md:text-5xl md:leading-none">
4+
{children}
5+
</h1>
6+
)
7+
}

src/components/Post.js

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,83 @@
1+
import PageTitle from '@/components/PageTitle'
2+
import { format } from 'date-fns'
3+
import Link from 'next/link'
4+
15
export default function Post({ meta, children }) {
26
return (
3-
<div>
4-
<h1>{meta.title}</h1>
5-
<div>
6-
{meta.authors.map((author) => (
7-
<img key={author.twitter} src={author.avatar} alt={author.name} />
8-
))}
7+
<article className="xl:divide-y xl:divide-gray-200">
8+
<header className="xl:pb-10">
9+
<div className="space-y-1">
10+
<div>
11+
<div className="text-sm uppercase font-medium leading-6 text-teal-500 tracking-wide">
12+
<Link href="/">
13+
<a>News</a>
14+
</Link>
15+
</div>
16+
<PageTitle>{meta.title}</PageTitle>
17+
</div>
18+
<dl className="space-y-10">
19+
<div>
20+
<dt className="sr-only">Published on</dt>
21+
<dd className="text-base leading-6 font-medium text-gray-500">
22+
<time dateTime={meta.date}>{format(new Date(meta.date), 'EEEE, LLLL d, y')}</time>
23+
</dd>
24+
</div>
25+
</dl>
26+
</div>
27+
</header>
28+
<div
29+
className="divide-y xl:divide-y-0 divide-gray-200 xl:grid xl:grid-cols-4 xl:col-gap-6 pb-16 xl:pb-20"
30+
style={{ gridTemplateRows: 'auto 1fr' }}
31+
>
32+
<dl className="py-10 xl:border-b xl:border-gray-200">
33+
<dt className="sr-only">Authors</dt>
34+
<dd>
35+
<ul className="flex xl:block space-x-8 sm:space-x-12 xl:space-x-0 xl:space-y-8">
36+
{meta.authors.map((author) => (
37+
<li key={author.twitter} className="flex items-center space-x-2">
38+
<img src={author.avatar} alt="" className="w-10 h-10 rounded-full" />
39+
<dl className="text-sm font-medium leading-5 whitespace-no-wrap">
40+
<dt className="sr-only">Name</dt>
41+
<dd className="text-gray-900">{author.name}</dd>
42+
<dt className="sr-only">Twitter</dt>
43+
<dd>
44+
<a href={`https://twitter.com/${author.twitter}`} className="text-teal-500">
45+
{author.twitter}
46+
</a>
47+
</dd>
48+
</dl>
49+
</li>
50+
))}
51+
</ul>
52+
</dd>
53+
</dl>
54+
<div className="py-10 xl:pb-0 xl:col-span-3 xl:row-span-2">{children}</div>
55+
<footer className="text-sm font-medium leading-5 divide-y divide-gray-200 xl:col-start-1 xl:row-start-2">
56+
<div className="space-y-8 py-8">
57+
<div>
58+
<h2 className="text-xs tracking-wide uppercase text-gray-500">Next Article</h2>
59+
<div className="text-teal-500">
60+
<Link href="/">
61+
<a>Introducing the official IntelliSense VS Code Plugin</a>
62+
</Link>
63+
</div>
64+
</div>
65+
<div>
66+
<h2 className="text-xs tracking-wide uppercase text-gray-500">Previous Article</h2>
67+
<div className="text-teal-500">
68+
<Link href="/">
69+
<a>Introducing the official IntelliSense VS Code Plugin</a>
70+
</Link>
71+
</div>
72+
</div>
73+
</div>
74+
<div className="pt-8">
75+
<Link href="/">
76+
<a className="text-teal-500">View all posts</a>
77+
</Link>
78+
</div>
79+
</footer>
980
</div>
10-
{children}
11-
</div>
81+
</article>
1282
)
1383
}

src/pages/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { format } from 'date-fns'
22
import Link from 'next/link'
33
import Head from 'next/head'
44
import Header from '@/components/Header'
5+
import PageTitle from '@/components/PageTitle'
56

67
function importAll(r) {
78
return r.keys().map((fileName) => ({ link: fileName.replace(/\.mdx$/, ''), module: r(fileName) }))
@@ -21,9 +22,7 @@ export default function Home() {
2122
return (
2223
<div className="divide-y divide-gray-200">
2324
<div className="pb-8 space-y-5">
24-
<h1 className="text-3xl leading-9 font-extrabold text-gray-900 tracking-tighter sm:text-4xl sm:leading-10 md:text-5xl md:leading-none">
25-
Blog
26-
</h1>
25+
<PageTitle>Blog</PageTitle>
2726
<p className="text-lg leading-7 text-gray-500">
2827
Latest project announcements, features and company updates from Tailwind CSS.
2928
</p>

0 commit comments

Comments
 (0)