Fix casing discrepancies.

This commit is contained in:
tangly1024
2022-03-16 09:42:54 +08:00
parent 3c056ba096
commit c5d6f04f11
192 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
export const Layout404 = () => {
return <div>
404 Not found.
</div>
}

View File

@@ -0,0 +1,6 @@
export const LayoutArchive = (props) => {
// const { posts, tags, categories, postCount } = props
return <div {...props}>
Archive Page
</div>
}

View File

@@ -0,0 +1,37 @@
import CommonHead from '@/components/CommonHead'
import Link from 'next/link'
/**
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
* @returns {JSX.Element}
* @constructor
*/
const LayoutBase = props => {
const { children, meta } = props
return (
<div>
<CommonHead meta={meta} />
{/* 导航菜单 */}
<div className="w-full flex justify-center my-2">
<nav className="max-w-6xl space-x-3 underline">
<Link href="/">
<a>首页</a>
</Link>
<Link href="/category">
<a>分类</a>
</Link>
<Link href="/tag">
<a>标签</a>
</Link>
</nav>
</div>
{/* 内容主体 */}
<main id="wrapper" className="flex justify-center flex-1 pb-12">
<div className="max-w-6xl px-3">{children}</div>
</main>
</div>
)
}
export default LayoutBase

View File

@@ -0,0 +1,8 @@
import LayoutBase from './LayoutBase'
export const LayoutCategory = (props) => {
const { category } = props
return <LayoutBase {...props}>
Category - {category}
</LayoutBase>
}

View File

@@ -0,0 +1,8 @@
import LayoutBase from './LayoutBase'
export const LayoutCategoryIndex = (props) => {
// const { tags, allPosts, categories, postCount, latestPosts } = props
return <LayoutBase {...props}>
CategoryIndex
</LayoutBase>
}

View File

@@ -0,0 +1,18 @@
import Link from 'next/link'
import LayoutBase from './LayoutBase'
export const LayoutIndex = props => {
const { posts } = props
return (
<LayoutBase {...props}>
{posts.map(p => (
<div key={p.id} className='border my-12'>
<Link href={`/article/${p.slug}`}>
<a className='underline cursor-pointer'>{p.title}</a>
</Link>
<div>{p.summary}</div>
</div>
))}
</LayoutBase>
)
}

View File

@@ -0,0 +1,8 @@
import LayoutBase from './LayoutBase'
export const LayoutPage = (props) => {
const { page } = props
return <LayoutBase {...props}>
Page - {page}
</LayoutBase>
}

View File

@@ -0,0 +1,42 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import LayoutBase from './LayoutBase'
export const LayoutSearch = props => {
const { keyword, posts } = props
const router = useRouter()
const currentSearch = keyword || router?.query?.s
let handleTextColor = false
useEffect(() => {
setTimeout(() => {
if (currentSearch && !handleTextColor) {
const container = document.getElementById('container')
if (container && container.innerHTML) {
const re = new RegExp(`${currentSearch}`, 'gim')
container.innerHTML = container.innerHTML.replace(
re,
`<span class='text-red-500 border-b border-dashed'>${currentSearch}</span>`
)
handleTextColor = true
}
}
}, 100)
})
return (
<LayoutBase {...props}>
<h2>Search</h2>
<div id="container">
{posts.map(p => (
<div key={p.id} className="border my-12">
<Link href={`/article/${p.slug}`}>
<a className="underline cursor-pointer">{p.title}</a>
</Link>
<div>{p.summary}</div>
</div>
))}
</div>
</LayoutBase>
)
}

View File

@@ -0,0 +1,59 @@
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>
)
}

View File

@@ -0,0 +1,8 @@
import LayoutBase from './LayoutBase'
export const LayoutTag = (props) => {
const { tag } = props
return <LayoutBase>
Tag - {tag}
</LayoutBase>
}

View File

@@ -0,0 +1,8 @@
import LayoutBase from './LayoutBase'
export const LayoutTagIndex = (props) => {
// const { tags, categories, postCount, latestPosts } = props
return <LayoutBase {...props}>
TagIndex
</LayoutBase>
}

View File

@@ -0,0 +1,4 @@
const CONFIG_EMPTY = {
TEST_CONFIG: 'TESET'
}
export default CONFIG_EMPTY

25
themes/empty/index.js Normal file
View File

@@ -0,0 +1,25 @@
import CONFIG_EMPTY from './config_empty'
import { LayoutIndex } from './LayoutIndex'
import { LayoutSearch } from './LayoutSearch'
import { LayoutArchive } from './LayoutArchive'
import { LayoutSlug } from './LayoutSlug'
import { Layout404 } from './Layout404'
import { LayoutCategory } from './LayoutCategory'
import { LayoutCategoryIndex } from './LayoutCategoryIndex'
import { LayoutPage } from './LayoutPage'
import { LayoutTag } from './LayoutTag'
import { LayoutTagIndex } from './LayoutTagIndex'
export {
CONFIG_EMPTY as THEME_CONFIG,
LayoutIndex,
LayoutSearch,
LayoutArchive,
LayoutSlug,
Layout404,
LayoutCategory,
LayoutCategoryIndex,
LayoutPage,
LayoutTag,
LayoutTagIndex
}