refactor: add and use isValidCatalogLayout type guard for robust layout assignment
This commit is contained in:
1 parent
683fee3bd9
commit
669e20a35c
2 files changed
+13
-2
No files matched your search
@@ -23,6 +23,11 @@ export const CATALOG_LAYOUTS = [
|
||||
|
||||
export type CatalogLayout = (typeof CATALOG_LAYOUTS)[number];
|
||||
|
||||
/** Type guard to check if a string is a valid CatalogLayout. */
|
||||
export function isValidCatalogLayout(layout: string): layout is CatalogLayout {
|
||||
return (CATALOG_LAYOUTS as readonly string[]).includes(layout);
|
||||
}
|
||||
|
||||
/** Short human-readable description for each layout. Shown in the layout selector. */
|
||||
export const LAYOUT_DESCRIPTIONS: Record<CatalogLayout, string> = {
|
||||
default_3x3: "Standard 3-column grid of items",
|
||||
|
||||
Reference in new issue
Block a user