function addLanguageAlternate
addLanguageAlternate(
schema: Record<string, any>,
alternateId: string,
isOriginal: boolean
): Record<string, any>

Helper function to manually add language alternate links to a schema

Useful for custom schema objects created in templates or frontmatter.

Examples

Example 1

const schema = {
  "@id": "https://example.com/en/page/#content",
  "@type": "WebPage",
  // ...
};

addLanguageAlternate(
  schema,
  "https://example.com/ja/page/#content",
  true // This is the original English version
);

// Result: schema now has workTranslation: [{ "@id": "https://example.com/ja/page/#content" }]

Parameters

schema: Record<string, any>

The schema object to modify

alternateId: string

The @id of the alternate language version

isOriginal: boolean

Whether this schema is for the original (default) language

Return Type

Record<string, any>

Modified schema object

Usage

import { addLanguageAlternate } from ".";