-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from tangly1024/preview
样式调整
- Loading branch information
Showing
18 changed files
with
562 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,9 @@ const BLOG = { | |
CONTACT_TELEGRAM: '', | ||
|
||
// 悬浮挂件 | ||
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || false, // 是否显示宠物挂件 | ||
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件 | ||
WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/[email protected]/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models | ||
WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题 | ||
|
||
// 评论互动 可同时开启 CUSDIS UTTERRANCES GITALK | ||
COMMENT_CUSDIS_APP_ID: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID || '', // data-app-id 36位 see https://cusdis.com/ | ||
|
@@ -78,7 +79,7 @@ const BLOG = { | |
ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx | ||
|
||
isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) | ||
VERSION: '2.8.0' // 版本号 | ||
VERSION: '2.8.1' // 版本号 | ||
} | ||
|
||
module.exports = BLOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,69 @@ | ||
export const LayoutArchive = (props) => { | ||
// const { posts, tags, categories, postCount } = props | ||
return <div {...props}> | ||
Archive Page | ||
</div> | ||
import BLOG from '@/blog.config' | ||
import { useGlobal } from '@/lib/global' | ||
import Link from 'next/link' | ||
import LayoutBase from './LayoutBase' | ||
|
||
export const LayoutArchive = props => { | ||
const { posts } = props | ||
const { locale } = useGlobal() | ||
const postsSortByDate = Object.create(posts) | ||
|
||
postsSortByDate.sort((a, b) => { | ||
const dateA = new Date(a?.date.start_date || a.createdTime) | ||
const dateB = new Date(b?.date.start_date || b.createdTime) | ||
return dateB - dateA | ||
}) | ||
|
||
const meta = { | ||
title: `${locale.NAV.ARCHIVE} | ${BLOG.TITLE}`, | ||
description: BLOG.DESCRIPTION, | ||
type: 'website' | ||
} | ||
|
||
const archivePosts = {} | ||
|
||
postsSortByDate.forEach(post => { | ||
const date = post.date.start_date.slice(0, 7) | ||
if (archivePosts[date]) { | ||
archivePosts[date].push(post) | ||
} else { | ||
archivePosts[date] = [post] | ||
} | ||
}) | ||
return ( | ||
<LayoutBase {...props} meta={meta}> | ||
<div className="mb-10 pb-20 md:p-12 p-3 min-h-full"> | ||
{Object.keys(archivePosts).map(archiveTitle => ( | ||
<div key={archiveTitle}> | ||
<div | ||
className="pt-16 pb-4 text-3xl dark:text-gray-300" | ||
id={archiveTitle} | ||
> | ||
{archiveTitle} | ||
</div> | ||
<ul> | ||
{archivePosts[archiveTitle].map(post => ( | ||
<li | ||
key={post.id} | ||
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" | ||
> | ||
<div id={post?.date?.start_date}> | ||
<span className="text-gray-400"> | ||
{post.date.start_date} | ||
</span>{' '} | ||
| ||
<Link href={`${BLOG.PATH}/article/${post.slug}`} passHref> | ||
<a className="dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600"> | ||
{post.title} | ||
</a> | ||
</Link> | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
))} | ||
</div> | ||
</LayoutBase> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,48 @@ | ||
import BLOG from '@/blog.config' | ||
import { useGlobal } from '@/lib/global' | ||
import Link from 'next/link' | ||
import { useState } from 'react' | ||
import LayoutBase from './LayoutBase' | ||
|
||
export const LayoutCategory = (props) => { | ||
const { category } = props | ||
return <LayoutBase {...props}> | ||
Category - {category} | ||
</LayoutBase> | ||
export const LayoutCategory = props => { | ||
const { category, posts } = props | ||
const { locale } = useGlobal() | ||
|
||
const [page, updatePage] = useState(1) | ||
let hasMore = false | ||
const postsToShow = posts | ||
? Object.assign(posts).slice(0, BLOG.POSTS_PER_PAGE * page) | ||
: [] | ||
|
||
if (posts) { | ||
const totalCount = posts.length | ||
hasMore = page * BLOG.POSTS_PER_PAGE < totalCount | ||
} | ||
const handleGetMore = () => { | ||
if (!hasMore) return | ||
updatePage(page + 1) | ||
} | ||
|
||
return ( | ||
<LayoutBase {...props}> | ||
Category - {category} | ||
{postsToShow.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> | ||
<div | ||
onClick={handleGetMore} | ||
className="w-full my-4 py-4 text-center cursor-pointer " | ||
> | ||
{' '} | ||
{hasMore ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}{' '} | ||
</div> | ||
</div> | ||
</LayoutBase> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
import { useGlobal } from '@/lib/global' | ||
import Link from 'next/link' | ||
import LayoutBase from './LayoutBase' | ||
|
||
export const LayoutCategoryIndex = (props) => { | ||
// const { tags, allPosts, categories, postCount, latestPosts } = props | ||
const { categories } = props | ||
const { locale } = useGlobal() | ||
return <LayoutBase {...props}> | ||
CategoryIndex | ||
<div className=' p-10'> | ||
<div className='dark:text-gray-200 mb-5'> | ||
<i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}: | ||
</div> | ||
<div id='category-list' className='duration-200 flex flex-wrap'> | ||
{categories && categories.map(category => { | ||
return <Link key={category.name} href={`/category/${category.name}`} passHref> | ||
<div | ||
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'}> | ||
<i className='mr-4 fas fa-folder' />{category.name}({category.count}) | ||
</div> | ||
</Link> | ||
})} | ||
</div> | ||
</div> | ||
</LayoutBase> | ||
} |
Oops, something went wrong.
86c42ae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: