Skip to content

Commit

Permalink
starter 加快首屏
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Oct 31, 2024
1 parent de4d7cf commit 42d025f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
54 changes: 38 additions & 16 deletions themes/starter/components/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { siteConfig } from '@/lib/config'
/**
* 英雄大图区块
*/
export const Hero = () => {
export const Hero = props => {
const CONFIG = props?.NOTION_CONFIG || CONFIG
return (
<>
{/* <!-- ====== Hero Section Start --> */}
Expand All @@ -19,37 +20,49 @@ export const Hero = () => {
data-wow-delay='.2s'>
{/* 主标题 */}
<h1 className='mb-6 text-3xl font-bold leading-snug text-white sm:text-4xl sm:leading-snug lg:text-5xl lg:leading-[1.2]'>
{siteConfig('STARTER_HERO_TITLE_1')}
{siteConfig('STARTER_HERO_TITLE_1', null, CONFIG)}
</h1>
{/* 次标题 */}
<p className='mx-auto mb-9 max-w-[600px] text-base font-medium text-white sm:text-lg sm:leading-[1.44]'>
{siteConfig('STARTER_HERO_TITLE_2')}
{siteConfig('STARTER_HERO_TITLE_2', null, CONFIG)}
</p>
{/* 按钮组 */}
<ul className='mb-10 flex flex-wrap items-center justify-center gap-5'>
{siteConfig('STARTER_HERO_BUTTON_1_TEXT') && (
{siteConfig('STARTER_HERO_BUTTON_1_TEXT', null, CONFIG) && (
<li>
<a
href={siteConfig('STARTER_HERO_BUTTON_1_URL')}
className='inline-flex items-center justify-center rounded-md bg-white px-7 py-[14px] text-center text-base font-medium text-dark shadow-1 transition duration-300 ease-in-out hover:bg-gray-2 hover:text-body-color'>
{siteConfig('STARTER_HERO_BUTTON_1_TEXT')}
{siteConfig('STARTER_HERO_BUTTON_1_TEXT', null, CONFIG)}
</a>
</li>
)}
{siteConfig('STARTER_HERO_BUTTON_2_TEXT') && (
{siteConfig('STARTER_HERO_BUTTON_2_TEXT', null, CONFIG) && (
<li>
<a
href={siteConfig('STARTER_HERO_BUTTON_2_URL')}
href={siteConfig(
'STARTER_HERO_BUTTON_2_URL',
null,
CONFIG
)}
target='_blank'
className='flex items-center rounded-md bg-white/[0.12] px-6 py-[14px] text-base font-medium text-white transition duration-300 ease-in-out hover:bg-white hover:text-dark'
rel='noreferrer'>
{siteConfig('STARTER_HERO_BUTTON_2_ICON') && (
{siteConfig(
'STARTER_HERO_BUTTON_2_ICON',
null,
CONFIG
) && (
<img
className='mr-4'
src={siteConfig('STARTER_HERO_BUTTON_2_ICON')}
src={siteConfig(
'STARTER_HERO_BUTTON_2_ICON',
null,
CONFIG
)}
/>
)}
{siteConfig('STARTER_HERO_BUTTON_2_TEXT')}
{siteConfig('STARTER_HERO_BUTTON_2_TEXT', null, CONFIG)}
</a>
</li>
)}
Expand All @@ -58,17 +71,21 @@ export const Hero = () => {
</div>

{/* 产品预览图片 */}
{siteConfig('STARTER_HERO_PREVIEW_IMAGE') && (
{siteConfig('STARTER_HERO_PREVIEW_IMAGE', null, CONFIG) && (
<div className='w-full px-4'>
<div
className='wow fadeInUp relative z-10 mx-auto max-w-[845px]'
data-wow-delay='.25s'>
<div className='mt-16'>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={siteConfig('STARTER_HERO_PREVIEW_IMAGE')}
alt={siteConfig('TITLE')}
title={siteConfig('TITLE')}
src={siteConfig(
'STARTER_HERO_PREVIEW_IMAGE',
null,
CONFIG
)}
alt={siteConfig('TITLE', null, CONFIG)}
title={siteConfig('TITLE', null, CONFIG)}
className='mx-auto max-w-full rounded-t-xl rounded-tr-xl'
/>
</div>
Expand All @@ -87,11 +104,16 @@ export const Hero = () => {
</div>
</div>
{/* 横幅图片 */}
{siteConfig('STARTER_HERO_BANNER_IMAGE') && (
{siteConfig('STARTER_HERO_BANNER_IMAGE', null, CONFIG) && (
<div className='container'>
<LazyImage
priority
className='w-full'
src={siteConfig('STARTER_HERO_BANNER_IMAGE')}></LazyImage>
src={siteConfig(
'STARTER_HERO_BANNER_IMAGE',
null,
CONFIG
)}></LazyImage>
</div>
)}
{/* <!-- ====== Hero Section End --> */}
Expand Down
26 changes: 13 additions & 13 deletions themes/starter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import CONFIG from './config'
import { Style } from './style'
// import { MadeWithButton } from './components/MadeWithButton'
import Comment from '@/components/Comment'
import LoadingCover from '@/components/LoadingCover'
import ShareBar from '@/components/ShareBar'
import { useGlobal } from '@/lib/global'
import { loadWowJS } from '@/lib/plugins/wow'
Expand Down Expand Up @@ -85,25 +84,26 @@ const LayoutIndex = props => {
const posts = props?.allNavPages ? props.allNavPages.slice(0, count) : []
return (
<>
<LoadingCover />
{/* 英雄区 */}
{siteConfig('STARTER_HERO_ENABLE') && <Hero />}
{siteConfig('STARTER_HERO_ENABLE', true, CONFIG) && <Hero {...props} />}
{/* 合作伙伴 */}
{siteConfig('STARTER_BRANDS_ENABLE') && <Brand />}
{siteConfig('STARTER_BRANDS_ENABLE', true, CONFIG) && <Brand />}
{/* 产品特性 */}
{siteConfig('STARTER_FEATURE_ENABLE') && <Features />}
{siteConfig('STARTER_FEATURE_ENABLE', true, CONFIG) && <Features />}
{/* 关于 */}
{siteConfig('STARTER_ABOUT_ENABLE') && <About />}
{siteConfig('STARTER_ABOUT_ENABLE', true, CONFIG) && <About />}
{/* 价格 */}
{siteConfig('STARTER_PRICING_ENABLE') && <Pricing />}
{siteConfig('STARTER_PRICING_ENABLE', true, CONFIG) && <Pricing />}
{/* 评价展示 */}
{siteConfig('STARTER_TESTIMONIALS_ENABLE') && <Testimonials />}
{siteConfig('STARTER_TESTIMONIALS_ENABLE', true, CONFIG) && (
<Testimonials />
)}
{/* 常见问题 */}
{siteConfig('STARTER_FAQ_ENABLE') && <FAQ />}
{siteConfig('STARTER_FAQ_ENABLE', true, CONFIG) && <FAQ />}
{/* 团队介绍 */}
{siteConfig('STARTER_TEAM_ENABLE') && <Team />}
{siteConfig('STARTER_TEAM_ENABLE', true, CONFIG) && <Team />}
{/* 博文列表 */}
{siteConfig('STARTER_BLOG_ENABLE') && (
{siteConfig('STARTER_BLOG_ENABLE', true, CONFIG) && (
<>
<Blog posts={posts} />
<div className='container mx-auto flex justify-end mb-4'>
Expand All @@ -115,10 +115,10 @@ const LayoutIndex = props => {
</>
)}
{/* 联系方式 */}
{siteConfig('STARTER_CONTACT_ENABLE') && <Contact />}
{siteConfig('STARTER_CONTACT_ENABLE', true, CONFIG) && <Contact />}

{/* 行动呼吁 */}
{siteConfig('STARTER_CTA_ENABLE') && <CTA />}
{siteConfig('STARTER_CTA_ENABLE', true, CONFIG) && <CTA />}
</>
)
}
Expand Down

0 comments on commit 42d025f

Please sign in to comment.