Docs for 1.9.2: import instead of code; docs↔code consistency test; audit accepts one-line routes
- AGENT.md: §7 full capability catalog (need → import), §0b/§3/§6 on RenderForm, SiteProviders, createPageRoute, re-exported routes, plugin section fields, resolveLink/resolveNav - PROGRAMISTA §2.4, §2.7–2.8 rewritten; §6 items 28–33 (28: FormRenderer leaked the Emails tab) - forms, links, blocks, pages, consent, turnstile, notifications, seo, mcp, i18n, deployment docs - ipal-form: RenderForm block, formClasses, CustomForm example (FormRenderer template removed), seed template handles steps and option labels per language - ipal-nav, ipal-block, ipal-setup, ipal-upgrade, ipal-seo-check, ipal-consent-check, vibe.md - ipal-audit: re-export routes and SiteProviders satisfy the mandatory set; flags form-engine copies, project section fields / navigation, server entries in client components - test/docsConsistency: docs imports exist in code; every public export is documented - CHANGELOG 1.9.2 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+76
-99
@@ -150,10 +150,11 @@ sprawdzić: **AGENT.md §0b**. Kod wszystkich tras niżej (§2.7–2.9).
|
||||
- `Media`: upload z `mimeTypes` (obrazy + PDF), `alt` (required, localized),
|
||||
`normalizeFilenameHook`, `buildOptimizeUploadHook` + `buildOptimizeUploadField` (za duże pliki, za zgodą); R2 przez `buildR2Storage(['media'], { s3Storage })` —
|
||||
`s3Storage` z `@payloadcms/storage-s3`, wstrzykiwany (storage.md).
|
||||
- Linki z pluginu (`buildLinkField`, `buildLinksField`, `resolveLinkHref` — links.md),
|
||||
`src/fields/` (sectionHeader, sectionSettings) i `src/components/ui/`
|
||||
(CMSLink, Button, Media, Section, SectionHeader) — gotowy kod w
|
||||
`agent/skills/ipal-block/resources/kod-sekcji.md`, reguły w AGENT.md §6.
|
||||
- Pola z pluginu: linki (`buildLinkField`, `buildLinksField` — links.md), nagłówek i ustawienia
|
||||
sekcji (`buildSectionHeaderField`, `buildSectionSettingsField` — blocks.md). W projekcie tylko
|
||||
prymitywy wyglądu `src/components/ui/` (CMSLink na `resolveLink`, Button, Media, Section,
|
||||
SectionHeader) i `src/components/forms/formClasses.ts` — gotowy kod w
|
||||
`agent/skills/ipal-block/resources/kod-sekcji.md` i `ipal-form/resources/`, reguły w AGENT.md §6.
|
||||
Załóż je **przed** pierwszym blokiem.
|
||||
|
||||
### 2.5 Tailwind
|
||||
@@ -207,36 +208,44 @@ layoutach i `not-found.tsx` **nie czytaj `headers()`** (AGENT.md §4.6).
|
||||
|
||||
### 2.7 Warstwa danych — jedno źródło
|
||||
```ts
|
||||
// src/lib/content.ts
|
||||
// src/lib/content.ts — JEDYNE miejsce konfiguracji: dane, trasy, linki, layout
|
||||
import { createContentHelpers } from '@intecion/ipal-kit'
|
||||
import config from '@/payload.config'
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
import { contentConfig } from '@/content.config'
|
||||
|
||||
export const {
|
||||
getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries, getPageJsonLd,
|
||||
generatePageMetadata, getNotFoundPage, generateStaticParams, sitemap, robots,
|
||||
// dane
|
||||
getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries, getNotFoundPage,
|
||||
generatePageMetadata, generateStaticParams, getPageJsonLd, resolvePageRedirect, i18n,
|
||||
// layout, formularze, linki
|
||||
getSiteShell, getFormTexts, getLinkOptions, getHomeSlug, resolveLink, resolveNav,
|
||||
// trasy (re-eksport w app/)
|
||||
sitemap, sitemapRoute, robots, manifest, llmsRoute, llmsFullRoute, markdownRoute,
|
||||
mcpGET, mcpPOST, healthRoute, indexNowKeyRoute,
|
||||
} = createContentHelpers({
|
||||
config,
|
||||
content: contentConfig,
|
||||
i18n: i18nConfig,
|
||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||
markdownAlternate: true, // GEO: <link rel="alternate" type="text/markdown"> w każdej stronie
|
||||
markdownAlternate: true, // GEO: <link rel="alternate" type="text/markdown"> w każdej stronie
|
||||
summaryField: 'aiSummary', // llms.txt i MCP biorą opis dla AI z buildSummaryField
|
||||
mcp: { serverName: '<klient>-site' },
|
||||
// pageJsonLd: { faq: (doc) => …mapowanie bloku FAQ na { question, answer }… },
|
||||
// siteJsonLd: async ({ settings, baseUrl, locale }) => [buildLocalBusinessJsonLd({…})], // firma lokalna
|
||||
})
|
||||
```
|
||||
Wszystko liczy się dopiero przy pierwszym użyciu i jest w cache na żądanie. Każdą
|
||||
funkcję można pominąć i złożyć stronę z niższych klocków (`createPageMetadata`,
|
||||
`createLlmsTxtRoute`, `createMcpRoute`… — seo.md, mcp.md) — plugin niczego nie wymusza.
|
||||
|
||||
### 2.8 Trasy
|
||||
```tsx
|
||||
// src/app/(frontend)/[locale]/layout.tsx
|
||||
import { notFound } from 'next/navigation'
|
||||
import {
|
||||
buildOrganizationJsonLd, buildWebSiteJsonLd, getAnalyticsConfig, getConsentTexts, getTurnstileConfig, sameAsUrls,
|
||||
} from '@intecion/ipal-kit'
|
||||
import { Analytics, ConsentProvider, CookieBanner, CookieButton, TurnstileProvider } from '@intecion/ipal-kit/client'
|
||||
import { JsonLdGraph, MediaPreconnect } from '@intecion/ipal-kit/rsc'
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
import { getCachedPayload, getConfiguredLocales, getSettings } from '@/lib/content'
|
||||
import { CookieBanner } from '@intecion/ipal-kit/client'
|
||||
import { SiteProviders } from '@intecion/ipal-kit/rsc'
|
||||
import { getConfiguredLocales, getSiteShell } from '@/lib/content'
|
||||
import '../styles.css'
|
||||
|
||||
type Props = { children: React.ReactNode; params: Promise<{ locale: string }> }
|
||||
@@ -244,88 +253,64 @@ type Props = { children: React.ReactNode; params: Promise<{ locale: string }> }
|
||||
export default async function LocaleLayout({ children, params }: Props) {
|
||||
const { locale } = await params
|
||||
if (!(await getConfiguredLocales()).includes(locale)) notFound()
|
||||
|
||||
const payload = await getCachedPayload()
|
||||
const [texts, analytics, turnstile, settings] = await Promise.all([
|
||||
getConsentTexts({ config: i18nConfig, locale, payload }), // link do polityki — automatycznie (consent.md)
|
||||
getAnalyticsConfig(payload),
|
||||
getTurnstileConfig(payload), // siteKey tylko przy obu kluczach — inaczej widget i weryfikacja wyłączone
|
||||
getSettings(locale),
|
||||
])
|
||||
const url = process.env.NEXT_PUBLIC_SERVER_URL
|
||||
const name = typeof settings?.siteName === 'string' ? settings.siteName : undefined
|
||||
// Dane z panelu; brak → węzeł pominięty (nigdy fallback z nazwą klienta). Firma lokalna: buildLocalBusinessJsonLd z globalu Company.
|
||||
const schemas = name && url
|
||||
? [buildWebSiteJsonLd({ name, url }), buildOrganizationJsonLd({ name, url, logo: settings.logo, sameAs: sameAsUrls(settings) })]
|
||||
: []
|
||||
// + buildNavigationJsonLd({ items: header.navItems, … }) z globala nagłówka (seo.md)
|
||||
|
||||
const shell = await getSiteShell(locale) // zgoda, analityka, Turnstile, JSON-LD strony, Site Settings
|
||||
return (
|
||||
<html lang={locale}>
|
||||
{/* BEZ <head> — Next zarządza nim sam */}
|
||||
<body>
|
||||
<MediaPreconnect />
|
||||
<JsonLdGraph schemas={schemas} />
|
||||
<ConsentProvider texts={texts} logEndpoint="/api/ipal/consent">
|
||||
<TurnstileProvider siteKey={turnstile.siteKey}> {/* zawsze — sam się wyłącza bez kluczy */}
|
||||
<main>{children}</main>
|
||||
</TurnstileProvider>
|
||||
<CookieBanner equalChoice />
|
||||
<CookieButton />
|
||||
<Analytics {...analytics} /> {/* wewnątrz providera; opcja defer — analytics.md */}
|
||||
</ConsentProvider>
|
||||
<SiteProviders shell={shell} logEndpoint="/api/ipal/consent" banner={<CookieBanner equalChoice />}>
|
||||
{/* <Header …/> */}
|
||||
<main>{children}</main>
|
||||
{/* <Footer …/> */}
|
||||
</SiteProviders>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
```
|
||||
`SiteProviders` wpina w dobrej kolejności: `MediaPreconnect`, `JsonLdGraph` (WebSite + Organization
|
||||
z Site Settings), `ConsentProvider` → `TurnstileProvider` (zawsze — sam się wyłącza bez kluczy) →
|
||||
baner, `CookieButton`, `Analytics` (wewnątrz zgody). Nie dodaje żadnego markupu. Każdą część
|
||||
zmienisz albo wyłączysz: `banner={<CookieBanner classNames={…} />}` / `false`, `cookieButton`,
|
||||
`analytics={{ defer: true }}` / `false`, `jsonLd={[buildNavigationJsonLd(…)]}`, `cookieMap`,
|
||||
`preconnect={false}`. Zupełnie własny układ: te same dane z `shell` do providerów (consent.md).
|
||||
|
||||
```tsx
|
||||
// src/app/(frontend)/[locale]/[[...slug]]/page.tsx — PODWÓJNE nawiasy
|
||||
import { notFound, permanentRedirect } from 'next/navigation'
|
||||
import type { Metadata } from 'next'
|
||||
import { JsonLdGraph, RenderBlocks } from '@intecion/ipal-kit/rsc'
|
||||
import { resolveRedirect } from '@intecion/ipal-kit'
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
import { createPageRoute } from '@intecion/ipal-kit/rsc'
|
||||
import * as content from '@/lib/content'
|
||||
import { blockRegistry } from '@/blocks/registry'
|
||||
import { generatePageMetadata, getCachedPayload, getPageJsonLd, resolveRoute } from '@/lib/content'
|
||||
import { sendForm } from '../actions'
|
||||
|
||||
export { generateStaticParams } from '@/lib/content' // SSG → <head> synchroniczny
|
||||
export const revalidate = 3600 // ISR
|
||||
export const revalidate = 3600 // ISR — literał w pliku (Next czyta go statycznie)
|
||||
|
||||
type Args = { params: Promise<{ locale: string; slug?: string[] }> } // bez searchParams!
|
||||
|
||||
// Ten sam cache co strona: jedno odczytanie ustawień i jedno resolveRoute na żądanie
|
||||
export async function generateMetadata({ params }: Args): Promise<Metadata> {
|
||||
const { locale, slug } = await params
|
||||
return generatePageMetadata(locale, slug)
|
||||
}
|
||||
|
||||
export default async function Page({ params }: Args) {
|
||||
const { locale, slug } = await params
|
||||
const route = await resolveRoute(locale, slug ?? [], 1)
|
||||
if (!route) {
|
||||
const target = await resolveRedirect({ payload: await getCachedPayload(), locale, segments: slug, config: i18nConfig })
|
||||
if (target) permanentRedirect(target)
|
||||
notFound()
|
||||
}
|
||||
const enhanceProps = () => ({ locale }) // locale dla CMSLink w blokach
|
||||
const doc = route.doc as { layout?: unknown[] }
|
||||
return (
|
||||
<>
|
||||
<JsonLdGraph schemas={await getPageJsonLd(locale, slug)} /> {/* WebPage/BlogPosting, okruszki, FAQ */}
|
||||
<RenderBlocks blocks={doc.layout as never} components={blockRegistry} enhanceProps={enhanceProps} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
const route = createPageRoute(content, {
|
||||
blocks: blockRegistry,
|
||||
notFound, permanentRedirect, // wstrzyknięte z next/navigation
|
||||
blockProps: async ({ locale }) => ({ formTexts: await content.getFormTexts(locale), sendForm }),
|
||||
// render: ({ route, blocks }) => route.type === 'archive' ? <Archive … /> : undefined,
|
||||
})
|
||||
export default route.Page
|
||||
export const generateMetadata = route.generateMetadata
|
||||
export const generateStaticParams = route.generateStaticParams // SSG → <head> synchroniczny
|
||||
```
|
||||
Opcje `resolveRedirect` (`collections`, `homeSlug`): content.md.
|
||||
Archiwum z paginacją (`?page=`) — osobna trasa albo świadomie dynamiczna (pages.md).
|
||||
`createPageRoute`: trasa (`resolveRoute`), stary slug → 308 (`resolvePageRedirect`), 404, metadata,
|
||||
`generateStaticParams`, JSON-LD strony (`getPageJsonLd`, wyłączenie: `jsonLd: false`) i bloki z
|
||||
`locale` + `blockProps`. Bez `searchParams` — archiwum z paginacją (`?page=`) to osobna trasa albo
|
||||
świadomie dynamiczna (pages.md). Własna strona: te same helpery ręcznie (pages.md).
|
||||
|
||||
404 z panelu: `src/app/(frontend)/[locale]/not-found.tsx` z `getNotFoundPage`
|
||||
(przykład w pages.md).
|
||||
```tsx
|
||||
// src/app/(frontend)/[locale]/not-found.tsx — 404 z panelu, w języku z URL, bez headers()
|
||||
import { createNotFoundPage } from '@intecion/ipal-kit/rsc'
|
||||
import * as content from '@/lib/content'
|
||||
import { blockRegistry } from '@/blocks/registry'
|
||||
|
||||
export default createNotFoundPage(content, { blocks: blockRegistry /*, fallback: <h1>404</h1> */ })
|
||||
```
|
||||
|
||||
```ts
|
||||
// Trasy SEO / GEO / ops — każda to re-eksport, konfiguracja jest w lib/content.ts
|
||||
// src/app/sitemap.xml/route.ts — XML dla Google, wygląd dla ludzi z pluginu (nic w /public)
|
||||
export { sitemapRoute as GET } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
@@ -334,43 +319,29 @@ export const dynamic = 'force-dynamic'
|
||||
export { robots as default } from '@/lib/content'
|
||||
|
||||
// src/app/manifest.ts
|
||||
import { createManifestHandler } from '@intecion/ipal-kit'
|
||||
import { getCachedPayload } from '@/lib/content'
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
export { manifest as default } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||||
|
||||
// ---- GEO: wszystkie poniżej są obowiązkowe (AGENT.md §0b.5–7) ----
|
||||
// src/app/llms.txt/route.ts (+ llms-full.txt/route.ts: to samo z `full: true`)
|
||||
import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
||||
// ---- GEO: wszystkie poniżej są obowiązkowe (AGENT.md §0b.5–8) ----
|
||||
// src/app/llms.txt/route.ts (+ llms-full.txt/route.ts: llmsFullRoute)
|
||||
export { llmsRoute as GET } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, summaryField: 'aiSummary' })
|
||||
|
||||
// src/app/md/[locale]/[[...slug]]/route.ts — każda strona jako Markdown (noindex + canonical do HTML)
|
||||
import { createMarkdownRoute } from '@intecion/ipal-kit'
|
||||
import { contentConfig } from '@/content.config'
|
||||
export { markdownRoute as GET } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const { GET } = createMarkdownRoute({ getCachedPayload, content: contentConfig, config: i18nConfig,
|
||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL })
|
||||
|
||||
// src/app/indexnow-key.txt/route.ts — klucz IndexNow (z Site Integrations albo INDEXNOW_KEY)
|
||||
import { createIndexNowKeyRoute } from '@intecion/ipal-kit'
|
||||
export { indexNowKeyRoute as GET } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const GET = createIndexNowKeyRoute({ getCachedPayload })
|
||||
|
||||
// src/app/api/mcp/route.ts — publiczny serwer MCP (AI przegląda stronę)
|
||||
import { createMcpRoute } from '@intecion/ipal-kit'
|
||||
export { mcpGET as GET, mcpPOST as POST } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
const mcp = createMcpRoute({ getCachedPayload, config: i18nConfig, content: contentConfig,
|
||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, serverName: '<klient>-site', summaryField: 'aiSummary' })
|
||||
export const POST = mcp.POST
|
||||
export const GET = mcp.GET
|
||||
|
||||
// src/app/api/health/route.ts
|
||||
import { createHealthRoute } from '@intecion/ipal-kit'
|
||||
export { healthRoute as GET } from '@/lib/content'
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const GET = createHealthRoute({ getCachedPayload })
|
||||
```
|
||||
Jeden sitemap: `sitemap.xml/route.ts` **albo** `sitemap.ts` — nigdy oba. Nagłówek
|
||||
sitemapy = „XML Sitemap”, pod nim „Technology by Intecion.com”; zmiana
|
||||
@@ -567,6 +538,12 @@ Rób po jednej pozycji, buduj, sprawdzaj. Kolejność wg wagi:
|
||||
| 25 | **1.9.1** — zgoda: wersja, rejestr, tabela | Cookie Settings → Policy version; `consentLog: true` + `logEndpoint`; `<CookieBanner equalChoice>`; skan + `<CookieTable>`; Postgres: `migrate:create` | consent.md |
|
||||
| 26 | **1.9.1** — media: `priority`, brak placeholderów, `images` w next.config | `<Media>` przez `mediaImageProps`/`videoProps`, `buildMediaPlaceholderHook`, `buildImagesConfig`, `buildUploadSecurityHeaders` | storage.md |
|
||||
| 27 | **1.9.1** — staging indeksowany | `IPAL_NOINDEX=1` w env stagingu | seo.md |
|
||||
| 28 | **1.9.2** — własny `FormRenderer` (kopia silnika na `useForm`) | **bezpieczeństwo:** przekazywał do przeglądarki cały dokument formularza z zakładką Emails (adresy firmy w HTML). Blok → `<RenderForm form action locale texts classNames>`, wygląd do `formClasses.ts`, usuń `FormRenderer.tsx`; nietypowy formularz → `useBuilderForm` | forms.md |
|
||||
| 29 | **1.9.2** — formularze krokowe / listy wyboru robione w kodzie | panel: bloki **Step**, **Radio**, **Checkbox group**, **Date**; Notifications → next / back / stepOf; Postgres: `migrate:create` | forms.md |
|
||||
| 30 | **1.9.2** — layout składany ręcznie (ConsentProvider, TurnstileProvider, Analytics, JsonLdGraph, MediaPreconnect) | `<SiteProviders shell={await getSiteShell(locale)} …>` — te same opcje (banner, analytics, jsonLd, logEndpoint) | PROGRAMISTA §2.8 |
|
||||
| 31 | **1.9.2** — strona catch-all i `not-found.tsx` pisane ręcznie | `createPageRoute(content, {…})` / `createNotFoundPage(content, {…})` z `/rsc`; `revalidate` zostaje literałem | pages.md |
|
||||
| 32 | **1.9.2** — trasy llms/md/mcp/health/indexnow/manifest z konfiguracją w każdym pliku | re-eksport z `lib/content` (`llmsRoute`, `llmsFullRoute`, `markdownRoute`, `mcpGET`/`mcpPOST`, `healthRoute`, `indexNowKeyRoute`, `manifest`); `summaryField`, `mcp` raz w `createContentHelpers` | PROGRAMISTA §2.7 |
|
||||
| 33 | **1.9.2** — `src/fields/sectionHeader.ts`, `sectionSettings.ts`, `lib/navigation.ts`, ręczne `resolveLinkHref` w `CMSLink` | `buildSectionHeaderField`, `buildSectionSettingsField` (ten sam kształt danych — bez migracji), `resolveNav`, `resolveLink` z `lib/content` | blocks.md, links.md |
|
||||
|
||||
Po aktualizacji pakietu: `pnpm ipal:skills` (nowe wersje skilli), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep nowego symbolu w
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
Reference in New Issue
Block a user