This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/Meta.tsx | |
import Head from 'next/head'; | |
import { useRouter } from 'next/router'; | |
import { SITE_URL, SITE_NAME, TWITTER_USERNAME } from '../utils/constants'; | |
type Props = { | |
pageTitle?: string; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/Header.tsx | |
import Link from 'next/link'; | |
import { SITE_NAME } from '../utils/constants'; | |
const Header: React.FC = () => { | |
return ( | |
<header className="py-2"> | |
<Link href="/"> | |
<a className="text-2xl font-bold text-green-500">{SITE_NAME}</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/Layout.tsx | |
import Header from '../components/Header'; | |
import Meta from '../components/Meta'; | |
type Props = { | |
children: React.ReactNode; | |
pageTitle?: string; | |
}; | |
const Layout: React.FC<Props> = ({ children, pageTitle }: Props) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// types/post.ts | |
export interface IPost { | |
slug: string; | |
date: string; | |
thumbnail: string; | |
title: string; | |
description: string; | |
yields: string; | |
ingredients: string[]; | |
directions: string[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utils/constants.ts | |
export const SITE_URL = 'http://localhost:3000'; | |
export const SITE_NAME = 'My Food Blog'; | |
export const TWITTER_USERNAME = '@MyAwesomeFoodBlog'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utils/mdxUtils.ts | |
import fs from 'fs'; | |
import { join } from 'path'; | |
import matter from 'gray-matter'; | |
type Items = { | |
[key: string]: string; | |
}; | |
type Post = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/index.tsx | |
import { GetStaticProps } from 'next'; | |
import Head from 'next/head'; | |
import Link from 'next/link'; | |
import Layout from '../components/Layout'; | |
import Thumbnail from '../components/Thumbnail'; | |
import { IPost } from '../types/post'; | |
import { SITE_NAME } from '../utils/constants'; | |
import { getAllPosts } from '../utils/mdxUtils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/_app.tsx | |
import type { AppProps } from 'next/app'; | |
// import '../styles/globals.css' // remove | |
import 'tailwindcss/tailwind.css'; // add | |
const MyApp: React.FC<AppProps> = ({ Component, pageProps }: AppProps) => { | |
return <Component {...pageProps} />; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tailwind.config.js | |
module.exports = { | |
purge: ['./components/**/*.tsx', './pages/**/*.tsx'], | |
darkMode: false, // or 'media' or 'class' | |
theme: { | |
extend: {}, | |
}, | |
variants: {}, | |
plugins: [require('@tailwindcss/typography')], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/new.js | |
import useSWR from 'swr'; // add | |
const New = ({ token }) => { | |
const { data: user } = useSWR('/api/user'); // add | |
... | |
const onSubmit = handleSubmit(async ({ task }) => { | |
... | |
// update |