mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
import BLOG from '@/blog.config'
|
|
import { getPageTableOfContents } from 'notion-utils'
|
|
import 'prismjs'
|
|
import 'prismjs/components/prism-bash'
|
|
import 'prismjs/components/prism-javascript'
|
|
import 'prismjs/components/prism-markup'
|
|
import 'prismjs/components/prism-python'
|
|
import 'prismjs/components/prism-typescript'
|
|
import {
|
|
Code,
|
|
Collection,
|
|
CollectionRow,
|
|
Equation,
|
|
NotionRenderer
|
|
} from 'react-notion-x'
|
|
import LayoutBase from './LayoutBase'
|
|
|
|
const mapPageUrl = id => {
|
|
return 'https://www.notion.so/' + id.replace(/-/g, '')
|
|
}
|
|
|
|
export const LayoutSlug = props => {
|
|
const { post } = props
|
|
const meta = {
|
|
title: `${post.title} | ${BLOG.TITLE}`,
|
|
description: post.summary,
|
|
type: 'article',
|
|
tags: post.tags
|
|
}
|
|
|
|
if (post?.blockMap?.block) {
|
|
post.content = Object.keys(post.blockMap.block)
|
|
post.toc = getPageTableOfContents(post, post.blockMap)
|
|
}
|
|
|
|
return (
|
|
<LayoutBase {...props} meta={meta}>
|
|
<div>
|
|
<h2>{post?.title}</h2>
|
|
<p>
|
|
<section id="notion-article" className="px-1">
|
|
{post.blockMap && (
|
|
<NotionRenderer
|
|
recordMap={post.blockMap}
|
|
mapPageUrl={mapPageUrl}
|
|
components={{
|
|
equation: Equation,
|
|
code: Code,
|
|
collectionRow: CollectionRow,
|
|
collection: Collection
|
|
}}
|
|
/>
|
|
)}
|
|
</section>
|
|
</p>
|
|
</div>
|
|
</LayoutBase>
|
|
)
|
|
}
|