|
1 | | -import type { Data } from '@measured/puck' |
2 | | -import { sectionSpacingDefaults } from '../utils/section-spacing' |
| 1 | +import { c, deepCloneWithFreshIds, type PuckTemplate } from './_shared' |
| 2 | +import { languageSchoolTemplates } from './language-school' |
| 3 | +import { fitnessStudioTemplates } from './fitness-studio' |
| 4 | +import { musicAcademyTemplates } from './music-academy' |
| 5 | +import { businessCoachingTemplates } from './business-coaching' |
| 6 | +import { designSchoolTemplates } from './design-school' |
3 | 7 |
|
4 | | -export interface PuckTemplate { |
5 | | - name: string |
6 | | - description: string |
7 | | - category: string |
8 | | - puck_data: Data |
9 | | - sort_order: number |
10 | | - pageType: string |
11 | | -} |
12 | | - |
13 | | -// Counter to generate unique-per-template IDs at module level. |
14 | | -// Fresh IDs are generated when templates are applied via deepCloneWithFreshIds(). |
15 | | -// LMS component types that use section spacing |
16 | | -const SPACED_COMPONENTS = new Set([ |
17 | | - 'FeaturesGrid', 'CourseGrid', 'TestimonialGrid', 'CtaBlock', |
18 | | - 'PricingTable', 'FaqAccordion', 'StatsCounter', 'ContactForm', |
19 | | - 'LogoCloud', 'Banner', 'TeamGrid', 'ImageGallery', 'SocialProof', |
20 | | -]) |
21 | | - |
22 | | -let idCounter = 0 |
23 | | -function c(type: string, props: Record<string, unknown>, id?: string) { |
24 | | - const spacing = SPACED_COMPONENTS.has(type) ? sectionSpacingDefaults : {} |
25 | | - return { type, props: { id: id || `${type}-tpl-${++idCounter}`, ...spacing, ...props } } |
26 | | -} |
27 | | - |
28 | | -/** Deep-clone a template's puck_data and assign fresh random IDs to all components */ |
29 | | -export function deepCloneWithFreshIds(data: Data): Data { |
30 | | - const cloned = JSON.parse(JSON.stringify(data)) as Data |
31 | | - for (const item of cloned.content) { |
32 | | - if (item.props?.id) { |
33 | | - item.props.id = `${item.type}-${Math.random().toString(36).slice(2, 10)}` |
34 | | - } |
35 | | - } |
36 | | - for (const zoneItems of Object.values(cloned.zones || {})) { |
37 | | - for (const item of zoneItems as Array<{ type: string; props: Record<string, unknown> }>) { |
38 | | - if (item.props?.id) { |
39 | | - item.props.id = `${item.type}-${Math.random().toString(36).slice(2, 10)}` |
40 | | - } |
41 | | - } |
42 | | - } |
43 | | - return cloned |
44 | | -} |
| 8 | +// Re-export shared helpers so existing importers (`@/lib/puck/templates`) |
| 9 | +// keep working unchanged. |
| 10 | +export { deepCloneWithFreshIds } |
| 11 | +export type { PuckTemplate } |
45 | 12 |
|
46 | 13 | // ─── Blank Template ────────────────────────────────────────────────────────── |
47 | 14 |
|
@@ -1136,4 +1103,10 @@ export const PUCK_TEMPLATES: PuckTemplate[] = [ |
1136 | 1103 | codeSchoolFaqTemplate, |
1137 | 1104 | codeSchoolContactTemplate, |
1138 | 1105 | codeSchoolCatalogTemplate, |
| 1106 | + // Vertical packs (Home / About / FAQ / Contact each) |
| 1107 | + ...languageSchoolTemplates, |
| 1108 | + ...fitnessStudioTemplates, |
| 1109 | + ...musicAcademyTemplates, |
| 1110 | + ...businessCoachingTemplates, |
| 1111 | + ...designSchoolTemplates, |
1139 | 1112 | ] |
0 commit comments