Skip to content

Instantly share code, notes, and snippets.

@kjmczk
kjmczk / Meta.tsx
Created April 30, 2021 08:20
components/Meta.tsx - MDX Blog Simple - Medium
// 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;
};
@kjmczk
kjmczk / Header.tsx
Created April 30, 2021 08:19
components/Header.tsx - MDX Blog Simple - Medium
// 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>
@kjmczk
kjmczk / Layout.tsx
Created April 30, 2021 08:18
components/Layout.tsx - MDX Blog Simple - Medium
// 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) => {
@kjmczk
kjmczk / post.ts
Created April 30, 2021 08:17
types/post.ts - MDX Blog Simple - Medium
// types/post.ts
export interface IPost {
slug: string;
date: string;
thumbnail: string;
title: string;
description: string;
yields: string;
ingredients: string[];
directions: string[];
@kjmczk
kjmczk / constants.ts
Created April 30, 2021 08:16
utils/constants.ts - MDX Blog Simple - Medium
// utils/constants.ts
export const SITE_URL = 'http://localhost:3000';
export const SITE_NAME = 'My Food Blog';
export const TWITTER_USERNAME = '@MyAwesomeFoodBlog';
@kjmczk
kjmczk / mdxUtils.ts
Created April 30, 2021 08:15
utils/mdxUtils.ts - MDX Blog Simple - Medium
// utils/mdxUtils.ts
import fs from 'fs';
import { join } from 'path';
import matter from 'gray-matter';
type Items = {
[key: string]: string;
};
type Post = {
@kjmczk
kjmczk / index.tsx
Created April 30, 2021 08:14
pages/index.tsx - MDX Blog Simple - Medium
// 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';
@kjmczk
kjmczk / _app.tsx
Created April 30, 2021 08:13
pages/_app.tsx - MDX Blog Simple - Medium
// 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} />;
};
@kjmczk
kjmczk / tailwind.config.js
Created April 30, 2021 08:11
tailwind.config.js - MDX Blog Simple - Medium
// tailwind.config.js
module.exports = {
purge: ['./components/**/*.tsx', './pages/**/*.tsx'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {},
plugins: [require('@tailwindcss/typography')],
};
@kjmczk
kjmczk / new.js
Last active August 31, 2020 06:42
pages/new.js - Next Fauna Auth - Medium
// pages/new.js
import useSWR from 'swr'; // add
const New = ({ token }) => {
const { data: user } = useSWR('/api/user'); // add
...
const onSubmit = handleSubmit(async ({ task }) => {
...
// update