Skip to content

Commit 678ca27

Browse files
committed
Nobelium主题
1 parent c1fc297 commit 678ca27

33 files changed

+1187
-4
lines changed

.env.local

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
2-
NEXT_PUBLIC_VERSION=3.6.8
2+
NEXT_PUBLIC_VERSION=3.6.8
3+
4+
5+
6+
NEXT_PUBLIC_WALINE_SERVER_URL=https://waline.tangly1024.com/
7+
NEXT_PUBLIC_NOTION_PROPERTY_PASSWORD=密码
8+
NEXT_PUBLIC_NOTION_PROPERTY_TYPE=类型
9+
NEXT_PUBLIC_NOTION_PROPERTY_TITLE=标题
10+
NEXT_PUBLIC_NOTION_PROPERTY_STATUS=状态
11+
NEXT_PUBLIC_NOTION_PROPERTY_SUMMARY=摘要
12+
NEXT_PUBLIC_NOTION_PROPERTY_SLUG=链接
13+
NEXT_PUBLIC_NOTION_PROPERTY_CATEGORY=分类
14+
NEXT_PUBLIC_NOTION_PROPERTY_DATE=日期
15+
NEXT_PUBLIC_NOTION_PROPERTY_TAGS=标签
16+
NEXT_PUBLIC_NOTION_PROPERTY_ICON=图标
17+
NOTION_PAGE_ID=29d5a78b858e4a3bbc13e51b5400fb82
18+
#影院前线NOTION_PAGE_ID=c7c08fdeb087414584a7912b92081c75
19+
NEXT_PUBLIC_THEME_SWITCH=true
20+
NEXT_PUBLIC_WALINE_SERVER_URL=https://preview-waline.tangly1024.com
21+
NEXT_PUBLIC_WALINE_RECENT=true
22+
NEXT_PUBLIC_THEME=medium
23+
#VERCEL_ENV=production
24+
ENABLE_CACHE=true
25+
26+
27+
NEXT_PUBLIC_COMMENT_ENV_ID=https://twikoo.tangly1024.com

components/Vercel.js

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

styles/globals.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,12 @@ nav {
197197
-webkit-box-orient: vertical;
198198
word-wrap: break-word;
199199
word-break: break-all;
200-
}
200+
}
201+
202+
.nobelium{
203+
@apply flex flex-col justify-between
204+
}
205+
206+
.nobelium .notion-code{
207+
@apply max-w-2xl;
208+
}

themes/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as next from './next'
55
import * as fukasawa from './fukasawa'
66
import * as hexo from './hexo'
77
import * as medium from './medium'
8+
import * as nobelium from './nobelium'
89
import * as example from './example'
910

10-
export const ALL_THEME = ['hexo', 'next', 'medium', 'fukasawa', 'example']
11-
export { hexo, next, medium, fukasawa, example }
11+
export const ALL_THEME = ['hexo', 'next', 'medium', 'fukasawa', 'nobelium', 'example']
12+
export { hexo, next, medium, fukasawa, nobelium, example }

themes/nobelium/Layout404.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import LayoutBase from './LayoutBase'
2+
3+
export const Layout404 = (props) => {
4+
return <LayoutBase {...props}>
5+
404 Not found.
6+
</LayoutBase>
7+
}

themes/nobelium/LayoutArchive.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import BLOG from '@/blog.config'
2+
import Link from 'next/link'
3+
import LayoutBase from './LayoutBase'
4+
5+
export const LayoutArchive = props => {
6+
const { posts } = props
7+
const postsSortByDate = Object.create(posts)
8+
9+
postsSortByDate.sort((a, b) => {
10+
const dateA = new Date(a?.date?.start_date || a.createdTime)
11+
const dateB = new Date(b?.date?.start_date || b.createdTime)
12+
return dateB - dateA
13+
})
14+
15+
const archivePosts = {}
16+
17+
postsSortByDate.forEach(post => {
18+
const date = post.date?.start_date.slice(0, 7)
19+
if (archivePosts[date]) {
20+
archivePosts[date].push(post)
21+
} else {
22+
archivePosts[date] = [post]
23+
}
24+
})
25+
return (
26+
<LayoutBase {...props}>
27+
<div className="mb-10 pb-20 md:py-12 p-3 min-h-screen w-full">
28+
{Object.keys(archivePosts).map(archiveTitle => (
29+
<div key={archiveTitle}>
30+
<div id={archiveTitle} className="pt-16 pb-4 text-3xl dark:text-gray-300" >
31+
{archiveTitle}
32+
</div>
33+
34+
<ul>
35+
{archivePosts[archiveTitle].map(post => (
36+
<li
37+
key={post.id}
38+
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
39+
>
40+
<div id={post?.date?.start_date}>
41+
<span className="text-gray-400">
42+
{post.date?.start_date}
43+
</span>{' '}
44+
&nbsp;
45+
<Link
46+
href={`${BLOG.SUB_PATH}/${post.slug}`}
47+
passHref
48+
>
49+
<a className="dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600">
50+
{post.title}
51+
</a>
52+
</Link>
53+
</div>
54+
</li>
55+
))}
56+
</ul>
57+
</div>
58+
))}
59+
</div>
60+
</LayoutBase>
61+
)
62+
}

