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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user