refactor: NEXT 主题配置规整

This commit is contained in:
tangly1024
2022-01-16 10:03:36 +08:00
parent 4909557397
commit f0c2bb05f6
28 changed files with 52 additions and 53 deletions

View File

@@ -11,7 +11,7 @@ import { useGlobal } from '@/lib/global'
import PropTypes from 'prop-types'
import React, { useEffect, useRef, useState } from 'react'
import smoothscroll from 'smoothscroll-polyfill'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from './config_next'
/**
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏

View File

@@ -1,6 +1,6 @@
import { useGlobal } from '@/lib/global'
import BLOG from '@/blog.config'
import LayoutBase from '@/themes/NEXT/LayoutBase'
import LayoutBase from './LayoutBase'
import StickyBar from './components/StickyBar'
import CategoryList from './components/CategoryList'
import BlogPostListScroll from './components/BlogPostListScroll'

View File

@@ -1,6 +1,6 @@
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
export default function ArticleCopyright ({ author, url }) {
if (!CONFIG_NEXT.ARTICLE_COPYRIGHT) {

View File

@@ -1,9 +1,9 @@
import BLOG from '@/blog.config'
import BlogAround from '@/themes/NEXT/components/BlogAround'
import BlogAround from './BlogAround'
import Comment from '@/components/Comment'
import RecommendPosts from '@/themes/NEXT/components/RecommendPosts'
import ShareBar from '@/themes/NEXT/components/ShareBar'
import TagItem from '@/themes/NEXT/components/TagItem'
import RecommendPosts from './RecommendPosts'
import ShareBar from './ShareBar'
import TagItem from './TagItem'
import formatDate from '@/lib/formatDate'
import { useGlobal } from '@/lib/global'
import { faEye, faFolderOpen } from '@fortawesome/free-solid-svg-icons'
@@ -102,8 +102,7 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) {
<div className="hidden busuanzi_container_page_pv font-light mr-2">
<FontAwesomeIcon icon={faEye} className='mr-1'/>
&nbsp;
<span className="mr-2 busuanzi_value_page_pv"
></span>
<span className="mr-2 busuanzi_value_page_pv"/>
<span className='mr-2'>|</span>
</div>
</div>
@@ -141,7 +140,7 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) {
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-2708419466378217"
data-ad-slot="3806269138"></ins>
data-ad-slot="3806269138"/>
</section>
{/* 版权声明 */}

View File

