118 lines
4.1 KiB
TypeScript
118 lines
4.1 KiB
TypeScript
import {useLoaderData} from 'react-router';
|
|
import type {Route} from '~/lib/reactRouterRouteStubs';
|
|
import {MockShopNotice} from '~/components/MockShopNotice';
|
|
import {AbiirHomeHero} from '~/components/AbiirHomeHero';
|
|
import {BrandValues} from '~/components/BrandValues';
|
|
import {FeaturedProducts, FEATURED_PRODUCTS_GROQ} from '~/components/FeaturedProducts';
|
|
import {Ingredients, INGREDIENTS_SECTION_GROQ} from '~/components/Ingredients';
|
|
import {SkinRitual, SKIN_RITUAL_SECTION_GROQ} from '~/components/SkinRitual';
|
|
import {SpringGlowBanner} from '~/components/SpringGlowBanner';
|
|
import {Testimonials, TESTIMONIALS_SECTION_GROQ} from '~/components/Testimonials';
|
|
import {LifestyleGrid, LIFESTYLE_GRID_SECTION_GROQ} from '~/components/LifestyleGrid';
|
|
import {Newsletter, NEWSLETTER_SECTION_GROQ} from '~/components/Newsletter';
|
|
import {loadBrandValuesFromSanity} from '~/lib/brandValues';
|
|
import {loadFeaturedProductsSection} from '~/lib/featuredProducts.server';
|
|
import {loadIngredientsFromSanity} from '~/lib/ingredients';
|
|
import {loadSkinRitualFromSanity} from '~/lib/skinRitual';
|
|
import {loadTestimonialsFromSanity} from '~/lib/testimonials';
|
|
import {loadLifestyleGridFromSanity} from '~/lib/lifestyleGrid';
|
|
import {
|
|
fetchInstagramLifestyleTiles,
|
|
mergeLifestyleGridWithInstagram,
|
|
} from '~/lib/instagramFeed';
|
|
import {loadHomeHeroFromSanity} from '~/lib/homeHero';
|
|
import {loadSpringGlowBannerFromSanity} from '~/lib/springGlowBanner';
|
|
import {loadNewsletterFromSanity} from '~/lib/newsletter';
|
|
|
|
export async function loader(args: Route.LoaderArgs) {
|
|
return loadCriticalData(args);
|
|
}
|
|
|
|
async function loadCriticalData({context}: Route.LoaderArgs) {
|
|
const {sanity, storefront} = context;
|
|
const [
|
|
homeHeroBundle,
|
|
springGlowBundle,
|
|
brandValuesBundle,
|
|
featuredBundle,
|
|
ingredientsBundle,
|
|
skinRitualBundle,
|
|
testimonialsBundle,
|
|
lifestyleGridBundle,
|
|
instagramTiles,
|
|
newsletterBundle,
|
|
] = await Promise.all([
|
|
loadHomeHeroFromSanity({sanity}),
|
|
loadSpringGlowBannerFromSanity({sanity, storefront}),
|
|
loadBrandValuesFromSanity({sanity}),
|
|
loadFeaturedProductsSection({
|
|
sanity,
|
|
storefront,
|
|
groq: FEATURED_PRODUCTS_GROQ,
|
|
}),
|
|
loadIngredientsFromSanity({
|
|
sanity,
|
|
groq: INGREDIENTS_SECTION_GROQ,
|
|
}),
|
|
loadSkinRitualFromSanity({
|
|
sanity,
|
|
groq: SKIN_RITUAL_SECTION_GROQ,
|
|
}),
|
|
loadTestimonialsFromSanity({
|
|
sanity,
|
|
groq: TESTIMONIALS_SECTION_GROQ,
|
|
}),
|
|
loadLifestyleGridFromSanity({
|
|
sanity,
|
|
groq: LIFESTYLE_GRID_SECTION_GROQ,
|
|
}),
|
|
fetchInstagramLifestyleTiles(context.env),
|
|
loadNewsletterFromSanity({
|
|
sanity,
|
|
groq: NEWSLETTER_SECTION_GROQ,
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
isShopLinked: Boolean(context.env.PUBLIC_STORE_DOMAIN),
|
|
homeHeroCms: homeHeroBundle.homeHeroCms,
|
|
springGlowCms: springGlowBundle.springGlowCms,
|
|
springGlowVariantId: springGlowBundle.bundleVariantId,
|
|
brandValuesCms: brandValuesBundle.brandValuesCms,
|
|
featuredProductsCms: featuredBundle.cms,
|
|
featuredProductRows: featuredBundle.rows,
|
|
ingredientsCms: ingredientsBundle.ingredientsCms,
|
|
skinRitualCms: skinRitualBundle.skinRitualCms,
|
|
testimonialsCms: testimonialsBundle.testimonialsCms,
|
|
lifestyleGridCms: mergeLifestyleGridWithInstagram(
|
|
lifestyleGridBundle.lifestyleGridCms,
|
|
instagramTiles,
|
|
),
|
|
newsletterCms: newsletterBundle.newsletterCms,
|
|
};
|
|
}
|
|
|
|
export default function Homepage() {
|
|
const data = useLoaderData<typeof loader>();
|
|
return (
|
|
<div className="home">
|
|
{data.isShopLinked ? null : <MockShopNotice />}
|
|
<AbiirHomeHero cms={data.homeHeroCms} />
|
|
<SpringGlowBanner
|
|
bundleVariantId={data.springGlowVariantId}
|
|
cms={data.springGlowCms}
|
|
/>
|
|
<BrandValues cms={data.brandValuesCms} />
|
|
<FeaturedProducts
|
|
cms={data.featuredProductsCms}
|
|
rows={data.featuredProductRows}
|
|
/>
|
|
<Ingredients cms={data.ingredientsCms} />
|
|
<SkinRitual cms={data.skinRitualCms} />
|
|
<Testimonials cms={data.testimonialsCms} />
|
|
<LifestyleGrid cms={data.lifestyleGridCms} />
|
|
<Newsletter cms={data.newsletterCms} />
|
|
</div>
|
|
);
|
|
}
|