Class

Config

Config

Represents the configuration of the publisher. This represents the API call of /api/v1/config.

In the malibu framework, this is loaded at page load, then updated periodically. An instance of the Config object will be injected into most malibu functions, and you should never need to create it manually.

See the API Documentation for a list of fields

Methods

asJson()

Use this to convert to a simple javascript object, suitable for JSON.

View Source index.js, line 483

getDomainConfig(domainSlug) → {object}

This method can be used to get the configuration for a domain.

Parameters:
Name Type Description
domainSlug string

View Source index.js, line 497

Configuration for the domain

object

getDomainSections(domainSlug) → {array}

This method can be used to get the list of sections for a given domain

Parameters:
Name Type Description
domainSlug string

View Source index.js, line 515

A list of sections that are part of the domain

array

getHomeCollectionSlug(domainSlug) → {string}

This method can be used to get the home collection's slug for a given domainSlug

Parameters:
Name Type Description
domainSlug string

View Source index.js, line 506

The slug of the home collection for a domain

string

getStack()

Deprecated:
  • Yes

View Source index.js, line 488

memoize(key, f)

This can be used to memoize a synchronous function. The value of f() is stored against the given key until the config object is removed from memory. By default in malibu, the config object is replaced every two minutes. Typically, this is used to memoize the routes for fast subsequest requests.

Example:

const routes = config.memoize("routes_all", () => [homePage, ...storyPages, ...sectionPages])
Parameters:
Name Type Description
key string

The key to store the results against

f function

A function that is executed to get the results

View Source index.js, line 537

The value of f() if it's called the first time, else the value against the key