videogen/apps/web/lib/seo/jsonld.ts
caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

165 lines
4.7 KiB
TypeScript

/**
* Structured-data (JSON-LD) builders shared by the programmatic pages. Kept as
* plain object factories so pages stay declarative and the shapes are testable
* without rendering. All URLs are absolute against SITE_URL.
*/
import { SITE_URL, MENIVOR_ONE_LINER } from "./site";
import { softwareApplicationEntity } from "./entity";
/** A single breadcrumb hop: a human label and an absolute-ish path. */
export interface Crumb {
readonly name: string;
readonly path: string;
}
/** A question/answer pair used for FAQPage structured data. */
export interface FaqEntry {
readonly question: string;
readonly answer: string;
}
/**
* SoftwareApplication node describing Menivor, reused across pages. Offers come
* from plan config through the entity module (MB1); no price is typed here.
*/
export function softwareApplicationLd(description: string = MENIVOR_ONE_LINER) {
return softwareApplicationEntity(description);
}
/** BreadcrumbList node from an ordered list of crumbs. */
export function breadcrumbLd(crumbs: readonly Crumb[]) {
return {
"@type": "BreadcrumbList",
itemListElement: crumbs.map((crumb, index) => ({
"@type": "ListItem",
position: index + 1,
name: crumb.name,
item: `${SITE_URL}${crumb.path}`,
})),
} as const;
}
/**
* ItemList node for a set of related internal links (the graph mesh). Emitting
* the related-links block as structured data gives AI answer engines an
* explicit, ordered entity list to follow, on top of the visible links.
*/
export function itemListLd(items: readonly Crumb[]) {
return {
"@type": "ItemList",
itemListElement: items.map((item, index) => ({
"@type": "ListItem",
position: index + 1,
name: item.name,
url: `${SITE_URL}${item.path}`,
})),
} as const;
}
/** A single ordered step in a HowTo. */
export interface HowToStep {
readonly name: string;
readonly text: string;
}
/**
* HowTo node for a step-by-step guide. Emitting HowTo alongside the visible
* ordered list gives search and answer engines an explicit, structured recipe.
*/
export function howToLd(
name: string,
description: string,
steps: readonly HowToStep[],
) {
return {
"@type": "HowTo",
name,
description,
step: steps.map((step, index) => ({
"@type": "HowToStep",
position: index + 1,
name: step.name,
text: step.text,
})),
} as const;
}
/**
* Article node for an editorial guide, attributed to the Menivor organization.
* `path` is a site-relative path resolved against SITE_URL.
*/
export function articleLd(params: {
readonly headline: string;
readonly description: string;
readonly path: string;
readonly datePublished: string;
readonly dateModified?: string;
}) {
return {
"@type": "Article",
headline: params.headline,
description: params.description,
mainEntityOfPage: `${SITE_URL}${params.path}`,
datePublished: params.datePublished,
dateModified: params.dateModified ?? params.datePublished,
author: { "@type": "Organization", name: "Menivor", url: SITE_URL },
publisher: { "@type": "Organization", name: "Menivor", url: SITE_URL },
} as const;
}
/**
* Person node for a creator's public profile page. `path` is the profile's
* site-relative path (`/creators/{handle}`). `stats` surfaces the creator's
* public template/follower counts as `interactionStatistic` entries without
* inventing a review or rating that is not already shown on the page.
*/
export function personLd(params: {
readonly name: string;
readonly description: string;
readonly path: string;
readonly stats?: ReadonlyArray<{ readonly interactionType: string; readonly userInteractionCount: number }>;
}) {
return {
"@type": "Person",
name: params.name,
description: params.description,
url: `${SITE_URL}${params.path}`,
mainEntityOfPage: `${SITE_URL}${params.path}`,
...(params.stats && params.stats.length > 0
? {
interactionStatistic: params.stats.map((stat) => ({
"@type": "InteractionCounter",
interactionType: stat.interactionType,
userInteractionCount: stat.userInteractionCount,
})),
}
: {}),
} as const;
}
/** FAQPage node from question/answer pairs. */
export function faqPageLd(faqs: readonly FaqEntry[]) {
return {
"@type": "FAQPage",
mainEntity: faqs.map((faq) => ({
"@type": "Question",
name: faq.question,
acceptedAnswer: {
"@type": "Answer",
text: faq.answer,
},
})),
} as const;
}
/** Wrap one or more nodes into a single @graph document ready to serialise. */
export function graphDocument(
nodes: ReadonlyArray<Record<string, unknown>>,
): Record<string, unknown> {
return {
"@context": "https://schema.org",
"@graph": nodes,
};
}