Skip to content

Commit

Permalink
Merge pull request #1255 from tangly1024/release/4.0.0
Browse files Browse the repository at this point in the history
Release/4.0.0
  • Loading branch information
tangly1024 authored Jul 18, 2023
2 parents f5bdd5e + 7b1baa3 commit 48cb3ee
Show file tree
Hide file tree
Showing 444 changed files with 11,654 additions and 4,508 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=3.16.4
NEXT_PUBLIC_VERSION=4.0.0
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
}
},
rules: {
'react/no-unknown-property': 'off', // <style jsx>
'react/prop-types': 'off',
'space-before-function-paren': 0,
'react-hooks/rules-of-hooks': 'error' // Checks rules of Hooks
Expand Down
21 changes: 14 additions & 7 deletions blog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BLOG = {
NOTION_HOST: process.env.NEXT_PUBLIC_NOTION_HOST || 'https://www.notion.so', // Notion域名,您可以选择用自己的域名进行反向代理,如果不懂得什么是反向代理,请勿修改此项

// 网站字体
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-serif', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
FONT_URL: [
// 字体CSS 例如 https://npm.elemecdn.com/[email protected]/style.css
'https://fonts.googleapis.com/css?family=Bitter&display=swap',
Expand All @@ -48,12 +48,12 @@ const BLOG = {
'-apple-system',
'BlinkMacSystemFont',
'"Hiragino Sans GB"',
'"Microsoft YaHei"',
'"Segoe UI Emoji"',
'"Segoe UI Symbol"',
'"Segoe UI"',
'"Noto Sans SC"',
'HarmonyOS_Regular',
'"Microsoft YaHei"',
'"Helvetica Neue"',
'Helvetica',
'"Source Han Sans SC"',
Expand Down Expand Up @@ -98,6 +98,7 @@ const BLOG = {
'https://npm.elemecdn.com/prism-themes/themes/prism-a11y-dark.min.css', // 代码样式主题 更多参考 https://github.com/PrismJS/prism-themes
CODE_MAC_BAR: process.env.NEXT_PUBLIC_CODE_MAC_BAR || true, // 代码左上角显示mac的红黄绿图标
CODE_LINE_NUMBERS: process.env.NEXT_PUBLIC_CODE_LINE_NUMBERS || 'false', // 是否显示行号
CODE_COLLAPSE: process.env.NEXT_PUBLIC_CODE_COLLAPSE || 'false', // 是否折叠代码框

// Mermaid 图表CDN
MERMAID_CDN: process.env.NEXT_PUBLIC_MERMAID_CDN || 'https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js', // CDN
Expand Down Expand Up @@ -126,6 +127,9 @@ const BLOG = {
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制

POST_DISABLE_GALLERY_CLICK: process.env.NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK || false, // 画册视图禁止点击,方便在友链页面的画册插入链接

// ********动态特效相关********
// 鼠标点击烟花特效
FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关
// 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩
Expand All @@ -138,18 +142,18 @@ const BLOG = {

// 樱花飘落特效
SAKURA: process.env.NEXT_PUBLIC_SAKURA || false, // 开关

// 漂浮线段特效
NEST: process.env.NEXT_PUBLIC_NEST || false, // 开关

// 动态彩带特效
FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || false, // 开关
// 静态彩带特效
RIBBON: process.env.NEXT_PUBLIC_RIBBON || false, // 开关

// 星空雨特效 黑夜模式才会生效
STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关

// ********挂件组件相关********
// Chatbase
CHATBASE_ID: process.env.NEXT_PUBLIC_CHATBASE_ID || null, // 是否显示chatbase机器人 https://www.chatbase.co/
// 悬浮挂件
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
WIDGET_PET_LINK:
Expand Down Expand Up @@ -192,6 +196,7 @@ const BLOG = {
MUSIC_PLAYER_METING_LRC_TYPE:
process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_LRC_TYPE || '1', // 可选值: 3 | 1 | 0(0:禁用 lrc 歌词,1:lrc 格式的字符串,3:lrc 文件 url)

// ********挂件组件相关********
// ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK

// twikoo
Expand Down Expand Up @@ -320,14 +325,16 @@ const BLOG = {
icon: process.env.NEXT_PUBLIC_NOTION_PROPERTY_ICON || 'icon'
},

// RSS
// RSS订阅
ENABLE_RSS: process.env.NEXT_PUBLIC_ENABLE_RSS || true, // 是否开启RSS订阅功能
MAILCHIMP_LIST_ID: process.env.MAILCHIMP_LIST_ID || null, // 开启mailichimp邮件订阅 客户列表ID ,具体使用方法参阅文档
MAILCHIMP_API_KEY: process.env.MAILCHIMP_API_KEY || null, // 开启mailichimp邮件订阅 APIkey

// 作废配置
AVATAR: process.env.NEXT_PUBLIC_AVATAR || '/avatar.svg', // 作者头像,被notion中的ICON覆盖。若无ICON则取public目录下的avatar.png
TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 ,被notion中的页面标题覆盖;此处请勿留空白,否则服务器无法编译
HOME_BANNER_IMAGE:
process.env.NEXT_PUBLIC_HOME_BANNER_IMAGE || './bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件
process.env.NEXT_PUBLIC_HOME_BANNER_IMAGE || '/bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件
DESCRIPTION:
process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖

Expand Down
14 changes: 14 additions & 0 deletions components/ChatBase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import BLOG from '@/blog.config'

export default function ChatBase() {
if (!BLOG.CHATBASE_ID) {
return <></>
}

return <iframe
src={`https://www.chatbase.co/chatbot-iframe/${BLOG.CHATBASE_ID}`}
width="100%"
style={{ height: '100%', minHeight: '700px' }}
frameborder="0"
></iframe>
}
2 changes: 1 addition & 1 deletion components/Collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Collapse = props => {
}, [props.isOpen])

return (
<div ref={ref} style={type === 'vertical' ? { height: '0px' } : { width: '0px' }} className={`${props.className} overflow-hidden duration-200 `}>
<div ref={ref} style={type === 'vertical' ? { height: '0px', willChange: 'height' } : { width: '0px', willChange: 'width' }} className={`${props.className} overflow-hidden duration-200 `}>
{props.children}
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions components/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
ssr: false
})

const Comment = ({ frontMatter }) => {
const Comment = ({ frontMatter, className }) => {
const router = useRouter()

if (isBrowser() && ('giscus' in router.query || router.query.target === 'comment')) {
Expand All @@ -70,7 +70,7 @@ const Comment = ({ frontMatter }) => {
}

return (
<div id='comment' className='comment mt-5 text-gray-800 dark:text-gray-300'>
<div id='comment' className={`comment mt-5 text-gray-800 dark:text-gray-300 ${className || ''}`}>
<Tabs>

{BLOG.COMMENT_TWIKOO_ENV_ID && (<div key='Twikoo'>
Expand Down
12 changes: 12 additions & 0 deletions components/CommonScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ import BLOG from '@/blog.config'
*/
const CommonScript = () => {
return (<>

{BLOG.CHATBASE_ID && (<>
<script id={BLOG.CHATBASE_ID} src="https://www.chatbase.co/embed.min.js" defer/>
<script async dangerouslySetInnerHTML={{
__html: `
window.chatbaseConfig = {
chatbotId: "${BLOG.CHATBASE_ID}",
}
`
}}/>
</>)}

{BLOG.COMMENT_DAO_VOICE_ID && (<>
{/* DaoVoice 反馈 */}
<script async dangerouslySetInnerHTML={{
Expand Down
24 changes: 21 additions & 3 deletions components/DarkModeButton.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import { useGlobal } from '@/lib/global'
import { saveDarkModeToCookies } from '@/themes/theme'
import { Moon, Sun } from './HeroIcons'
import { useImperativeHandle } from 'react'

/**
* 深色模式按钮
*/
const DarkModeButton = (props) => {
const { cRef, className } = props
const { isDarkMode, updateDarkMode } = useGlobal()

/**
* 对外暴露方法
*/
useImperativeHandle(cRef, () => {
return {
handleChangeDarkMode: () => {
handleChangeDarkMode()
}
}
})

// 用户手动设置主题
const handleChangeDarkMode = () => {
const newStatus = !isDarkMode
Expand All @@ -13,8 +31,8 @@ const DarkModeButton = (props) => {
htmlElement.classList?.add(newStatus ? 'dark' : 'light')
}

return <div onClick={handleChangeDarkMode} className={'px-1 dark:text-gray-200 text-gray-800 z-10 duration-200 text-xl hover:scale-110 cursor-pointer transform ' + props.className}>
<i id='darkModeButton' className={`${isDarkMode ? 'far fa-sun' : 'far fa-moon'}`}/>
</div>
return <div onClick={handleChangeDarkMode} className={`${className || ''} flex justify-center dark:text-gray-200 text-gray-800`}>
<div id='darkModeButton' className=' hover:scale-110 cursor-pointer transform duration-200 w-5 h-5'> {isDarkMode ? <Sun /> : <Moon />}</div>
</div>
}
export default DarkModeButton
4 changes: 2 additions & 2 deletions components/DebugPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import { useEffect, useState } from 'react'
import Select from './Select'
import { useGlobal } from '@/lib/global'
import { ALL_THEME } from '@/themes/theme'
import { THEMES } from '@/themes/theme'
import { useRouter } from 'next/router'

/**
Expand All @@ -16,7 +16,7 @@ const DebugPanel = () => {
const [siteConfig, updateSiteConfig] = useState({})

// 主题下拉框
const themeOptions = ALL_THEME.map(t => ({ value: t, text: t }))
const themeOptions = THEMES?.map(t => ({ value: t, text: t }))

useEffect(() => {
updateSiteConfig(Object.assign({}, BLOG))
Expand Down
2 changes: 2 additions & 0 deletions components/ExternalPlugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BLOG from 'blog.config'
import dynamic from 'next/dynamic'
import ChatBase from './ChatBase'

// import TwikooCommentCounter from '@/components/TwikooCommentCounter'
// import { DebugPanel } from '@/components/DebugPanel'
Expand Down Expand Up @@ -53,6 +54,7 @@ const ExternalPlugin = (props) => {
{JSON.parse(BLOG.FLUTTERINGRIBBON) && <FlutteringRibbon />}
{JSON.parse(BLOG.COMMENT_TWIKOO_COUNT_ENABLE) && <TwikooCommentCounter {...props}/>}
{JSON.parse(BLOG.RIBBON) && <Ribbon />}
{BLOG.CHATBASE_ID && <ChatBase />}
<VConsole/>
</>
}
Expand Down
56 changes: 56 additions & 0 deletions components/FlipCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { useState } from 'react'

/**
* 翻转组件
* @param {*} props
* @returns
*/
export default function FlipCard(props) {
const [isFlipped, setIsFlipped] = useState(false)

function handleCardFlip() {
setIsFlipped(!isFlipped)
}

return (
<div className={`flip-card ${isFlipped ? 'flipped' : ''}`} >
<div className={`flip-card-front ${props.className || ''}`} onMouseEnter={handleCardFlip}>
{props.frontContent}
</div>
<div className={`flip-card-back ${props.className || ''}`} onMouseLeave={handleCardFlip}>
{props.backContent}
</div>
<style jsx>{`
.flip-card {
width: 100%;
height: 100%;
display: inline-block;
position: relative;
transform-style: preserve-3d;
transition: transform 0.2s;
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
}
.flip-card-front {
z-index: 2;
transform: rotateY(0);
}
.flip-card-back {
transform: rotateY(180deg);
}
.flip-card.flipped {
transform: rotateY(180deg);
}
`}</style>
</div>
)
}
48 changes: 48 additions & 0 deletions components/FullScreenButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { isBrowser } from '@/lib/utils'
import React, { useState } from 'react'

/**
* 全屏按钮
* @returns
*/
const FullScreenButton = () => {
const [isFullScreen, setIsFullScreen] = useState(false)

const handleFullScreenClick = () => {
if (!isBrowser()) {
return
}
const element = document.documentElement
if (!isFullScreen) {
if (element.requestFullscreen) {
element.requestFullscreen()
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen()
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen()
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen()
}
setIsFullScreen(true)
} else {
if (document.exitFullscreen) {
document.exitFullscreen()
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen()
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen()
} else if (document.msExitFullscreen) {
document.msExitFullscreen()
}
setIsFullScreen(false)
}
}

return (
<button onClick={handleFullScreenClick} className='dark:text-gray-300'>
{isFullScreen ? '退出全屏' : <i className="fa-solid fa-expand"></i>}
</button>
)
}

export default FullScreenButton
10 changes: 5 additions & 5 deletions components/GoogleAdsense.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { useEffect } from 'react'

/**
* 初始化谷歌广告
* @returns
*/
export default function GoogleAdsense() {
const initGoogleAdsense = () => {
setTimeout(() => {
Expand All @@ -21,12 +25,8 @@ export default function GoogleAdsense() {
}

const router = useRouter()

useEffect(() => {
router.events.on('routeChangeComplete', initGoogleAdsense)
return () => {
router.events.off('routeChangeComplete', initGoogleAdsense)
}
initGoogleAdsense()
}, [router])

return null
Expand Down
Loading

0 comments on commit 48cb3ee

Please sign in to comment.