Agent instructions: mandatory feature set (SEO, GEO, R2, Turnstile, forms) enforced by audits
- AGENT.md §0b: one table of everything every site must have (SEO meta/maps,
JSON-LD, llms.txt + llms-full, Markdown, MCP, AI bots, R2, panel forms,
Turnstile, consent, security, ops, system pages, zero hardcodes), the
forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written
JSON-LD, static SEO files, raw S3) and an `ipal-audit-skip:` escape hatch that
needs a recorded client decision.
- ipal-audit: "missing: …" errors for every mandatory item and for plugin
replacements; ipal-seo-check: runtime GEO checks (llms, Markdown, MCP,
JSON-LD, AI bots, health). Both verified on bare and complete fixtures.
- Skills (setup, site, form, upgrade, audit, seo-check) and PROGRAMISTA.md
wire the full set from step one; GEO is no longer "optional".
- Fix: createProxy({ markdown: true }) lets /md/... through — multilingual
sites redirected /md/pl/x to /pl/md/pl/x, so the documented Markdown route
never worked — and handles Accept: text/markdown.
- createContentHelpers({ markdownAlternate: true }) adds the text/markdown
alternate link in generatePageMetadata.
- JSDoc/docs JSON-LD examples use JsonLdGraph; docs/CHANGELOG.md for 1.9.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -8,6 +8,7 @@ import type { I18nConfig } from '../i18n/index.js'
|
||||
import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js'
|
||||
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'
|
||||
import { MARKDOWN_PREFIX, markdownHref } from '../content/markdownNegotiation.js'
|
||||
import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js'
|
||||
|
||||
type CreateContentHelpersArgs = {
|
||||
@@ -29,6 +30,14 @@ type CreateContentHelpersArgs = {
|
||||
* handlers — they need the locale list to emit hreflang.
|
||||
*/
|
||||
i18n?: I18nConfig
|
||||
/**
|
||||
* Advertise each page's Markdown version from generatePageMetadata:
|
||||
* `<link rel="alternate" type="text/markdown" href="/md/pl/o-nas">` (GEO —
|
||||
* agents find the clean version without guessing). `true` uses the '/md'
|
||||
* prefix, a string sets another one. Needs the matching Markdown route
|
||||
* (content.md). Indexable pages only.
|
||||
*/
|
||||
markdownAlternate?: boolean | string
|
||||
/** Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string
|
||||
/**
|
||||
@@ -77,6 +86,7 @@ export function createContentHelpers({
|
||||
config,
|
||||
content,
|
||||
i18n,
|
||||
markdownAlternate,
|
||||
pagesSlug = 'pages',
|
||||
robots: robotsOptions,
|
||||
settingsSlug = 'site-settings',
|
||||
@@ -154,7 +164,15 @@ export function createContentHelpers({
|
||||
},
|
||||
settingsSlug,
|
||||
})
|
||||
return pageMetadata({ slug: segments, locale, page, payload: await getCachedPayload() })
|
||||
const meta = await pageMetadata({ slug: segments, locale, page, payload: await getCachedPayload() })
|
||||
const canonical = meta.alternates?.canonical
|
||||
if (!markdownAlternate || !canonical || meta.robots?.index === false) {return meta}
|
||||
const prefix = typeof markdownAlternate === 'string' ? markdownAlternate : MARKDOWN_PREFIX
|
||||
const pathname = new URL(canonical, 'http://localhost').pathname
|
||||
return {
|
||||
...meta,
|
||||
alternates: { ...meta.alternates, types: { ...meta.alternates?.types, 'text/markdown': markdownHref(pathname, prefix) } },
|
||||
}
|
||||
}
|
||||
|
||||
/** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { I18nConfig } from './types.js'
|
||||
|
||||
import { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from '../content/markdownNegotiation.js'
|
||||
import { isValidLocale } from './helpers.js'
|
||||
import { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'
|
||||
|
||||
@@ -31,6 +32,8 @@ type ProxyResponse = {
|
||||
type NextResponseLike = {
|
||||
next: (init?: { request?: { headers: Headers } }) => ProxyResponse
|
||||
redirect: (url: string | URL) => ProxyResponse
|
||||
/** Needed for `markdown` content negotiation; Next's NextResponse has it. */
|
||||
rewrite?: (url: string | URL) => ProxyResponse
|
||||
}
|
||||
|
||||
type CreateProxyOptions = {
|
||||
@@ -39,6 +42,13 @@ type CreateProxyOptions = {
|
||||
cookieName?: string
|
||||
/** Expose x-locale / x-pathname request headers to RSC. Default true. */
|
||||
exposeHeaders?: boolean
|
||||
/**
|
||||
* GEO: wire the Markdown route (content.md). `true` = prefix '/md', a string
|
||||
* sets another one. Paths under the prefix pass through untouched (no locale
|
||||
* redirect — /md/pl/o-nas must not become /pl/md/pl/o-nas), and a page
|
||||
* requested with `Accept: text/markdown` is rewritten to its Markdown version.
|
||||
*/
|
||||
markdown?: boolean | string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,22 +63,34 @@ type CreateProxyOptions = {
|
||||
* import { NextResponse } from 'next/server'
|
||||
* import { createProxy, DEFAULT_PROXY_MATCHER } from '@intecion/ipal-kit'
|
||||
* import { i18nConfig } from '@/i18n.config'
|
||||
* export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||
* export const config = { matcher: DEFAULT_PROXY_MATCHER }
|
||||
* export const proxy = createProxy(i18nConfig, { NextResponse, markdown: true })
|
||||
* export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] } // inline literal
|
||||
*/
|
||||
export function createProxy(
|
||||
config: I18nConfig,
|
||||
deps: { NextResponse: NextResponseLike } & CreateProxyOptions,
|
||||
): (request: ProxyRequest) => ProxyResponse {
|
||||
const { exposeHeaders = true, NextResponse, ...mwOptions } = deps
|
||||
const { exposeHeaders = true, markdown, NextResponse, ...mwOptions } = deps
|
||||
const run = createLocaleMiddleware({ config, ...mwOptions })
|
||||
const mdPrefix = markdown ? (typeof markdown === 'string' ? markdown : MARKDOWN_PREFIX).replace(/\/$/, '') : null
|
||||
|
||||
return (request: ProxyRequest): ProxyResponse => {
|
||||
const { pathname } = request.nextUrl
|
||||
if (mdPrefix) {
|
||||
if (pathname === mdPrefix || pathname.startsWith(`${mdPrefix}/`)) {return NextResponse.next()}
|
||||
// Only locale-qualified paths (or single-locale sites) map 1:1 onto the
|
||||
// Markdown route; the rest gets the locale redirect first, then negotiates.
|
||||
const seg = pathname.split('/').filter(Boolean)[0] ?? ''
|
||||
const routable = config.locales.length === 1 || isValidLocale(seg, config)
|
||||
if (routable && NextResponse.rewrite && prefersMarkdown(request.headers)) {
|
||||
return NextResponse.rewrite(new URL(markdownHref(pathname, mdPrefix), request.url))
|
||||
}
|
||||
}
|
||||
|
||||
const result = run(request)
|
||||
|
||||
const requestHeaders = new Headers(request.headers)
|
||||
if (exposeHeaders) {
|
||||
const { pathname } = request.nextUrl
|
||||
const seg = pathname.split('/').filter(Boolean)[0] ?? ''
|
||||
const locale = isValidLocale(seg, config) ? seg : config.defaultLocale
|
||||
requestHeaders.set('x-locale', locale)
|
||||
|
||||
@@ -14,6 +14,8 @@ export type PageMetadata = {
|
||||
alternates?: {
|
||||
canonical?: string
|
||||
languages?: Record<string, string>
|
||||
/** Alternate representations by MIME type, e.g. { 'text/markdown': '/md/pl/o-nas' }. */
|
||||
types?: Record<string, string>
|
||||
}
|
||||
description?: string
|
||||
openGraph?: {
|
||||
|
||||
@@ -17,15 +17,15 @@ type OrganizationJsonLdArgs = {
|
||||
* search (brand recognition, logo in knowledge panels) and is a signal used
|
||||
* alongside favicon for identity.
|
||||
*
|
||||
* Returns a plain object; the project renders it as a <script type="application/
|
||||
* ld+json"> in the root layout:
|
||||
* Returns a plain object; the project renders it with <JsonLdGraph> in the
|
||||
* root layout:
|
||||
*
|
||||
* import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
||||
* const jsonLd = buildOrganizationJsonLd({
|
||||
* name: settings.siteName, url: baseUrl, logo: settings.logo,
|
||||
* })
|
||||
* <script type="application/ld+json"
|
||||
* dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
|
||||
* // render through JsonLdGraph (@intecion/ipal-kit/rsc) — it escapes '<' and wraps @graph:
|
||||
* <JsonLdGraph schemas={[jsonLd]} />
|
||||
*
|
||||
* Data comes from the panel (siteName, logo) — nothing hardcoded. Emit once in
|
||||
* the root layout (Organization is site-wide, not per page).
|
||||
|
||||
@@ -37,8 +37,8 @@ type WebSiteJsonLdArgs = {
|
||||
*
|
||||
* import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
||||
* const jsonLd = buildWebSiteJsonLd({ name: settings.siteName, url: baseUrl })
|
||||
* <script type="application/ld+json"
|
||||
* dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
|
||||
* // render through JsonLdGraph (@intecion/ipal-kit/rsc) — it escapes '<' and wraps @graph:
|
||||
* <JsonLdGraph schemas={[jsonLd]} />
|
||||
*/
|
||||
export function buildWebSiteJsonLd({ name, search, url }: WebSiteJsonLdArgs) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user