Files
ipal-kit/src/modules/block-library/templates/pages.ts
T
Radosław SmolińskiandClaude Opus 5.5 2d1cc0e77d Block library: 15 blocks, registry, primitives, templates, manifest, eject
- @intecion/ipal-kit/blocks: libraryBlocks() opt-in, one builder per block, field
  builders, option merging, blockLibraryManifest, faqItemsFromLayout
- @intecion/ipal-kit/blocks/rsc: createBlockRegistry, the block components and UI
  primitives (token utilities only; next/image and next/link passed in)
- @intecion/ipal-kit/templates: 10 page templates as createSeeder data
- createSeeder: { $form: title } references
- ipal-blocks eject <block>
- tests: options, rendering and a11y per block, Payload + seeding, GraphQL, admin
  wording, schema snapshot (versioning), eject imports
- shorter admin labels: link "New tab", table of contents "Show contents"

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 14:05:47 +01:00

129 lines
10 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { TemplateOptions, TemplatePage } from './build.js'
import { buildTemplate, fill, header, pageRef, richText, sections, TEMPLATE_SLUGS, tx } from './build.js'
const button = (label: Record<string, string>, page: { $page: string }, appearance = 'primary') => ({
link: { type: 'internal', appearance, label, page },
})
const pageHero = (heading: Record<string, string>, intro?: Record<string, string>) => ({ blockType: 'hero' as const, header: header(heading, intro), variant: 'page' })
const cta = (options?: TemplateOptions) => ({
blockType: 'cta' as const,
header: header(tx('Ready to talk about your project?', 'Porozmawiajmy o Twoim projekcie'), fill('one sentence why to get in touch', 'jedno zdanie, dlaczego warto się skontaktować')),
links: [button(tx('Contact us', 'Skontaktuj się'), pageRef('contact', options))],
variant: 'band',
})
const items = (n: number, make: (i: number) => Record<string, unknown>) => Array.from({ length: n }, (_, i) => make(i + 1))
/** Home: hero, logos, features, text and image, key figures, testimonials, FAQ, call to action. */
export function home(options?: TemplateOptions): TemplatePage {
return buildTemplate('home', { slug: TEMPLATE_SLUGS.home, title: tx('Home', 'Strona główna') }, [
{ blockType: 'hero', header: header(fill('main promise of the company', 'główna obietnica firmy'), fill('one or two sentences for whom and what', 'jedno–dwa zdania: dla kogo i co')), links: [button(tx('Contact us', 'Skontaktuj się'), pageRef('contact', options))], variant: 'split' },
{ blockType: 'logos', header: header(tx('They trust us', 'Zaufali nam')), variant: 'row' },
{ blockType: 'featureGrid', columns: 'three', header: header(tx('What we do', 'Czym się zajmujemy')), items: items(3, (i) => ({ heading: fill(`service ${i}`, `usługa ${i}`), text: fill('one sentence about it', 'jedno zdanie o niej') })), variant: 'cards' },
{ blockType: 'textMedia', content: richText(fill('who we are and how we work', 'kim jesteśmy i jak pracujemy')), header: header(tx('About us', 'O nas')), links: [button(tx('More about us', 'Więcej o nas'), pageRef('about', options), 'secondary')], variant: 'mediaRight' },
{ blockType: 'stats', items: items(3, (i) => ({ heading: fill(`figure ${i} label`, `opis liczby ${i}`), value: fill('number', 'liczba') })), variant: 'row' },
{ blockType: 'testimonials', header: header(tx('What our clients say', 'Co mówią klienci')), items: items(3, () => ({ heading: fill('client name', 'imię klienta'), quote: fill('real quote from a client', 'prawdziwy cytat od klienta') })), variant: 'grid' },
{ blockType: 'faq', header: header(tx('Frequently asked questions', 'Najczęstsze pytania')), items: items(4, (i) => ({ answer: fill(`answer ${i}`, `odpowiedź ${i}`), question: fill(`question ${i}`, `pytanie ${i}`) })), variant: 'single' },
cta(options),
], options)
}
/** About: page header, story, key figures, team, how we work, call to action. */
export function about(options?: TemplateOptions): TemplatePage {
return buildTemplate('about', { slug: TEMPLATE_SLUGS.about, title: tx('About us', 'O nas') }, [
pageHero(tx('About us', 'O nas'), fill('one sentence about the company', 'jedno zdanie o firmie')),
{ blockType: 'textMedia', content: richText(fill('the company story', 'historia firmy')), header: header(tx('Our story', 'Nasza historia')), variant: 'mediaLeft' },
{ blockType: 'stats', items: items(3, (i) => ({ heading: fill(`figure ${i} label`, `opis liczby ${i}`), value: fill('number', 'liczba') })), variant: 'cards' },
{ blockType: 'team', header: header(tx('Our team', 'Nasz zespół')), items: items(3, () => ({ heading: fill('name', 'imię i nazwisko'), text: fill('role', 'stanowisko') })), variant: 'grid' },
{ blockType: 'steps', header: header(tx('How we work', 'Jak pracujemy')), items: items(4, (i) => ({ heading: fill(`step ${i}`, `krok ${i}`), text: fill('what happens in it', 'co się w nim dzieje') })), variant: 'numbered' },
cta(options),
], options)
}
/** Services: page header, service cards, process, pricing, FAQ, call to action. */
export function services(options?: TemplateOptions): TemplatePage {
return buildTemplate('services', { slug: tx('services', 'uslugi'), title: tx('Services', 'Usługi') }, [
pageHero(tx('Services', 'Usługi'), fill('one sentence about the offer', 'jedno zdanie o ofercie')),
{ blockType: 'featureGrid', columns: 'three', items: items(6, (i) => ({ heading: fill(`service ${i}`, `usługa ${i}`), text: fill('one sentence about it', 'jedno zdanie o niej') })), variant: 'cards' },
{ blockType: 'steps', header: header(tx('How it works', 'Jak to działa')), items: items(3, (i) => ({ heading: fill(`step ${i}`, `krok ${i}`) })), variant: 'numbered' },
{ blockType: 'pricing', header: header(tx('Pricing', 'Cennik')), items: items(3, (i) => ({ heading: fill(`plan ${i}`, `pakiet ${i}`), price: fill('price', 'cena') })) },
{ blockType: 'faq', header: header(tx('Questions about our services', 'Pytania o usługi')), items: items(3, (i) => ({ answer: fill(`answer ${i}`, `odpowiedź ${i}`), question: fill(`question ${i}`, `pytanie ${i}`) })), variant: 'single' },
cta(options),
], options)
}
/** One service: hero, description, benefits, gallery, FAQ, contact. Pass `slug` and `title`. */
export function service(options?: { form?: unknown } & TemplateOptions): TemplatePage {
return buildTemplate('service', { slug: tx('service', 'usluga'), title: fill('service name', 'nazwa usługi') }, [
{ blockType: 'hero', header: header(fill('service name', 'nazwa usługi'), fill('what the client gets', 'co dostaje klient')), links: [button(tx('Ask for a quote', 'Zapytaj o wycenę'), pageRef('contact', options))], variant: 'split' },
{ blockType: 'textMedia', content: richText(fill('description of the service', 'opis usługi')), variant: 'mediaRight' },
{ blockType: 'featureGrid', columns: 'two', header: header(tx('What you get', 'Co zyskujesz')), items: items(4, (i) => ({ heading: fill(`benefit ${i}`, `korzyść ${i}`) })), variant: 'list' },
{ blockType: 'gallery', columns: 'three', header: header(tx('Our work', 'Nasze realizacje')), variant: 'grid' },
{ blockType: 'faq', items: items(3, (i) => ({ answer: fill(`answer ${i}`, `odpowiedź ${i}`), question: fill(`question ${i}`, `pytanie ${i}`) })), variant: 'single' },
...(options?.form ? [{ blockType: 'contact' as const, form: options.form, header: header(tx('Ask about this service', 'Zapytaj o tę usługę')), variant: 'formOnly' }] : []),
], options)
}
/** Contact: page header, the form with contact details, FAQ. `form`: `{ $form: 'Contact form' }`. */
export function contact(options: { form: unknown } & TemplateOptions): TemplatePage {
return buildTemplate('contact', { slug: TEMPLATE_SLUGS.contact, title: tx('Contact', 'Kontakt') }, [
pageHero(tx('Contact', 'Kontakt'), fill('how fast you answer', 'jak szybko odpowiadacie')),
{ blockType: 'contact', content: richText(fill('who to contact and when', 'z kim i kiedy się kontaktować')), form: options.form, variant: 'formWithDetails' },
{ blockType: 'faq', header: header(tx('Before you write', 'Zanim napiszesz')), items: items(3, (i) => ({ answer: fill(`answer ${i}`, `odpowiedź ${i}`), question: fill(`question ${i}`, `pytanie ${i}`) })), variant: 'single' },
], options)
}
/** Blog index: the archive page (its entries come from createPageRoute) with a header and a call to action. */
export function blogIndex(options?: TemplateOptions): TemplatePage {
return buildTemplate('blogIndex', { slug: tx('blog', 'blog'), title: tx('Blog', 'Blog') }, [pageHero(tx('Blog', 'Blog'), fill('what the posts are about', 'o czym są wpisy')), cta(options)], options)
}
/** Post body for a posts collection with a `layout` field: text with a table of contents, more posts, call to action. */
export function post(options?: TemplateOptions): TemplatePage {
return buildTemplate('post', { slug: fill('post-address', 'adres-wpisu'), title: fill('post title', 'tytuł wpisu') }, [
{ blockType: 'richText', content: richText(fill('post text', 'treść wpisu')), tableOfContents: { label: tx('Contents', 'Spis treści'), show: true }, variant: 'narrow' },
{ blockType: 'entryList', collection: 'posts', header: header(tx('Read also', 'Przeczytaj też')), limit: 3, mode: 'latest', variant: 'cards' },
cta(options),
], options)
}
const LEGAL = {
privacyPolicy: { slug: tx('privacy-policy', 'polityka-prywatnosci'), title: tx('Privacy policy', 'Polityka prywatności') },
termsOfService: { slug: tx('terms', 'regulamin'), title: tx('Terms of service', 'Regulamin') },
}
/** A legal page (privacy policy, terms): header and text with a table of contents. Structure only — the wording comes from the client. */
export function legal(role: keyof typeof LEGAL, options?: TemplateOptions): TemplatePage {
const { slug, title } = LEGAL[role]
return buildTemplate(role, { slug, title }, [
pageHero(title),
{
blockType: 'richText',
content: sections({
en: [['[TO FILL: section heading]', '[TO FILL: text provided by the client or their lawyer]']],
pl: [['[TO FILL: nagłówek sekcji]', '[TO FILL: treść od klienta lub prawnika]']],
}),
tableOfContents: { label: tx('Contents', 'Spis treści'), show: true },
variant: 'narrow',
},
], options)
}
/** Cookie policy: header and text; put the cookie table (CookieTable) on it in your page view or own block. */
export function cookiePolicy(options?: TemplateOptions): TemplatePage {
return buildTemplate('cookiePolicy', { slug: tx('cookie-policy', 'polityka-cookies'), title: tx('Cookie policy', 'Polityka cookies') }, [
pageHero(tx('Cookie policy', 'Polityka cookies')),
{ blockType: 'richText', content: richText(fill('cookie policy text from the client', 'treść polityki cookies od klienta')), tableOfContents: { show: false }, variant: 'narrow' },
], options)
}
/** 404: a small header with a button home. */
export function notFound(options?: TemplateOptions): TemplatePage {
return buildTemplate('notFound', { slug: tx('page-not-found', 'nie-znaleziono'), title: tx('Page not found', 'Nie znaleziono strony') }, [
{ blockType: 'hero', header: header(tx('Page not found', 'Nie znaleziono strony'), tx('The address may be mistyped or the page was moved.', 'Adres może być błędny albo strona została przeniesiona.')), links: [button(tx('Go to the home page', 'Przejdź na stronę główną'), pageRef('home', options))], variant: 'page' },
], options)
}