@times-components/related-articles

6.20.7 • Public • Published

Related Articles

Related articles sit at the bottom of the article, providing similar articles for a user to navigate to should they be interested. The related articles component uses three templates which are configured within the slice layout package:

  • StandardSlice
  • LeadAndTwoSlice
  • OpinionAndTwoSlice

Standard template

This is the simplest template called StandardSlice, whereby all of the returned related articles (items) are of equal importance, and come pre-ordered (or sorted) from the API.

Lead and Opinion templates

The LeadAndTwoSlice and OpinionAndTwoSlice templates each have a "main" article, and two "supporting" articles (support1 and support2). This package takes the "main" (either lead or opinion, depending on the template) article, and passes that as part of a render prop to the slice layout package. A separate render prop handles the "supporting" articles (as an array). Each article is iterated over and rendered as appropriate.

Contributing

Please read CONTRIBUTING.md before contributing to this package

Running the code

Please see our main README.md to get the project running locally

Development

The code can be formatted and linted in accordance with the agreed standards.

yarn fmt
yarn lint

Testing

This package uses yarn (latest) to run unit tests on each platform with jest.

yarn test:web

Visit the official storybook to see our available related articles templates.

/@times-components/related-articles/

    Package Sidebar

    Install

    npm i @times-components/related-articles

    Weekly Downloads

    956

    Version

    6.20.7

    License

    BSD-3-Clause

    Unpacked Size

    313 kB

    Total Files

    21

    Last publish

    Collaborators

    • marcincuber
    • newsuk
    • news-tools