@financial-times/n-display-metadata

[![CircleCI](https://img.shields.io/circleci/project/github/Financial-Times/n-display-metadata/master.svg)](https://circleci.com/gh/Financial-Times/n-display-metadata) [![NPM version](https://img.shields.io/npm/v/@financial-times/n-display-metadata.svg)](

Stats

StarsIssuesVersionUpdatedCreatedSize
@financial-times/n-display-metadata
1.0.010 months ago3 years agoMinified + gzip package size for @financial-times/n-display-metadata in KB

Readme

n-display-metadata

CircleCI NPM version

This module encapsulates the editorially selected logic for deciding which metadata items to display in teasers and article toppers.

Installation

This is a Node.js module available through the npm registry. Before installing, download and install Node.js. Node.js 6 or higher is required.

Installation is done using the npm install command:

$ npm install -S @financial-times/n-display-metadata

Usage

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).

API

.teaser(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.

.topper(content)

Coming soon.

Content

All

Logic

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.

Teasers

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.