@@ -8,7 +8,7 @@ import React from 'react'
import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x'
import Card from './Card'
import TagItemMini from './TagItemMini'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
const BlogPostCard = ({ post, showSummary }) => {
const { locale } = useGlobal()

View File

@@ -1,7 +1,7 @@
import BlogPostCard from '@/themes/NEXT/components/BlogPostCard'
import BlogPostCard from './BlogPostCard'
import PaginationNumber from './PaginationNumber'
import BLOG from '@/blog.config'
import BlogPostListEmpty from '@/themes/NEXT/components/BlogPostListEmpty'
import BlogPostListEmpty from './BlogPostListEmpty'
/**
* 文章列表分页表格

View File

@@ -1,10 +1,10 @@
import BLOG from '@/blog.config'
import BlogPostCard from '@/themes/NEXT/components/BlogPostCard'
import BlogPostListEmpty from '@/themes/NEXT/components/BlogPostListEmpty'
import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 博客列表滚动分页

View File

@@ -1,6 +1,7 @@
import { loadUserThemeFromCookies, saveTheme, useGlobal } from '@/lib/global'
import { useGlobal } from '@/lib/global'
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme'
const DarkModeButton = () => {
const { changeTheme } = useGlobal()

View File

@@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global'
import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme'
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
export default function FloatDarkModeButton () {
if (!CONFIG_NEXT.WIDGET_DARK_MODE) {

View File

@@ -3,7 +3,7 @@ import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useEffect, useState } from 'react'
import Typed from 'typed.js'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
let wrapperTop = 0
let windowTop = 0

View File

@@ -2,7 +2,7 @@ import { faArrowDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React, { useEffect, useState } from 'react'
import smoothscroll from 'smoothscroll-polyfill'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 跳转到网页顶部

View File

@@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global'
import { faArrowUp } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React from 'react'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 跳转到网页顶部

View File

@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'
import throttle from 'lodash.throttle'
import DarkModeButton from '@/themes/NEXT/components/DarkModeButton'
import DarkModeButton from './DarkModeButton'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faBars } from '@fortawesome/free-solid-svg-icons'

View File

@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
let hasLoad = false
export default function Live2D () {

View File

@@ -1,7 +1,7 @@
import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 展示文章推荐

View File

@@ -15,7 +15,7 @@ import {
faWeixin
} from '@fortawesome/free-brands-svg-icons'
import { faLink } from '@fortawesome/free-solid-svg-icons'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
const ShareBar = ({ post }) => {
if (!CONFIG_NEXT.ARTICLE_SHARE) {

View File

@@ -1,5 +1,5 @@
import React from 'react'
import ShareBar from '@/themes/NEXT/components/ShareBar'
import ShareBar from './ShareBar'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faShareAltSquare } from '@fortawesome/free-solid-svg-icons'

View File

@@ -1,13 +1,13 @@
import InfoCard from '@/themes/NEXT/components/InfoCard'
import MenuButtonGroup from '@/themes/NEXT/components/MenuButtonGroup'
import SearchInput from '@/themes/NEXT/components/SearchInput'
import Toc from '@/themes/NEXT/components/Toc'
import InfoCard from './InfoCard'
import MenuButtonGroup from './MenuButtonGroup'
import SearchInput from './SearchInput'
import Toc from './Toc'
import { useGlobal } from '@/lib/global'
import React from 'react'
import Tabs from '@/themes/NEXT/components/Tabs'
import Tabs from './Tabs'
import Logo from './Logo'
import Card from './Card'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 侧边平铺
@@ -52,9 +52,9 @@ const SideAreaLeft = ({ currentTag, post, postCount, currentSearch }) => {
<span className='px-1 '>
<strong className='font-medium'>{postCount}</strong>{locale.COMMON.POSTS}</span>
<span className='px-1 busuanzi_container_site_uv hidden'>
| <strong className='pl-1 busuanzi_value_site_uv font-medium'></strong>{locale.COMMON.VISITORS}</span>
| <strong className='pl-1 busuanzi_value_site_uv font-medium'/>{locale.COMMON.VISITORS}</span>
{/* <span className='px-1 busuanzi_container_site_pv hidden'>
| <strong className='pl-1 busuanzi_value_site_pv font-medium'></strong>{locale.COMMON.VIEWS}</span> */}
| <strong className='pl-1 busuanzi_value_site_pv font-medium'/>{locale.COMMON.VIEWS}</span> */}
</div>
</>
</div>

View File

@@ -6,7 +6,7 @@ import React from 'react'
import Card from './Card'
import CategoryGroup from './CategoryGroup'
import TagGroups from './TagGroups'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 侧边平铺

View File

