SEO/GEO tools and project requests: site index, IndexNow, page JSON-LD, fixes
GEO / SEO
- collectSiteIndex: one list of public docs per locale (pages + archive
entries) on sitemap rules; llms.txt/llms-full and MCP list_pages now include
blog/content entries and every language. Fixes hard-coded "## Strony" heading
and homepage not collapsing to the locale root in llms.txt.
- Markdown frontmatter: canonical url + updated date.
- Metadata: X/Twitter card, OG image width/height/alt, og:type article with
published/modified times for entries.
- Fix: Site Settings "defaultShareImage" was never used — now the OG fallback.
- getPageJsonLd (createContentHelpers): WebPage/CollectionPage/BlogPosting,
BreadcrumbList from the real route, FAQPage via a project mapper.
- IndexNow (opt-in ipalKit({ indexNow: true })): submit published URLs in all
languages, key generated in Site Integrations or INDEXNOW_KEY, key route.
- sameAs profiles in Site Settings + sameAsUrls(); sitemap <image:image>.
From project reports
- Fix: package exports were missing ./env and ./fluid.css although the docs
import them (TS2307); regression test checks every documented subpath.
- Fix: plugins run before Payload adds its default users collection, so roles
and 2FA had nothing to attach to — ipalKit injects an auth collection when
the project has none (project's own one wins). Audit no longer errors on it.
- createMarkdownRoute, createSubmitAction (/server, headers injected).
- formatOpeningHours (PL/EN/DE text → schema.org), used by
buildLocalBusinessJsonLd, which also takes a schema.org `type`.
- buildNavigationJsonLd straight from the header global.
- buildCsp googleMaps: full Maps JS API domain set; values de-duplicated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -9,7 +9,8 @@ import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapSty
|
||||
|
||||
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'
|
||||
import { buildWebPageJsonLd } from '../seo/buildWebPageJsonLd.js'
|
||||
import { buildArticleJsonLd, buildBreadcrumbJsonLd, buildFaqJsonLd, buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js'
|
||||
|
||||
type CreateContentHelpersArgs = {
|
||||
/**
|
||||
@@ -38,6 +39,8 @@ type CreateContentHelpersArgs = {
|
||||
* (content.md). Indexable pages only.
|
||||
*/
|
||||
markdownAlternate?: boolean | string
|
||||
/** Defaults for getPageJsonLd — each call can override them. */
|
||||
pageJsonLd?: PageJsonLdOptions
|
||||
/** Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string
|
||||
/**
|
||||
@@ -48,6 +51,8 @@ type CreateContentHelpersArgs = {
|
||||
robots?: RobotsOptions
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
/** Image URLs of a document for the sitemap (Google Images). Default: its SEO share image. */
|
||||
sitemapImages?: (doc: Record<string, unknown>) => (null | string | undefined)[]
|
||||
/**
|
||||
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
||||
* header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
|
||||
@@ -55,6 +60,20 @@ type CreateContentHelpersArgs = {
|
||||
sitemapStyle?: false | SitemapStyleOptions
|
||||
}
|
||||
|
||||
export type PageJsonLdOptions = {
|
||||
/** BreadcrumbList (home › archive › page) from the real route. Default true. */
|
||||
breadcrumbs?: boolean
|
||||
/** schema.org type of archive entries. Default 'BlogPosting'. */
|
||||
entryType?: 'Article' | 'BlogPosting' | 'NewsArticle'
|
||||
/**
|
||||
* Q&A visible on this page (e.g. from its FAQ block) → FAQPage. The project
|
||||
* knows its block shape, so it maps it: `(doc) => doc.layout…map(i => ({ question, answer }))`.
|
||||
*/
|
||||
faq?: (doc: Record<string, unknown>) => { answer: string; question: string }[]
|
||||
/** schema.org type of ordinary pages, per document (e.g. 'ContactPage'). Default 'WebPage'. */
|
||||
pageType?: (doc: Record<string, unknown>) => string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundles the per-request data helpers a frontend needs — the same cached
|
||||
* wrappers every project was writing by hand (getPayload, settings, locale
|
||||
@@ -87,9 +106,11 @@ export function createContentHelpers({
|
||||
content,
|
||||
i18n,
|
||||
markdownAlternate,
|
||||
pageJsonLd: pageJsonLdDefaults,
|
||||
pagesSlug = 'pages',
|
||||
robots: robotsOptions,
|
||||
settingsSlug = 'site-settings',
|
||||
sitemapImages,
|
||||
sitemapStyle,
|
||||
}: CreateContentHelpersArgs) {
|
||||
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
|
||||
@@ -175,6 +196,89 @@ export function createContentHelpers({
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Per-page structured data — WebPage (BlogPosting for archive entries) with
|
||||
* language and dates, BreadcrumbList from the actual route, FAQPage when the
|
||||
* project maps its FAQ block. Built from the same cached route and metadata
|
||||
* as the page, so it can't disagree with canonical/title. Returns plain nodes
|
||||
* — render them with <JsonLdGraph schemas={…}> next to the layout's
|
||||
* WebSite/Organization, add your own, or drop any.
|
||||
*
|
||||
* // [[...slug]]/page.tsx
|
||||
* <JsonLdGraph schemas={await getPageJsonLd(locale, slug)} />
|
||||
*/
|
||||
const getPageJsonLd = async (
|
||||
locale: string,
|
||||
segments: string[] | undefined,
|
||||
options: PageJsonLdOptions = {},
|
||||
): Promise<Record<string, unknown>[]> => {
|
||||
const opts = { ...pageJsonLdDefaults, ...options }
|
||||
const [meta, route, settings] = await Promise.all([
|
||||
generatePageMetadata(locale, segments),
|
||||
resolveRoute(locale, segments ?? [], 1),
|
||||
getSettings(locale) as Promise<Record<string, unknown>>,
|
||||
])
|
||||
const url = meta.alternates?.canonical
|
||||
if (!route || !url || meta.robots?.index === false) {return []}
|
||||
|
||||
const doc = route.doc
|
||||
const str = (v: unknown) => (typeof v === 'string' && v.trim() ? v.trim() : undefined)
|
||||
const name = str(doc.title) ?? meta.title
|
||||
const siteName = str(settings?.siteName)
|
||||
const root = new URL(url)
|
||||
const singleLocale = (i18n?.locales.length ?? 0) === 1
|
||||
const homeUrl = `${root.origin}${singleLocale ? '' : `/${locale}`}`
|
||||
const image = meta.openGraph?.images?.[0]?.url
|
||||
const nodes: (null | Record<string, unknown>)[] = []
|
||||
|
||||
if (route.type === 'entry') {
|
||||
nodes.push(
|
||||
buildArticleJsonLd({
|
||||
type: opts.entryType ?? 'BlogPosting',
|
||||
dateModified: str(doc.updatedAt),
|
||||
datePublished: str(doc.publishedAt) ?? str(doc.createdAt),
|
||||
description: meta.description,
|
||||
headline: name,
|
||||
image: image ? { url: image } : undefined,
|
||||
publisherName: siteName,
|
||||
url,
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
nodes.push(
|
||||
buildWebPageJsonLd({
|
||||
name,
|
||||
type: route.type === 'archive' ? 'CollectionPage' : (opts.pageType?.(doc) ?? 'WebPage'),
|
||||
dateModified: str(doc.updatedAt),
|
||||
description: meta.description,
|
||||
image,
|
||||
inLanguage: locale,
|
||||
url,
|
||||
websiteUrl: homeUrl,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
if (opts.breadcrumbs !== false && route.type !== 'home') {
|
||||
const homepage = settings?.homepage as Record<string, unknown> | undefined
|
||||
const crumbs = [{ name: str(homepage?.title) ?? siteName ?? root.host, url: homeUrl }]
|
||||
if (route.type === 'entry') {
|
||||
const archiveName = str(route.archive.title)
|
||||
if (archiveName) {crumbs.push({ name: archiveName, url: url.replace(/\/[^/]+$/, '') })}
|
||||
}
|
||||
crumbs.push({ name, url })
|
||||
nodes.push(buildBreadcrumbJsonLd(crumbs))
|
||||
}
|
||||
|
||||
const faq = opts.faq?.(doc)?.filter((i) => i.question?.trim() && i.answer?.trim())
|
||||
if (faq?.length) {nodes.push(buildFaqJsonLd(faq))}
|
||||
|
||||
// JsonLdGraph adds the @context once for the whole @graph.
|
||||
return nodes
|
||||
.filter((n): n is Record<string, unknown> => Boolean(n))
|
||||
.map(({ '@context': _context, ...node }) => node)
|
||||
}
|
||||
|
||||
/** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */
|
||||
const getNotFoundPageId = cache(async (): Promise<null | number | string> => {
|
||||
const payload = await getCachedPayload()
|
||||
@@ -259,6 +363,7 @@ export function createContentHelpers({
|
||||
baseUrl: origin,
|
||||
config: i18n,
|
||||
content,
|
||||
images: sitemapImages,
|
||||
pagesSlug,
|
||||
payload: await getCachedPayload(),
|
||||
settingsSlug,
|
||||
@@ -424,6 +529,7 @@ export function createContentHelpers({
|
||||
getConfiguredLocales,
|
||||
getEntries,
|
||||
getNotFoundPage,
|
||||
getPageJsonLd,
|
||||
getSettings,
|
||||
resolveRoute,
|
||||
robots,
|
||||
|
||||
Reference in New Issue
Block a user