themes/nobelium/LayoutBase.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import CommonHead from '@/components/CommonHead'
2+
import React from 'react'
3+
import Header from './components/Header'
4+
import { Footer } from './components/Footer'
5+
import JumpToTopButton from './components/JumpToTopButton'
6+
/**
7+
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
8+
9+
* @returns {JSX.Element}
10+
* @constructor
11+
*/
12+
const LayoutBase = props => {
13+
const { children, meta, post } = props
14+
15+
const fullWidth = post?.fullWidth ?? false
16+
17+
return (
18+
<div className='nobelium dark:text-gray-300 w-full overflow-hidden bg-white dark:bg-black min-h-screen'>
19+
<CommonHead meta={meta} />
20+
21+
{/* 顶栏LOGO */}
22+
<Header {...props} />
23+
24+
<main className={`m-auto flex-grow w-full transition-all ${
25+
!fullWidth ? 'max-w-2xl px-4' : 'px-4 md:px-24'
26+
}`}>
27+
28+
{children}
29+
30+
</main>
31+
32+
<Footer {...props} />
33+
34+
<div className='fixed right-4 bottom-4'>
35+
<JumpToTopButton />
36+
</div>
37+
</div>
38+
)
39+
}
40+
41+
export default LayoutBase

themes/nobelium/LayoutCategory.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import BLOG from '@/blog.config'
2+
import { BlogListPage } from './components/BlogListPage'
3+
import { BlogListScroll } from './components/BlogListScroll'
4+
import LayoutBase from './LayoutBase'
5+
6+
export const LayoutCategory = props => {
7+
return <LayoutBase {...props}>
8+
{BLOG.POST_LIST_STYLE === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
9+
</LayoutBase >
10+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Link from 'next/link'
2+
import LayoutBase from './LayoutBase'
3+
4+
export const LayoutCategoryIndex = (props) => {
5+
const { categories } = props
6+
7+
return <LayoutBase {...props}>
8+
<div id='category-list' className='duration-200 flex flex-wrap'>
9+
{categories && categories.map(category => {
10+
return <Link key={category.name} href={`/category/${category.name}`} passHref>
11+
<div
12+
className={'hover:text-black dark:hover:text-white dark:text-gray-300 dark:hover:bg-gray-600 px-5 cursor-pointer py-2 hover:bg-gray-100'}>
13+
<i className='mr-4 fas fa-folder' />{category.name}({category.count})
14+
</div>
15+
</Link>
16+
})}
17+
</div>
18+
</LayoutBase>
19+
}

themes/nobelium/LayoutIndex.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import BLOG from '@/blog.config'
3+
import { BlogListPage } from './components/BlogListPage'
4+
import { BlogListScroll } from './components/BlogListScroll'
5+
import LayoutBase from './LayoutBase'
6+
7+
export const LayoutIndex = props => {
8+
return (
9+
<LayoutBase {...props}>
10+
{BLOG.POST_LIST_STYLE === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
11+
</LayoutBase>
12+
)
13+
}

themes/nobelium/LayoutPage.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { BlogListPage } from './components/BlogListPage'
2+
import LayoutBase from './LayoutBase'
3+
4+
export const LayoutPage = props => {
5+
return (
6+
<LayoutBase {...props}>
7+
<BlogListPage {...props} />
8+
</LayoutBase>
9+
)
10+
}

themes/nobelium/LayoutSearch.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import BLOG from '@/blog.config'
2+
import { BlogListPage } from './components/BlogListPage'
3+
import { BlogListScroll } from './components/BlogListScroll'
4+
import { useRouter } from 'next/router'
5+
import { useEffect } from 'react'
6+
import SearchInput from './components/SearchInput'
7+
import Mark from 'mark.js'
8+
import LayoutBase from './LayoutBase'
9+
import { isBrowser } from '@/lib/utils'
10+
11+
export const LayoutSearch = props => {
12+
const { keyword } = props
13+
const router = useRouter()
14+
15+
useEffect(() => {
16+
setTimeout(() => {
17+
const container = isBrowser() && document.getElementById('container')
18+
if (container && container.innerHTML) {
19+
const re = new RegExp(keyword, 'gim')
20+
const instance = new Mark(container)
21+
instance.markRegExp(re, {
22+
element: 'span',
23+
className: 'text-red-500 border-b border-dashed'
24+
})
25+
}
26+
}, 100)
27+
}, [router.events])
28+
29+
useEffect(() => {
30+
setTimeout(() => {
31+
if (keyword) {
32+
const targets = document.getElementsByClassName('replace')
33+
for (const container of targets) {
34+
if (container && container.innerHTML) {
35+
const re = new RegExp(`${keyword}`, 'gim')
36+
container.innerHTML = container.innerHTML.replace(
37+
re,
38+
`<span class='text-red-500 border-b border-dashed'>${keyword}</span>`
39+
)
40+
}
41+
}
42+
}
43+
}, 100)
44+
}, [])
45+
46+
return <LayoutBase {...props}>
47+
<div className='pb-12'>
48+
<SearchInput {...props} />
49+
</div>
50+
51+
{BLOG.POST_LIST_STYLE === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
52+
53+
</LayoutBase>
54+
}

themes/nobelium/LayoutSlug.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import LayoutBase from './LayoutBase'
2+
import { ArticleLock } from './components/ArticleLock'
3+
import NotionPage from '@/components/NotionPage'
4+
import { ArticleInfo } from './components/ArticleInfo'
5+
import Comment from '@/components/Comment'
6+
import { ArticleFooter } from './components/ArticleFooter'
7+
8+
export const LayoutSlug = props => {
9+
const { post, lock, validPassword } = props
10+
11+
if (!post) {
12+
return <LayoutBase {...props} />
13+
}
14+
15+
return (
16+
<LayoutBase {...props}>
17+
18+
{lock && <ArticleLock validPassword={validPassword} />}
19+
20+
{!lock && <div id="notion-article" className="px-2">
21+
{post && <>
22+
<ArticleInfo post={post} />
23+
<NotionPage post={post} />
24+
<Comment frontMatter={post}/>
25+
<ArticleFooter />
26+
</>}
27+
</div>}
28+
29+
</LayoutBase>
30+
)
31+
}

0 commit comments

Comments
 (0)