@@ -1,6 +1,6 @@
import CategoryGroup from '@/themes/NEXT/components/CategoryGroup'
import InfoCard from '@/themes/NEXT/components/InfoCard'
import TagGroups from '@/themes/NEXT/components/TagGroups'
import CategoryGroup from './CategoryGroup'
import InfoCard from './InfoCard'
import TagGroups from './TagGroups'
import { useGlobal } from '@/lib/global'
import { faAngleDoubleRight, faTag, faThList } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
@@ -15,11 +15,10 @@ import React from 'react'
* @param posts
* @param categories
* @param currentCategory
* @param currentSearch
* @returns {JSX.Element}
* @constructor
*/
const SideBar = ({ title, tags, currentTag, post, slot, categories, currentCategory, currentSearch }) => {
const SideBar = ({ tags, currentTag, post, slot, categories, currentCategory }) => {
const { locale } = useGlobal()
return <aside id='sidebar' className='bg-white dark:bg-gray-900 w-80 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'>
@@ -34,7 +33,7 @@ const SideBar = ({ title, tags, currentTag, post, slot, categories, currentCateg
<section className='mt-8'>
<div className='text-sm px-5 flex flex-nowrap justify-between font-light'>
<div className='text-gray-600 dark:text-gray-200'><FontAwesomeIcon icon={faThList} className='mr-2' />{locale.COMMON.CATEGORY}</div>
<Link href='/category' passHref>
<Link href={'/category'} passHref>
<a className='mb-3 text-gray-400 hover:text-black dark:text-gray-400 dark:hover:text-white hover:underline cursor-pointer'>
{locale.COMMON.MORE} <FontAwesomeIcon icon={faAngleDoubleRight} />
</a>
@@ -49,7 +48,7 @@ const SideBar = ({ title, tags, currentTag, post, slot, categories, currentCateg
<section className='mt-4'>
<div className='text-sm py-2 px-5 flex flex-nowrap justify-between font-light dark:text-gray-200'>
<div className='text-gray-600 dark:text-gray-200'><FontAwesomeIcon icon={faTag} className='mr-2'/>{locale.COMMON.TAGS}</div>
<Link href='/tag' passHref>
<Link href={'/tag'} passHref>
<a className='text-gray-400 hover:text-black dark:hover:text-white hover:underline cursor-pointer'>
{locale.COMMON.MORE} <FontAwesomeIcon icon={faAngleDoubleRight} />
</a>
@@ -73,7 +72,7 @@ const SideBar = ({ title, tags, currentTag, post, slot, categories, currentCateg
data-ad-format="fluid"
data-ad-layout-key="-5j+cz+30-f7+bf"
data-ad-client="ca-pub-2708419466378217"
data-ad-slot="1510444138"></ins>
data-ad-slot="1510444138"/>
</section>
</aside>

View File

@@ -1,4 +1,4 @@
import SideBar from '@/themes/NEXT/components/SideBar'
import SideBar from './SideBar'
import { useRouter } from 'next/router'
import React, { useEffect, useImperativeHandle } from 'react'
@@ -7,7 +7,7 @@ import React, { useEffect, useImperativeHandle } from 'react'
* @returns {JSX.Element}
* @constructor
*/
const SideBarDrawer = ({ post, currentTag, cRef, tags, slot, categories, currentCategory }) => {
const SideBarDrawer = ({ post, cRef, tags, slot, categories, currentCategory }) => {
// 暴露给父组件 通过cRef.current.handleMenuClick 调用
useImperativeHandle(cRef, () => {
return {
@@ -22,7 +22,7 @@ const SideBarDrawer = ({ post, currentTag, cRef, tags, slot, categories, current
const router = useRouter()
useEffect(() => {
const sideBarDrawerRouteListener = url => {
const sideBarDrawerRouteListener = () => {
switchSideDrawerVisible(false)
}
router.events.on('routeChangeComplete', sideBarDrawerRouteListener)

View File

@@ -1,6 +1,6 @@
import throttle from 'lodash.throttle'
import { useCallback, useEffect } from 'react'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
let windowTop = 0

View File

@@ -1,4 +1,4 @@
import TagItemMini from '@/themes/NEXT/components/TagItemMini'
import TagItemMini from './TagItemMini'
/**
* 标签组

View File

@@ -7,7 +7,7 @@ import { useGlobal } from '@/lib/global'
const TagItem = ({ tag, selected }) => {
const { locale } = useGlobal()
if (!tag) {
<>{locale.COMMON.NOTAG}</>
<div> { locale.COMMON.NOTAG } </div>
}
return (
<Link href={selected ? '/' : `/tag/${encodeURIComponent(tag.name)}`} passHref>

View File

@@ -1,5 +1,5 @@
import React from 'react'
import TagItem from '@/themes/NEXT/components/TagItem'
import TagItem from './TagItem'
/**
* 横向的标签列表
* @param tags

View File

@@ -1,4 +1,4 @@
import Toc from '@/themes/NEXT/components/Toc'
import Toc from './Toc'
import React, { useImperativeHandle, useState } from 'react'
import { useGlobal } from '@/lib/global'

View File

@@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global'
import { faListOl } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React from 'react'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
/**
* 点击召唤目录抽屉

View File

@@ -10,7 +10,7 @@ import Logo from './Logo'
import MenuButtonGroup from './MenuButtonGroup'
import SearchDrawer from './SearchDrawer'
import TagGroups from './TagGroups'
import CONFIG_NEXT from '@/themes/NEXT/config_next'
import CONFIG_NEXT from '../config_next'
let windowTop = 0