/*
Builds the JSON-LD ItemList node for "collection"-typed pages (RFC-0490 pillar hub).
- Do not build per-item Product or Service nodes — the ItemList references page URLs only.
- RFC-0490: initial — ItemList node for collection-typed pillar hub pages.
*/
import type { JsonLdContext } from "./context.ts";
import type { JsonLdNode } from "./types.ts";
export function buildCollectionListNode(context: JsonLdContext): JsonLdNode | null {
const { page, collectionListId } = context;
if (!collectionListId || !page.collectionItems?.length) return null;
return {
"@type": "ItemList",
"@id": collectionListId,
itemListElement: page.collectionItems.map((item, index) => ({
"@type": "ListItem",
position: index + 1,
url: item.url,
name: item.name,
})),
};
}