feature: 提交空主题

This commit is contained in:
tangly1024
2022-01-16 10:17:50 +08:00
parent f0c2bb05f6
commit 6184f687ba
14 changed files with 155 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,40 @@
import CommonHead from '@/components/CommonHead'
/**
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
* @param children
* @param layout
* @param tags
* @param meta
* @param post
* @param currentSearch
* @param currentCategory
* @param currentTag
* @param categories
* @returns {JSX.Element}
* @constructor
*/
const LayoutBase = ({
children,
headerSlot,
tags,
meta,
post,
postCount,
sideBarSlot,
floatSlot,
rightAreaSlot,
currentSearch,
currentCategory,
currentTag,
categories
}) => {
return (<>
<CommonHead meta={meta} />
<main id='wrapper' className='flex justify-center flex-1 pb-12'>
{children}
</main>
</>)
}
export default LayoutBase

View File

@@ -0,0 +1,5 @@
export const LayoutCategory = ({ tags, posts, category, categories, latestPosts, postCount }) => {
return <div>
Category - {category}
</div>
}

View File

@@ -0,0 +1,11 @@
export const LayoutCategoryIndex = ({
tags,
allPosts,
categories,
postCount,
latestPosts
}) => {
return <div>
CategoryIndex
</div>
}

View File

@@ -0,0 +1,3 @@
export const LayoutIndex = ({ posts, tags, meta, categories, postCount, latestPosts }) => {
return <div>Index</div>
}

View File

@@ -0,0 +1,5 @@
export const LayoutPage = ({ page, posts, tags, meta, categories, postCount, latestPosts }) => {
return <div>
Page - {page}
</div>
}

View File

@@ -0,0 +1,34 @@
import { useRouter } from 'next/router'
export const LayoutSearch = ({
posts,
tags,
categories,
postCount
}) => {
let filteredPosts
const searchKey = getSearchKey()
if (searchKey) {
filteredPosts = posts.filter(post => {
const tagContent = post.tags ? post.tags.join(' ') : ''
const searchContent = post.title + post.summary + tagContent
return searchContent.toLowerCase().includes(searchKey.toLowerCase())
})
} else {
filteredPosts = posts
}
console.log(filteredPosts)
return <div>
Search {searchKey}
</div>
}
function getSearchKey () {
const router = useRouter()
if (router.query && router.query.s) {
return router.query.s
}
return null
}

View File

@@ -0,0 +1,21 @@
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'
export const LayoutSlug = ({
post,
tags,
prev,
next,
recommendPosts,
categories,
postCount,
latestPosts
}) => {
return <div>
Slug
</div>
}

View File

@@ -0,0 +1,5 @@
export const LayoutTag = ({ tags, posts, tag, categories, postCount, latestPosts }) => {
return <div>
Tag - {tag}
</div>
}

View File

@@ -0,0 +1,5 @@
export const LayoutTagIndex = ({ tags, categories, postCount, latestPosts }) => {
return <div>
TagIndex
</div>
}

View File

10
themes/Empty/index.js Normal file
View File

@@ -0,0 +1,10 @@
export { LayoutIndex } from './LayoutIndex'
export { LayoutSearch } from './LayoutSearch'
export { LayoutArchive } from './LayoutArchive'
export { LayoutSlug } from './LayoutSlug'
export { Layout404 } from './Layout404'
export { LayoutCategory } from './LayoutCategory'
export { LayoutCategoryIndex } from './LayoutCategoryIndex'
export { LayoutPage } from './LayoutPage'
export { LayoutTag } from './LayoutTag'
export { LayoutTagIndex } from './LayoutTagIndex'

View File

@@ -1 +1,6 @@
/**
* 直接将./NEXT 替换成对应的主题路径
*/
export * from './NEXT' // 切换主题
// export * from './Empty' // 切换主题