diff --git a/examples/next-tailwind/README.md b/examples/next-tailwind/README.md index 5d98b1e..f4fcdb0 100644 --- a/examples/next-tailwind/README.md +++ b/examples/next-tailwind/README.md @@ -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 @@ -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. diff --git a/examples/next-tailwind/package.json b/examples/next-tailwind/package.json index 198ad49..9f9a453 100644 --- a/examples/next-tailwind/package.json +++ b/examples/next-tailwind/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "epic-remark": "^0.1.10", + "gray-matter": "^4.0.3", "next": "14.0.4", "react": "^18", "react-dom": "^18" diff --git a/examples/next-tailwind/pages/blog/index.jsx b/examples/next-tailwind/pages/blog/index.jsx new file mode 100644 index 0000000..596e495 --- /dev/null +++ b/examples/next-tailwind/pages/blog/index.jsx @@ -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 ( +
+

Blog

+ +
+ ); +}; + +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, + }, + }; +}; diff --git a/examples/next-tailwind/pages/index.js b/examples/next-tailwind/pages/index.js index 2fb6d31..51b8a93 100644 --- a/examples/next-tailwind/pages/index.js +++ b/examples/next-tailwind/pages/index.js @@ -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 ( -
-
+
+

- Get started by editing  + Start writing your markdown content in  + posts/ +

+

+ Edit this page in  pages/index.js

-
- - By Vercel Logo - -
+
-
- +

- Docs -> + Blog ->

-

Find in-depth information about Next.js features and API.

-
+

Check out the epic-remark powered blog

+

- Learn -> + Docs ->

-

Learn about Next.js in an interactive course with quizzes!

+

Find in-depth information about Next.js features and API.

- Templates{' '} - -> + Learn ->

-

Discover and deploy boilerplate example Next.js projects.

+

Learn about Next.js in an interactive course with quizzes!