DefaultHomeComponents
The engine's 13 built-in home blocks, keyed by block path, ready to spread into registerHomeComponents.
import { DefaultHomeComponents } from '@salla.sa/twilight-theme-engine/components/home';In plain words
A ready-made table of the standard Salla home blocks and the engine component that draws each one. You spread it into registerHomeComponents({ ...DefaultHomeComponents }) and add or replace entries after it.
To replace one block with your own, put your component under the same key after the spread.
Signature
const DefaultHomeComponents: Record<string, AnyHomeComponent | null> = {
'fixed-banner': FixedBanner,
'photos-slider': PhotosSlider,
testimonial: Testimonials,
'store-features': StoreFeatures,
youtube: Youtube,
'square-photos': SquarePhotos,
'fixed-products': FixedProducts,
'products-slider': ProductsSlider,
'parallax-background': ParallaxBackground,
'featured-products:style1': FeaturedProductsStyle1,
'featured-products:style2': FeaturedProductsStyle2,
'featured-products:style3': FeaturedProductsStyle3,
'bundle-component': BundleComponent,
};Try it live
| key | registered as home:key | blocks on this store |
|---|---|---|
fixed-banner | true | |
photos-slider | true | |
testimonial | true | |
store-features | true | |
youtube | true | |
square-photos | true | |
fixed-products | true | |
products-slider | true | |
parallax-background | true | |
featured-products:style1 | true | |
featured-products:style2 | true | |
featured-products:style3 | true | |
bundle-component | true |
Blocks with no default:
import {
DefaultHomeComponents,
registerHomeComponents,
} from '@salla.sa/twilight-theme-engine/components/home';
import { Brands } from './components/home/Brands';
registerHomeComponents({
...DefaultHomeComponents, // keep the defaults
brands: Brands, // add a block the defaults do not cover
});
Example
import {
DefaultHomeComponents,
registerHomeComponents,
} from '@salla.sa/twilight-theme-engine/components/home';
import { MyTestimonials } from './components/home/MyTestimonials';
registerHomeComponents({
...DefaultHomeComponents,
testimonial: MyTestimonials, // replaces the default reviews block
});
How it behaves
Only
testimonial(Testimonials) is aReact.lazycomponent; the other twelve are ordinary components, even though the engine source imports them underLazy*names.Featured products exist only as variants (
featured-products:style1tostyle3), matched against the block'sview_style.
Gotchas
The reviews key is
testimonial, singular. packages/theme-engine/docs/HOME_COMPONENTS.md writes the path astestimonials; a replacement registered under that name is never used.A
featured-productsblock whoseview_styleis not exactlystyle1,style2orstyle3matches no default. The demo store sendsview_style: "products_without_special_product"(items withfeatured_productandproducts, the shapeFeaturedProductsStyle3reads), so that block draws nothing on the engine's home page. Register a component underfeatured-products:<that view_style>to show it.store-featuresneeds no wrapper on the demo store: the API sendsfeatureswithicon,titleanddescription, which is what the component reads. A block missing that array throws instead — see StoreFeatures.
Related
Tells the engine which component draws each home page block, by the block path the Salla API sends. Call it once at startup.
HomeComponentRendererDraws one home page block from its API data: finds its registered component, wraps it in an error boundary, and defers it until visible.