function languageAlternatesSchema
languageAlternatesSchema(options: LanguageAlternatesSchemaOptions): (pages: any[]) => void

Creates a language alternates schema preprocessor

This preprocessor:

  1. Maps pages by their ID and language
  2. Finds pages with the same ID in different languages
  3. Links them via Schema.org relationships:
    • Original language (default) → adds workTranslation pointing to translations
    • Translated languages → adds translationOfWork pointing to original
  4. Updates all specified schema types on each page

Requirements:

  • Pages must have an id field in frontmatter
  • Pages must have a lang field in frontmatter
  • Schema objects must have an @id property

Examples

Example 1

// In page frontmatter:
// en/services/consulting.md
---
id: service-consulting
lang: en
serviceSchema:
  "@id": "https://example.com/en/services/consulting/#service"
  ...
---

// ja/services/consulting.md
---
id: service-consulting
lang: ja
serviceSchema:
  "@id": "https://example.com/services/consulting/#service"
  ...
---

After processing:

  • EN page serviceSchema gains: workTranslation: { "@id": "https://example.com/services/consulting/#service" }
  • JA page serviceSchema gains: translationOfWork: { "@id": "https://example.com/en/services/consulting/#service" }

Parameters

Configuration options

Return Type

(pages: any[]) => void

Preprocessor function compatible with Lume's site.preprocess()

Usage

import { languageAlternatesSchema } from ".";