Skip to content

Commit

Permalink
Common
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jul 30, 2023
1 parent 1353acf commit d1dfd32
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 14 deletions.
4 changes: 0 additions & 4 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ import dynamic from 'next/dynamic'

// 自定义样式css和js引入
import ExternalScript from '@/components/ExternalScript'
import CommonHead from '@/components/CommonHead'

// 各种扩展插件 动画等
const ExternalPlugins = dynamic(() => import('@/components/ExternalPlugins'))

const MyApp = ({ Component, pageProps }) => {
useEffect(() => {
AOS.init()
}, [])
const { meta } = pageProps

return (
<GlobalContextProvider {...pageProps}>
<CommonHead meta={meta}/>
<ExternalScript />
<Component {...pageProps} />
<ExternalPlugins {...pageProps} />
Expand Down
7 changes: 6 additions & 1 deletion themes/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import TagItem from './components/TagItem'
import { useRouter } from 'next/router'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import CommonHead from '@/components/CommonHead'

/**
* 基础布局框架
Expand All @@ -35,7 +36,7 @@ import { Style } from './style'
* @constructor
*/
const LayoutBase = props => {
const { children, slotTop } = props
const { children, slotTop, meta } = props
const { onLoading } = useGlobal()

// 增加一个状态以触发 Transition 组件的动画
Expand All @@ -48,6 +49,10 @@ const LayoutBase = props => {

return (
<div id='theme-example' className='dark:text-gray-300 bg-white dark:bg-black'>

{/* SEO信息 */}
<CommonHead meta={meta}/>

<Style/>

{/* 页头 */}
Expand Down
5 changes: 4 additions & 1 deletion themes/fukasawa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import dynamic from 'next/dynamic'
import { AdSlot } from '@/components/GoogleAdsense'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'

const Live2D = dynamic(() => import('@/components/Live2D'))

Expand All @@ -42,7 +43,7 @@ export const useFukasawaGlobal = () => useContext(ThemeGlobalFukasawa)
* @constructor
*/
const LayoutBase = (props) => {
const { children, headerSlot } = props
const { children, headerSlot, meta } = props
const leftAreaSlot = <Live2D />
const { onLoading } = useGlobal()

Expand All @@ -65,6 +66,8 @@ const LayoutBase = (props) => {
<ThemeGlobalFukasawa.Provider value={{ isCollapsed, setIsCollapse }}>

<div id='theme-fukasawa'>
{/* SEO信息 */}
<CommonHead meta={meta}/>
<Style/>

<TopNav {...props} />
Expand Down
4 changes: 3 additions & 1 deletion themes/gitbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import NotionPage from '@/components/NotionPage'
import { ArticleLock } from './components/ArticleLock'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import CommonHead from '@/components/CommonHead'

// 主题全局变量
const ThemeGlobalGitbook = createContext()
Expand All @@ -42,7 +43,7 @@ export const useGitBookGlobal = () => useContext(ThemeGlobalGitbook)
* @constructor
*/
const LayoutBase = (props) => {
const { children, post, allNavPages, slotLeft, slotRight, slotTop } = props
const { children, post, allNavPages, slotLeft, slotRight, slotTop, meta } = props
const { onLoading } = useGlobal()
const router = useRouter()
const [tocVisible, changeTocVisible] = useState(false)
Expand All @@ -58,6 +59,7 @@ const LayoutBase = (props) => {

return (
<ThemeGlobalGitbook.Provider value={{ tocVisible, changeTocVisible, filteredNavPages, setFilteredNavPages, allNavPages, pageNavVisible, changePageNavVisible }}>
<CommonHead meta={meta}/>
<Style/>

<div id='theme-gitbook' className='bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300'>
Expand Down
4 changes: 3 additions & 1 deletion themes/heo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ import LazyImage from '@/components/LazyImage'
* @constructor
*/
const LayoutBase = props => {
const { children, headerSlot, slotTop, slotRight, siteInfo, className } = props
const { children, headerSlot, slotTop, slotRight, siteInfo, className, meta } = props

return (
<div id='theme-heo' className='bg-[#f7f9fe] dark:bg-[#18171d] h-full min-h-screen flex flex-col'>
{/* SEO信息 */}
<CommonHead meta={meta}/>
<Style />

{/* 顶部嵌入 导航栏,首页放hero,文章页放文章详情 */}
Expand Down
2 changes: 1 addition & 1 deletion themes/hexo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const LayoutBase = props => {
return (
<div id='theme-hexo'>
{/* 网页SEO */}
<CommonHead meta={meta} siteInfo={siteInfo} />
<CommonHead meta={meta}/>
<Style/>

{/* 顶部导航 */}
Expand Down
5 changes: 4 additions & 1 deletion themes/medium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { Transition } from '@headlessui/react'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import ArticleInfo from './components/ArticleInfo'
import CommonHead from '@/components/CommonHead'

// 主题全局状态
const ThemeGlobalMedium = createContext()
Expand All @@ -47,14 +48,16 @@ export const useMediumGlobal = () => useContext(ThemeGlobalMedium)
* @constructor
*/
const LayoutBase = props => {
const { children, showInfoCard = true, slotRight, slotTop, siteInfo, notice } = props
const { children, showInfoCard = true, slotRight, slotTop, siteInfo, notice, meta } = props
const { locale } = useGlobal()
const router = useRouter()
const [tocVisible, changeTocVisible] = useState(false)
const { onLoading } = useGlobal()

return (
<ThemeGlobalMedium.Provider value={{ tocVisible, changeTocVisible }}>
{/* SEO相关 */}
<CommonHead meta={meta}/>
{/* CSS样式 */}
<Style/>

Expand Down
5 changes: 4 additions & 1 deletion themes/next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import BlogListBar from './components/BlogListBar'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'

/**
* 基础布局 采用左中右三栏布局,移动端使用顶部导航栏
* @returns {JSX.Element}
* @constructor
*/
const LayoutBase = (props) => {
const { children, headerSlot, floatSlot, rightAreaSlot, siteInfo } = props
const { children, headerSlot, floatSlot, rightAreaSlot, siteInfo, meta } = props
const { onLoading } = useGlobal()
const targetRef = useRef(null)
const floatButtonGroup = useRef(null)
Expand Down Expand Up @@ -69,6 +70,8 @@ const LayoutBase = (props) => {

return (
<div id='theme-next'>
{/* SEO相关 */}
<CommonHead meta={meta}/>
<Style/>

{/* 移动端顶部导航栏 */}
Expand Down
5 changes: 4 additions & 1 deletion themes/nobelium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import BlogListBar from './components/BlogListBar'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'

/**
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
Expand All @@ -31,13 +32,15 @@ import replaceSearchResult from '@/components/Mark'
* @constructor
*/
const LayoutBase = props => {
const { children, post, topSlot } = props
const { children, post, topSlot, meta } = props

const fullWidth = post?.fullWidth ?? false
const { onLoading } = useGlobal()

return (
<div id='theme-nobelium' className='nobelium relative dark:text-gray-300 w-full bg-white dark:bg-black min-h-screen'>
{/* SEO相关 */}
<CommonHead meta={meta}/>
{/* SEO相关 */}
<Style/>

Expand Down
5 changes: 4 additions & 1 deletion themes/plog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { saveDarkModeToCookies } from '@/themes/theme'
import Modal from './components/Modal'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'

// 主题全局状态
const ThemeGlobalPlog = createContext()
Expand All @@ -34,7 +35,7 @@ export const usePlogGlobal = () => useContext(ThemeGlobalPlog)
* @constructor
*/
const LayoutBase = props => {
const { children, topSlot } = props
const { children, topSlot, meta } = props
const { onLoading, updateDarkMode } = useGlobal()
const [showModal, setShowModal] = useState(false)
const [modalContent, setModalContent] = useState(null)
Expand All @@ -58,6 +59,8 @@ const LayoutBase = props => {
return (
<ThemeGlobalPlog.Provider value={{ showModal, setShowModal, modalContent, setModalContent }}>
<div id='theme-plog' className='plog relative dark:text-gray-300 w-full bg-black min-h-screen'>
{/* SEO相关 */}
<CommonHead meta={meta}/>
<Style/>

{/* 移动端顶部导航栏 */}
Expand Down
5 changes: 4 additions & 1 deletion themes/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SearchInput from './components/SearchInput'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'

/**
* 基础布局
Expand All @@ -32,14 +33,16 @@ import replaceSearchResult from '@/components/Mark'
* @returns
*/
const LayoutBase = props => {
const { children, slotTop } = props
const { children, slotTop, meta } = props
const { onLoading } = useGlobal()

if (isBrowser()) {
loadExternalResource('/css/theme-simple.css', 'css')
}
return (
<div id='theme-simple' className='min-h-screen flex flex-col dark:text-gray-300 bg-white dark:bg-black'>
{/* SEO相关 */}
<CommonHead meta={meta}/>
<Style/>

{CONFIG.TOP_BAR && <TopBar {...props} />}
Expand Down

0 comments on commit d1dfd32

Please sign in to comment.