Configuration Guide: Node.js and Browser-Side

Richie.js provides a flexible configuration schema that can be used in both Node.js and browser-side environments. The schema supports customization for preferences, reserved names, and rich result types.


Configuration Schema Overview

Richie.js uses a unified configuration schema with the following key options:

1. Domain Address

  • Key: domainAddress
  • Description: Specifies the base domain for generating structured data.
  • Example: "example.com"

2. Preferences

The preference object allows customization of key features for generating structured data.

Properties

PreferenceTypeDescriptionDefault
isCarousals.moviebooleanEnable or disable carousel support for movies.false
isCarousals.coursebooleanEnable or disable carousel support for courses.false
isCarousals.restaurantbooleanEnable or disable carousel support for restaurants.false
isCarousals.recipebooleanEnable or disable carousel support for recipes.false
isProductVarbooleanEnable product group for rich results.false
breadcrumbbooleanEnable or disable breadcrumb structured data.false
siteSearchBoxFieldNamestring

Specifies the name of the search input field for the site search box.

”query”

Example Configuration

preference: {
  isCarousals: {
    movie: true,
    course: false,
    restaurant: true,
    recipe: false,
  },
  isProductVar: true,
  breadcrumb: true,
  siteSearchBoxFieldName: "searchTerm",
}

3. Reserved Names

Reserved names are identifiers used for specific fields when generating rich result structured data. This allows you to align Richie.js with your website’s naming conventions.

Example Reserved Names Configuration:

reservedNames: {
  siteSearchBox: {
    baseID: "search-field",
  },
  aggregateRating: {
    wrapper: "rating-container",
    aggregatedRatingValue: "rating-value",
    maxRangeOfRating: "max-rating",
    numberOfRatings: "review-count",
  },
  article: {
    baseID: "article-base",
    articleType: "article-category",
    authorNameStartwith: "author-",
  },
}

To see the complete list of reserved names for supported rich result types, visit the Supported Rich Results.


Node.js Configuration

For Node.js environments, Richie.js simplifies configuration management. You don’t need to manually load or apply the configuration.

Initialize Configuration

Run the following command to generate a default configuration file in your project root:

rjs init

This will create a richiejs.config.js file with default settings. For example:

/** @type {import("@cresteem/richie-js").rjsOptions} */
const config = {
  domainAddress: "cresteem.com",
  preference: {
    isCarousals: {
      movie: false,
      course: false,
      recipe: true,
      restaurant: true,
    },
    isProductVar: false,
    breadcrumb: false,
    siteSearchBoxFieldName: "query",
  },
};
 
exports.default = config;

Richie.js will automatically detect and load the richiejs.config.js file from your project root during execution. No need to manually import or reference it in your code.

By default, Richie.js uses the auto-loaded configuration file. If the file is missing, it will fall back to its default configuration schema.

  • To modify the configuration, edit the richiejs.config.js file directly in your project root.
  • For advanced configurations, refer to the Supported Rich Results.

Browser-Side Configuration

For browser-side setups, the configuration object is passed as a parameter when calling the Richie.js API.

Example Initialization:

<script src="https://cdn.jsdelivr.net/npm/@cresteem/[email protected]/dist/browser/bundle.min.js"></script>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    RichieJS.default({
      richieNames: ["article", "faq"],
      configuration: {
        domainAddress: "example.com",
        preference: {
          breadcrumb: true,
          siteSearchBoxFieldName: "searchTerm",
        },
        reservedNames: {
          article: {
            baseID: "article-container",
            articleType: "category",
          },
        },
      },
    });
  });
</script>

Summary of Configuration Methods

FeatureNode.js SetupBrowser-Side Setup
Configuration Locationrichiejs.config.js filePassed as a parameter in RichieJS API
Reserved NamesDefine in richiejs.config.jsPass in API configuration object
Customization ScopeGlobal (entire server instance)Page-level (per API call)

Reserved Names Reference

For a detailed list of reserved names and how they map to specific fields in structured data, visit the Supported Rich Results.


Keywords

  • Richie.js Configuration
  • Dynamic Structured Data
  • Node.js Setup
  • Browser-Side Configuration
  • SEO Optimization
  • Rich Result Reserved Names