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/_document.tsx | |
import Document, { Html, Head, Main, NextScript } from 'next/document'; | |
class MyDocument extends Document { | |
render(): React.ReactElement { | |
return ( | |
<Html> | |
<Head /> | |
<body className="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"> | |
<Main /> |
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 = { | |
// ... | |
theme: { | |
extend: { | |
typography: (theme) => ({ | |
dark: { | |
css: { | |
color: theme('colors.gray.300'), | |
h1: { |
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 ThemeSwitch from './theme-switch'; | |
const Header: React.FC = () => { | |
return ( | |
<header className="py-2"> | |
<div className="flex justify-between items-center"> | |
... | |
<ThemeSwitch /> | |
</div> |
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/theme-switch.tsx | |
import { useState, useEffect } from 'react'; | |
import { useTheme } from 'next-themes'; | |
import Switch from 'react-switch'; | |
import { IconContext } from 'react-icons'; | |
import { FaMoon, FaSun } from 'react-icons/fa'; | |
const ThemeSwitch: React.FC = () => { | |
const { theme, setTheme } = useTheme(); |
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 { ThemeProvider } from 'next-themes'; | |
import 'tailwindcss/tailwind.css'; | |
const MyApp: React.FC<AppProps> = ({ Component, pageProps }: AppProps) => { | |
return ( | |
<ThemeProvider attribute="class"> | |
<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
// components/Tips.tsx | |
type Props = { | |
tips: string[]; | |
}; | |
const Tips: React.FC<Props> = ({ tips }: Props) => { | |
return ( | |
<> | |
<h2>Tips</h2> | |
<ul> |
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/Directions.tsx | |
type Props = { | |
directions: string[]; | |
}; | |
const Directions: React.FC<Props> = ({ directions }: Props) => { | |
return ( | |
<> | |
<h2>Directions</h2> | |
<ol> |
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/Ingredients.tsx | |
type Props = { | |
ingredients: string[]; | |
}; | |
const Ingredients: React.FC<Props> = ({ ingredients }: Props) => { | |
return ( | |
<> | |
<h2>Ingredients</h2> | |
<ul> |
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/posts/[slug].tsx | |
import { GetStaticProps, GetStaticPaths } from 'next'; | |
import dynamic from 'next/dynamic'; | |
import Head from 'next/head'; | |
import { serialize } from 'next-mdx-remote/serialize'; | |
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'; | |
import Directions from '../../components/Directions'; | |
import Ingredients from '../../components/Ingredients'; | |
import Layout from '../../components/Layout'; |
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/Thumbnail.tsx | |
import Image from 'next/image'; | |
import Link from 'next/link'; | |
type Props = { | |
title: string; | |
src: string; | |
slug?: string; | |
}; |
NewerOlder