9.4.1 • Published 2 days ago

@financial-times/dotcom-server-navigation v9.4.1

Weekly downloads
631
License
MIT
Repository
-
Last release
2 days ago

@financial-times/dotcom-server-navigation

This package provides tools to fetch and format navigation data for FT.com.

It is primarily intended to be consumed via the dotcom-middleware-navigation package which can be used by Express applications.

Data for the menus will be periodically fetched and updated from the Next Navigation API. This data is managed by editorial staff and is used to render the navigation components across FT.com including the header, drop-down menus, drawer, and footer.

Getting started

This package is compatible with Node 12+ and is distributed on npm.

npm install -S @financial-times/dotcom-server-navigation

This package provides a single class which can be configured using options.

import { Navigation } from '@financial-times/dotcom-server-navigation'
const navigation = new Navigation()

The navigation instance provides methods to retrieve global navigation data and navigation for a specific page:

const menusData = await navigation.getMenusData()
const menusDataForPage = await navigation.getMenusFor('/companies/health', 'uk')

API

getMenusData(): Promise<TNavMenus>

Resolves all menus data, refreshed by a poller. This data has been deep-frozen to prevent accidental mutation as it gets passed around. If you need to modify any part of the data, you should first clone the parts you need and then work with your cloned object.

getMenusFor(currentPath: string, currentEdition?: string): Promise<TNavMenusForEdition>

Resolves the menus data for the current edition with any links to the current path marked as selected and URL placeholders updated. If no edition is provided it will default to "uk".

getSubNavigationFor(currentPath: string): Promise<TNavSubNavigation>

Resolves any sub-navigation data for the current path which may include ancestors and children (a.k.a. crumbtrail and subsections).

getEditionsFor(currentEdition?: string): TNavEditions

Returns the available FT editions with the current edition selected. If no edition is provided it will default to "uk".

Options

The Navigation class accepts the following parameters. All parameters are optional:

menuUrl

The URL to the navigation service endpoint which provides the global navigation data. Defaults to "http://next-navigation.ft.com/v2/menus".

subNavigationUrl

The URL to the navigation service endpoint which provides navigation data for a given path. Defaults to "http://next-navigation.ft.com/v2/hierarchy".

interval

Time in milliseconds to wait between polling navigation data. Defaults to 900000 (15 minutes).

9.4.1

2 days ago

9.4.0

23 days ago

9.3.4

3 months ago

8.2.6

3 months ago

9.3.3

3 months ago

9.3.2

4 months ago

9.3.1

4 months ago

9.3.0

4 months ago

9.2.1

4 months ago

9.2.0

4 months ago

9.1.1

4 months ago

9.1.0

5 months ago

9.0.3

5 months ago

8.2.3

7 months ago

8.2.2

7 months ago

8.2.5

7 months ago

8.2.4

7 months ago

9.0.0-beta.5

9 months ago

9.0.0-beta.4

9 months ago

9.0.0-beta.3

9 months ago

9.0.0-beta.2

9 months ago

9.0.0-beta.1

9 months ago

9.0.0-beta.9

8 months ago

9.0.0-beta.8

8 months ago

9.0.0-beta.7

8 months ago

9.0.0-beta.6

8 months ago

8.2.1

8 months ago

8.2.0

8 months ago

9.0.2

6 months ago

9.0.1

7 months ago

9.0.0-beta.15

7 months ago

9.0.0-beta.16

7 months ago

9.0.0-beta.13

8 months ago

9.0.0-beta.14

8 months ago

9.0.0-beta.11

8 months ago

9.0.0-beta.12

8 months ago

9.0.0-beta.10

8 months ago

8.1.0

11 months ago

7.3.5

1 year ago

7.3.4

1 year ago

8.0.0

1 year ago

7.3.3

1 year ago

7.3.2

1 year ago

7.3.1

1 year ago

7.3.0

1 year ago

7.2.6

1 year ago

7.2.7

1 year ago

7.1.3

2 years ago

7.2.5

1 year ago

7.2.4

2 years ago

7.1.4

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.0.0

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.2

2 years ago

5.1.0

2 years ago

4.2.0

2 years ago

5.0.0

2 years ago

4.0.0

2 years ago

4.1.0

2 years ago

3.0.0

2 years ago

2.6.1

3 years ago

2.6.2

3 years ago

2.6.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0-pre.1

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.6.5

4 years ago

0.7.1

4 years ago

0.7.0-beta.2

4 years ago

0.7.0

4 years ago

0.7.0-beta.1

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.4.5

4 years ago

0.5.4

4 years ago

0.4.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.5.0-beta.3

4 years ago

0.5.0-beta.1

4 years ago

0.5.0-beta.2

4 years ago

0.4.1

4 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.1-test.2

5 years ago

0.0.1-test.1

5 years ago