Files
ipal-kit/src/modules/seo/NoSnippet.tsx
T
Radosław SmolińskiandClaude Opus 5.5 4ec27d9ef0 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]>
2026-10-21 15:10:55 +02:00

38 lines
1.3 KiB
TypeScript

import type { HTMLAttributes, ReactNode } from 'react'
export type NoSnippetProps = {
/**
* Wrapper element. Only div, section and span — Google honours
* `data-nosnippet` on those and ignores it on footer, nav, aside and the rest.
* Default 'div'.
*/
as?: 'div' | 'section' | 'span'
children?: ReactNode
} & HTMLAttributes<HTMLElement>
/**
* Keeps its contents out of Google's search snippets (`data-nosnippet`). The
* text is still crawled and indexed — Google just won't quote it under a
* result.
*
* Use it for text that repeats on every page: the footer's address, hours and
* phone, a contact strip, a "book a visit" call to action. Google picks snippet
* text itself when it thinks it fits the query better than the meta
* description; for a brand search that is the contact block, so every sitelink
* ends up showing the same address. The address stays available to Google
* through the LocalBusiness JSON-LD.
*
* Never wrap <main> — that's the text the snippet should come from.
*
* <footer>
* <NoSnippet>…address, hours, phone, links…</NoSnippet>
* </footer>
*/
export function NoSnippet({ as: Tag = 'div', children, ...rest }: NoSnippetProps) {
return (
<Tag {...rest} data-nosnippet="">
{children}
</Tag>
)
}