Built-in statistics (cookieless, consent-gated visitor history); per-page meta descriptions, NoSnippet

Stats: ipalKit({ stats: true }) adds the stats-visits collection, POST /api/ipal/hit, the
/admin/stats view (30-day visits chart, top/entry pages, referrers, devices), a dashboard card
and a nav link. <PageStats> (or <SiteProviders stats>) sends one beacon per page view. Without
consent nothing is stored on the device and no IP is kept: page views are joined by a hash with
an in-memory salt replaced daily. With analytics consent an ipal_vid cookie links visits across
days (server re-checks the consent cookie and policy version; withdrawal deletes the cookie).
Bots, logged-in panel users and prefetches aren't counted. Retention 90 days.
@payloadcms/next added to peerDependencies (DefaultTemplate). Docs: stats.md with privacy text.

Also in this release: meta.description auto-filled from page blocks, <NoSnippet>,
MetaDescriptionCheck in the SEO tab, data-nosnippet on banner/language switcher, GA4 CSP
wildcards, consent version passed to Analytics' default consent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-21 15:10:55 +02:00
co-authored by Claude Opus 5.5
parent 305c564d13
commit 4ec27d9ef0
47 changed files with 1799 additions and 57 deletions
+44
View File
@@ -7,10 +7,12 @@ import { markdownHref, prefersMarkdown } from '../src/modules/content/markdownNe
import { lexicalToMarkdown } from '../src/modules/richtext/lexicalToMarkdown.js'
import { buildCsp } from '../src/modules/security/buildCsp.js'
import { buildSecurityHeaders } from '../src/modules/security/buildSecurityHeaders.js'
import { buildAutoFillMetaHook } from '../src/modules/seo/autoFillMeta.js'
import { AI_TRAINING_BOTS, buildRobots } from '../src/modules/seo/buildRobots.js'
import { buildSitemapXml } from '../src/modules/seo/buildSitemapXml.js'
import { createPageMetadata } from '../src/modules/seo/createPageMetadata.js'
import { buildHreflangAlternates } from '../src/modules/seo/hreflang.js'
import { describeFromMarkdown } from '../src/modules/seo/plainText.js'
const config: I18nConfig = {
defaultLocale: 'pl',
@@ -301,3 +303,45 @@ describe('buildProductJsonLd', () => {
})
})
})
describe('meta description auto-fill', () => {
const layout = [
{ blockType: 'hero', heading: 'Car detailing in Opole', subheading: 'For drivers who expect more' },
{ blockType: 'content', body: 'We apply Gtechniq ceramic coatings and correct paint. Every car gets a written report.' },
{ blockType: 'content', body: 'Book a free consultation — we will advise on the scope. Opening hours are listed on the contact page.' },
]
// the hook ignores everything but data and originalDoc
const run = (data: Record<string, unknown>, originalDoc?: Record<string, unknown>, mapping = {}) =>
buildAutoFillMetaHook(mapping)({ data, operation: originalDoc ? 'update' : 'create', originalDoc } as never) as Record<string, unknown>
test('describeFromMarkdown skips headings and keeps whole sentences', () => {
const md = '## Title\n\nFirst sentence here. Second one.\n\n### Sub\n\nThird part without a stop'
expect(describeFromMarkdown(md)).toBe('First sentence here. Second one. Third part without a stop.')
const long = describeFromMarkdown('One short sentence. ' + 'word '.repeat(60), 155)
expect(long).toBe('One short sentence.')
expect(describeFromMarkdown('## Only a heading')).toBe('Only a heading.')
expect(describeFromMarkdown('')).toBe('')
})
test('fills an empty description from the page blocks', () => {
const out = run({ layout, title: 'Detailing' })
const meta = out.meta as Record<string, string>
expect(meta.title).toBe('Detailing')
expect(meta.description).toBe(
'We apply Gtechniq ceramic coatings and correct paint. Every car gets a written report. Book a free consultation — we will advise on the scope.',
)
expect(meta.description.length).toBeLessThanOrEqual(155)
})
test('never replaces a description — typed now or already stored', () => {
expect((run({ layout, meta: { description: 'Mine' } }).meta as Record<string, string>).description).toBe('Mine')
// partial update: data carries only the layout, the stored doc has a description
const out = run({ layout }, { meta: { description: 'Stored', title: 'T' } })
expect(out.meta).toBeUndefined()
})
test('mapped description field wins; content: false turns the fallback off', () => {
expect((run({ excerpt: 'Excerpt text', layout }, undefined, { description: 'excerpt' }).meta as Record<string, string>).description).toBe('Excerpt text')
expect((run({ layout, title: 'T' }, undefined, { content: false }).meta as Record<string, string>).description).toBeUndefined()
})
})