From 5de570ba5ec72aaf7c7bcbf0758c7f2549d91836 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 8 Feb 2024 16:39:36 +0800 Subject: [PATCH] theme-starter --- next.config.js | 15 +- .../components/About.js | 20 +- .../components/BackToTopButton.js | 27 +- .../{landing-2 => starter}/components/Blog.js | 6 +- .../components/Brand.js | 0 .../{landing-2 => starter}/components/CTA.js | 2 +- .../components/Contact.js | 0 .../components/DarkModeButton.js | 4 +- .../{landing-2 => starter}/components/FAQ.js | 0 .../components/Features.js | 8 +- .../components/Footer.js | 40 +- .../{landing-2 => starter}/components/Hero.js | 66 ++-- .../{landing-2 => starter}/components/Logo.js | 0 .../components/MadeWithButton.js | 0 .../components/MenuList.js | 17 +- .../components/NavBar.js | 0 .../components/Pricing.js | 6 +- .../components/SVG404.js | 0 .../{landing-2 => starter}/components/Team.js | 368 +++++++++--------- .../components/Testimonials.js | 48 +++ themes/{landing-2 => starter}/config.js | 0 themes/{landing-2 => starter}/index.js | 32 +- themes/{landing-2 => starter}/style.js | 50 ++- themes/theme.js | 3 +- 24 files changed, 396 insertions(+), 316 deletions(-) rename themes/{landing-2 => starter}/components/About.js (93%) rename themes/{landing-2 => starter}/components/BackToTopButton.js (69%) rename themes/{landing-2 => starter}/components/Blog.js (97%) rename themes/{landing-2 => starter}/components/Brand.js (100%) rename themes/{landing-2 => starter}/components/CTA.js (98%) rename themes/{landing-2 => starter}/components/Contact.js (100%) rename themes/{landing-2 => starter}/components/DarkModeButton.js (98%) rename themes/{landing-2 => starter}/components/FAQ.js (100%) rename themes/{landing-2 => starter}/components/Features.js (98%) rename themes/{landing-2 => starter}/components/Footer.js (97%) rename themes/{landing-2 => starter}/components/Hero.js (95%) rename themes/{landing-2 => starter}/components/Logo.js (100%) rename themes/{landing-2 => starter}/components/MadeWithButton.js (100%) rename themes/{landing-2 => starter}/components/MenuList.js (87%) rename themes/{landing-2 => starter}/components/NavBar.js (100%) rename themes/{landing-2 => starter}/components/Pricing.js (98%) rename themes/{landing-2 => starter}/components/SVG404.js (100%) rename themes/{landing-2 => starter}/components/Team.js (87%) rename themes/{landing-2 => starter}/components/Testimonials.js (93%) rename themes/{landing-2 => starter}/config.js (100%) rename themes/{landing-2 => starter}/index.js (82%) rename themes/{landing-2 => starter}/style.js (73%) diff --git a/next.config.js b/next.config.js index 732303bf..6dbf5eac 100644 --- a/next.config.js +++ b/next.config.js @@ -16,16 +16,11 @@ function scanSubdirectories(directory) { const subdirectories = [] fs.readdirSync(directory).forEach(file => { - // 这段代码会将landing排除在可选主题中 - - // const fullPath = path.join(directory, file) - // const stats = fs.statSync(fullPath) - // landing主题默认隐藏掉,一般网站不会用到 - // if (stats.isDirectory() && file !== 'landing') { - // subdirectories.push(file) - // } - - subdirectories.push(file) + const fullPath = path.join(directory, file) + const stats = fs.statSync(fullPath) + if (stats.isDirectory()) { + subdirectories.push(file) + } }) return subdirectories diff --git a/themes/landing-2/components/About.js b/themes/starter/components/About.js similarity index 93% rename from themes/landing-2/components/About.js rename to themes/starter/components/About.js index 6ac66a83..8279ec06 100644 --- a/themes/landing-2/components/About.js +++ b/themes/starter/components/About.js @@ -31,7 +31,7 @@ export const About = () => {

Know More @@ -107,11 +107,11 @@ export const About = () => { y2="178.431" gradientUnits="userSpaceOnUse" > - + @@ -143,11 +143,11 @@ export const About = () => { y2="133.937" gradientUnits="userSpaceOnUse" > - + @@ -179,11 +179,11 @@ export const About = () => { y2="256.79" gradientUnits="userSpaceOnUse" > - + diff --git a/themes/landing-2/components/BackToTopButton.js b/themes/starter/components/BackToTopButton.js similarity index 69% rename from themes/landing-2/components/BackToTopButton.js rename to themes/starter/components/BackToTopButton.js index bcb404de..1f201684 100644 --- a/themes/landing-2/components/BackToTopButton.js +++ b/themes/starter/components/BackToTopButton.js @@ -31,16 +31,18 @@ export const BackToTopButton = () => { t--; return (-c / 2) * (t * (t - 2) - 1) + b; }; - - document.querySelector('.back-to-top').onclick = () => { - scrollTo(document.documentElement); - }; + const backToTop = document.querySelector('.back-to-top') + if (backToTop) { + backToTop.onclick = () => { + scrollTo(document.documentElement); + }; + } window.addEventListener('scroll', navBarScollListener) return () => { window.removeEventListener('scroll', navBarScollListener) } - }) + }, []) // 滚动监听 const throttleMs = 200 @@ -49,20 +51,17 @@ export const BackToTopButton = () => { const scrollY = window.scrollY; // 显示或隐藏返回顶部按钮 const backToTop = document.querySelector('.back-to-top'); - backToTop.style.display = scrollY > 50 ? 'flex' : 'none'; + if (backToTop) { + backToTop.style.display = scrollY > 50 ? 'flex' : 'none'; + } }, throttleMs) ) return <> {/* */} - + + + {/* */} } diff --git a/themes/landing-2/components/Blog.js b/themes/starter/components/Blog.js similarity index 97% rename from themes/landing-2/components/Blog.js rename to themes/starter/components/Blog.js index bf68e5d2..37249f0e 100644 --- a/themes/landing-2/components/Blog.js +++ b/themes/starter/components/Blog.js @@ -41,7 +41,7 @@ export const Blog = () => {

Meet AutoManage, the best AI management tools @@ -75,7 +75,7 @@ export const Blog = () => {

How to earn more money as a wellness coach @@ -109,7 +109,7 @@ export const Blog = () => {

The no-fuss guide to upselling and cross selling diff --git a/themes/landing-2/components/Brand.js b/themes/starter/components/Brand.js similarity index 100% rename from themes/landing-2/components/Brand.js rename to themes/starter/components/Brand.js diff --git a/themes/landing-2/components/CTA.js b/themes/starter/components/CTA.js similarity index 98% rename from themes/landing-2/components/CTA.js rename to themes/starter/components/CTA.js index ae1a195a..702fafb9 100644 --- a/themes/landing-2/components/CTA.js +++ b/themes/starter/components/CTA.js @@ -25,7 +25,7 @@ export const CTA = () => { majority have suffered in some form.

Start using Play diff --git a/themes/landing-2/components/Contact.js b/themes/starter/components/Contact.js similarity index 100% rename from themes/landing-2/components/Contact.js rename to themes/starter/components/Contact.js diff --git a/themes/landing-2/components/DarkModeButton.js b/themes/starter/components/DarkModeButton.js similarity index 98% rename from themes/landing-2/components/DarkModeButton.js rename to themes/starter/components/DarkModeButton.js index 0a89e7a0..9d4ceef1 100644 --- a/themes/landing-2/components/DarkModeButton.js +++ b/themes/starter/components/DarkModeButton.js @@ -6,7 +6,7 @@ export const DarkModeButton = () => { const router = useRouter() return <> Learn More @@ -85,7 +85,7 @@ export const Features = () => { Lorem Ipsum is simply dummy text of the printing and industry.

Learn More @@ -152,7 +152,7 @@ export const Features = () => { Lorem Ipsum is simply dummy text of the printing and industry.

Learn More @@ -199,7 +199,7 @@ export const Features = () => { Lorem Ipsum is simply dummy text of the printing and industry.

Learn More diff --git a/themes/landing-2/components/Footer.js b/themes/starter/components/Footer.js similarity index 97% rename from themes/landing-2/components/Footer.js rename to themes/starter/components/Footer.js index ba20e84a..2b26ff7e 100644 --- a/themes/landing-2/components/Footer.js +++ b/themes/starter/components/Footer.js @@ -10,7 +10,7 @@ export const Footer = () => {
{

{ { { {
Purchase Now @@ -117,7 +117,7 @@ export const Pricing = () => {
Purchase Now @@ -164,7 +164,7 @@ export const Pricing = () => { Purchase Now diff --git a/themes/landing-2/components/SVG404.js b/themes/starter/components/SVG404.js similarity index 100% rename from themes/landing-2/components/SVG404.js rename to themes/starter/components/SVG404.js diff --git a/themes/landing-2/components/Team.js b/themes/starter/components/Team.js similarity index 87% rename from themes/landing-2/components/Team.js rename to themes/starter/components/Team.js index 35412537..616be1df 100644 --- a/themes/landing-2/components/Team.js +++ b/themes/starter/components/Team.js @@ -49,212 +49,212 @@ export const Team = () => { xmlns="http://www.w3.org/2000/svg" > @@ -272,7 +272,7 @@ export const Team = () => {

{ { { xmlns="http://www.w3.org/2000/svg" > @@ -476,7 +476,7 @@ export const Team = () => {

{ { { xmlns="http://www.w3.org/2000/svg" > @@ -680,7 +680,7 @@ export const Team = () => {

{ { { xmlns="http://www.w3.org/2000/svg" > @@ -884,7 +884,7 @@ export const Team = () => {

{ { { + console.log('加载swiper') + await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.css', 'css'); + await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.js', 'js'); + + const Swiper = window.Swiper + if (!Swiper) { + return + } + // Testimonial + const testimonialSwiper = new Swiper('.testimonial-carousel', { + slidesPerView: 1, + spaceBetween: 30, + + // Navigation arrows + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev' + }, + + breakpoints: { + 640: { + slidesPerView: 2, + spaceBetween: 30 + }, + 1024: { + slidesPerView: 3, + spaceBetween: 30 + }, + 1280: { + slidesPerView: 3, + spaceBetween: 30 + } + } + }); + console.log('swiper', testimonialSwiper) +}; + export const Testimonials = () => { + useEffect(() => { + loadExternal() + }, []) return <> {/* */}
{ - await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.js', 'js'); - await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.css', 'css'); await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js', 'js'); // 配合animatecss 实现延时滚动动画,和AOS动画相似 const WOW = window.WOW; @@ -63,10 +61,8 @@ const LayoutBase = (props) => { loadExternal() }, []) - return <> - -
- + return
+ } diff --git a/themes/theme.js b/themes/theme.js index ddb30a77..e14a7a32 100644 --- a/themes/theme.js +++ b/themes/theme.js @@ -8,7 +8,6 @@ export const { THEMES = [] } = getConfig().publicRuntimeConfig /** * 加载全局布局 - * 如果是 * @param {*} themeQuery * @returns */ @@ -39,7 +38,7 @@ export const getLayoutByTheme = ({ router, theme }) => { setTimeout(() => { checkThemeDOM() }, 100); - return ThemeComponents[ThemeComponents.getLayoutNameByPath('-1')] + return ThemeComponents[ThemeComponents.getLayoutNameByPath(router.pathname)] } }