Skip to content

Commit

Permalink
部分微调
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Nov 21, 2024
1 parent d2f97f7 commit d5235b3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 40 deletions.
4 changes: 2 additions & 2 deletions components/GlobalHead.js → components/SEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useEffect } from 'react'
* @param {*} param0
* @returns
*/
const GlobalHead = props => {
const SEO = props => {
const { children, siteInfo, post, NOTION_CONFIG } = props
let url = siteConfig('PATH')?.length
? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}`
Expand Down Expand Up @@ -275,4 +275,4 @@ const getSEOMeta = (props, router, locale) => {
}
}

export default GlobalHead
export default SEO
6 changes: 4 additions & 2 deletions lib/sitemap.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export async function generateSitemapXml({ allPages, NOTION_CONFIG }) {
{
loc: `${link}`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
changefreq: 'daily',
priority: 1.0
},
{
loc: `${link}/archive`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
changefreq: 'daily',
priority: 1.0
},
{
loc: `${link}/category`,
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getQueryParam } from '../lib/utils'
// 各种扩展插件 这个要阻塞引入
import BLOG from '@/blog.config'
import ExternalPlugins from '@/components/ExternalPlugins'
import GlobalHead from '@/components/GlobalHead'
import SEO from '@/components/SEO'
import { zhCN } from '@clerk/localizations'
import dynamic from 'next/dynamic'
// import { ClerkProvider } from '@clerk/nextjs'
Expand Down Expand Up @@ -55,7 +55,7 @@ const MyApp = ({ Component, pageProps }) => {
const content = (
<GlobalContextProvider {...pageProps}>
<GLayout {...pageProps}>
<GlobalHead {...pageProps} />
<SEO {...pageProps} />
<Component {...pageProps} />
</GLayout>
<ExternalPlugins {...pageProps} />
Expand Down
2 changes: 1 addition & 1 deletion themes/heo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const LayoutSearch = props => {
}
}, [])
return (
<div {...props} currentSearch={currentSearch}>
<div currentSearch={currentSearch}>
<div id='post-outer-wrapper' className='px-5 md:px-0'>
{!currentSearch ? (
<SearchNav {...props} />
Expand Down
17 changes: 10 additions & 7 deletions themes/magzine/components/BannerItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
import CONFIG from '../config'

/**
* 文字广告Banner
Expand All @@ -8,13 +9,15 @@ import Link from 'next/link'
*/
export default function BannerItem() {
// 首屏信息栏按钮文字
const banner = siteConfig('MAGZINE_HOME_BANNER_ENABLE')
const button = siteConfig('MAGZINE_HOME_BUTTON')
const text = siteConfig('MAGZINE_HOME_BUTTON_TEXT')
const url = siteConfig('MAGZINE_HOME_BUTTON_URL')
const title = siteConfig('MAGZINE_HOME_TITLE')
const description = siteConfig('MAGZINE_HOME_DESCRIPTION')
const tips = siteConfig('MAGZINE_HOME_TIPS')
const banner = siteConfig('MAGZINE_HOME_BANNER_ENABLE', null, CONFIG)

const button = siteConfig('MAGZINE_HOME_BUTTON', null, CONFIG)
const text = siteConfig('MAGZINE_HOME_BUTTON_TEXT', null, CONFIG)
const url = siteConfig('MAGZINE_HOME_BUTTON_URL', null, CONFIG)
const title = siteConfig('MAGZINE_HOME_TITLE', null, CONFIG)
const description = siteConfig('MAGZINE_HOME_DESCRIPTION', null, CONFIG)
const tips = siteConfig('MAGZINE_HOME_TIPS', null, CONFIG)

if (!banner) {
return null
}
Expand Down
2 changes: 1 addition & 1 deletion themes/magzine/components/CTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function CTA({ notice }) {
<Announcement
post={notice}
className={
'text-center text-black bg-[#7BE986] dark:bg-hexo-black-gray py-16'
'cta text-center text-black bg-[#7BE986] dark:bg-hexo-black-gray py-16'
}
/>
</>
Expand Down
54 changes: 31 additions & 23 deletions themes/magzine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,24 @@ const LayoutBase = props => {

<div
id='theme-magzine'
className={`${siteConfig('FONT_STYLE')} bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300 scroll-smooth`}>
className={`${siteConfig('FONT_STYLE')} bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen flex flex-col justify-between dark:text-gray-300 scroll-smooth`}>
<main
id='wrapper'
className={'relative flex justify-between w-full h-full mx-auto'}>
className='relative flex flex-col justify-between w-full h-full mx-auto'>
{/* 主区 */}
<div id='container-wrapper' className='w-full relative z-10'>
<div
id='container-wrapper'
className='w-full h-full min-h-screen flex flex-col relative z-10'>
<Header {...props} />
<div id='main' role='main'>

<div
id='main'
role='main'
className='flex-grow' // 这个类保证 main 区域填满剩余的空白
>
{children}
</div>
{/* 行动呼吁 */}
<CTA {...props} />

<Footer title={siteConfig('TITLE')} />
</div>
</main>
Expand Down Expand Up @@ -115,6 +121,9 @@ const LayoutIndex = props => {

{/* 文章推荐 */}
<PostListRecommend {...props} />

{/* 行动呼吁 */}
<CTA {...props} />
</div>
)
}
Expand Down Expand Up @@ -150,31 +159,28 @@ const LayoutSlug = props => {
const { post, recommendPosts, prev, next, lock, validPassword } = props
const { locale } = useGlobal()
const router = useRouter()

const waiting404 = siteConfig('POST_WAITING_TIME_FOR_404') * 1000
useEffect(() => {
// 404
if (!post) {
setTimeout(
() => {
if (isBrowser) {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
})
}
setTimeout(() => {
if (isBrowser) {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
})
}
},
siteConfig('POST_WAITING_TIME_FOR_404') * 1000
)
}
}, waiting404)
}
}, [post])

return (
<>
<div {...props} className='w-full mx-auto max-w-screen-3xl'>
<div className='w-full mx-auto max-w-screen-3xl'>
{/* 广告位 */}
<WWAds orientation='horizontal' />

Expand Down Expand Up @@ -372,9 +378,11 @@ const LayoutArchive = props => {
const Layout404 = props => {
return (
<>
<div className='w-full h-96 py-80 flex justify-center items-center'>
<div className='w-full py-40 flex justify-center items-center'>
404 Not found.
</div>
{/* 文章推荐 */}
<PostListRecommend {...props} />
</>
)
}
Expand Down
6 changes: 4 additions & 2 deletions themes/medium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ const LayoutSlug = props => {
setTimeout(
() => {
if (isBrowser) {
const article = document.querySelector('#article-wrapper #notion-article')
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
Expand All @@ -205,7 +207,7 @@ const LayoutSlug = props => {
}, [post])

return (
<div {...props}>
<div>
{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}

Expand Down

0 comments on commit d5235b3

Please sign in to comment.