Skip to content

Commit

Permalink
Feat: Add blog index page
Browse files Browse the repository at this point in the history
  • Loading branch information
sandypockets committed Dec 17, 2023
1 parent 63b5df6 commit 4e9c278
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 30 deletions.
18 changes: 15 additions & 3 deletions examples/next-tailwind/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# `epic-remark next-tailwind`
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app), and integrated with `epic-remark` and everything you need to start writing content right away.

## Getting Started
### How is this different from `create-next-app`?
This `epic-remark` build of `create-next-app` is preconfigured with `epic-remark` and a few other goodies to get you started writing content right away. Most notably:
* pages/blog/index.jsx
* pages/blog/[slug].jsx
* posts/

These pages represent a basic blog setup.

* Write new `epic-remark`-flavoured markdown in the `posts/` directory.
* The `blog/index.jsx` page displays a list of all posts in the `posts/` directory.
* The `blog/[slug].jsx` page displays a single post, like `/blog/example`.

## Getting Started
First, run the development server:

```bash
Expand Down Expand Up @@ -35,6 +47,6 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=epic-remark-example) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
1 change: 1 addition & 0 deletions examples/next-tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"epic-remark": "^0.1.10",
"gray-matter": "^4.0.3",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
Expand Down
46 changes: 46 additions & 0 deletions examples/next-tailwind/pages/blog/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Link from 'next/link';
import fs from 'fs';
import path from 'path';
import matter from 'gray-matter';

export default function Blog({ posts }){
return (
<div className="max-w-3xl mx-auto px-6 py-12">
<h1 className="text-5xl font-semibold my-3">Blog</h1>
<ul>
{posts.map(post => (
<li key={post.id}>
<Link href={`/blog/${post.id}`}>
<h2 className="text-2xl font-bold">{post.title}</h2>
<p className="text-gray-600">{post.date}</p>
<p>{post.summary}</p>
</Link>
</li>
))}
</ul>
</div>
);
};

export const getStaticProps = async () => {
const postsDirectory = path.join(process.cwd(), 'posts');
const filenames = fs.readdirSync(postsDirectory);

const posts = filenames.map(filename => {
const id = filename.replace(/\.md$/, '');
const fullPath = path.join(postsDirectory, filename);
const fileContents = fs.readFileSync(fullPath, 'utf8');
const { data: frontMatter } = matter(fileContents);

return {
id,
...frontMatter,
};
});

return {
props: {
posts,
},
};
};
49 changes: 22 additions & 27 deletions examples/next-tailwind/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import Image from 'next/image';
import { Inter } from 'next/font/google';
import Link from 'next/link'

const inter = Inter({ subsets: ['latin'] });

export default function Home() {
return (
<main className={`flex min-h-screen flex-col items-center justify-between p-24 ${inter.className}`}>
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<main className={`flex w-full min-h-screen flex-col items-center justify-between p-24 ${inter.className}`}>
<div className="z-10 max-w-5xl w-full flex flex-col items-start gap-3 justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
Start writing your markdown content in&nbsp;
<code className="font-mono font-bold">posts/</code>
</p>
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Edit this page in&nbsp;
<code className="font-mono font-bold">pages/index.js</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By <Image src="/vercel.svg" alt="Vercel Logo" className="dark:invert" width={100} height={24} priority />
</a>
</div>
</div>


<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700/10 after:dark:from-sky-900 after:dark:via-[#0141ff]/40 before:lg:h-[360px]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
Expand All @@ -34,46 +30,45 @@ export default function Home() {
/>
</div>

<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
<div className="mb-32 mx-auto w-full grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<Link
href="/blog"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs <span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
Blog <span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Find in-depth information about Next.js features and API.</p>
</a>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Check out the epic-remark powered blog</p>
</Link>

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=epic-remark"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn <span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
Docs <span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Find in-depth information about Next.js features and API.</p>
</a>

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=epic-remark"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
Learn <span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">-&gt;</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Discover and deploy boilerplate example Next.js&nbsp;projects.</p>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=epic-remark"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
Expand Down

0 comments on commit 4e9c278

Please sign in to comment.