Skip to content

Commit

Permalink
♻️ layout
Browse files Browse the repository at this point in the history
  • Loading branch information
yokinist committed Jun 20, 2021
1 parent 16bf35d commit 2f6f331
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 167 deletions.
148 changes: 0 additions & 148 deletions layouts/fullwidth.js

This file was deleted.

5 changes: 3 additions & 2 deletions layouts/default.js → layouts/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const mapPageUrl = id => {
return 'https://www.notion.so/' + id.replace(/-/g, '')
}

const DefaultLayout = ({ children, blockMap, frontMatter, emailHash }) => {
const Layout = ({ children, blockMap, frontMatter, emailHash, fullWidth = false }) => {
const locale = useLocale()
const router = useRouter()
const cusdisI18n = ['zh-cn', 'es', 'tr', 'pt-BR', 'oc']
Expand All @@ -43,6 +43,7 @@ const DefaultLayout = ({ children, blockMap, frontMatter, emailHash }) => {
description={frontMatter.summary}
// date={new Date(frontMatter.publishedAt).toISOString()}
type="article"
fullWidth={fullWidth}
>
<article>
<h1 className="font-bold text-3xl text-black dark:text-white">
Expand Down Expand Up @@ -144,4 +145,4 @@ const DefaultLayout = ({ children, blockMap, frontMatter, emailHash }) => {
)
}

export default DefaultLayout
export default Layout
24 changes: 7 additions & 17 deletions pages/[slug].js
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import DefaultLayout from '@/layouts/default'
import FullWidthLayout from '@/layouts/fullwidth'
import Layout from '@/layouts/layout'
import { getAllPosts, getPostBlocks } from '@/lib/notion'
import BLOG from '@/blog.config'
import { createHash } from 'crypto'

const BlogPost = ({ post, blockMap, emailHash }) => {
if (!post) return null
return (
<>
{post.fullWidth ? (
<FullWidthLayout
blockMap={blockMap}
frontMatter={post}
emailHash={emailHash}
></FullWidthLayout>
) : (
<DefaultLayout
blockMap={blockMap}
frontMatter={post}
emailHash={emailHash}
></DefaultLayout>
)}
</>
<Layout
blockMap={blockMap}
frontMatter={post}
emailHash={emailHash}
fullWidth={post.fullWidth}
/>
)
}

Expand Down

0 comments on commit 2f6f331

Please sign in to comment.