This module encapsulates the editorially selected logic for deciding which metadata items to display in teasers and article toppers.
This is a Node.js module available through the npm registry. Before installing, download and install Node.js. Node.js 18 or higher is required.
Installation is done using the npm install command:
$ npm install -S @financial-times/n-display-metadata
This module provides a method for each use case. Currently there is just one method for choosing which metadata to display on the teaser.
const metadata = require('@financial-times/n-display-metadata');
const teaserMetadata = metadata.teaser(content);
References to the variable content
refer to a content item either from the internal enriched content API or the FT.com Elasticsearch cluster. The content should have an annotations
property (which is an array of concepts and their relationship to the content) and containedIn
property (which is an array of packages which contain the content).
Returns an object with 3 properties:- prefixText
, link
and altLink
. The altLink
can be used when the current context of the teaser is the same as the link
, e.g. to avoid displaying links to "FastFT" on the FastFT stream page. It is up to the implementor to add this logic.
Coming soon.
All
Both teasers and toppers are capable of displaying two pieces of metadata:- a prefix and a link. Though similar decisions may be made for each, they are not strictly connected.
The logic for choosing which metadata to display on teasers was last decided by Mus and Guy on 28/08/2018 and implemented by Matt Hinchliffe on 29/08/2018.
The current decision trees can be seen in the docs folder