# Available methods

List of functions exposed by the instance.

API research

Functions getAllTags and getRelatedPosts executes research in the collection of articles get from the API according to the limitData option. The limit can be adjust to fit your need.

# init

  • Return: Promise<Object>

The function build the app and returns a promise. API dependents functions must be called when init function is ready.

tumblr.init().then(response => {
  // App is render and ready
});
1
2
3

Since init() returns a promise, you can achieve the same as the above using the new ES2017 async/await syntax:

const response = await tumblr.init();
1

The function exposes a response object with datas from the API including following fields.

# response.totalPosts

  • Type: Integer
  • Default: 0

The total of articles available on the Tumblr blog, according to the host option.

# response.posts

  • Type: Array<Object>
  • Default: []

List of articles datas returns by the app.

# response.tags

  • Type: Array
  • Default: []

List of all hashtags for all articles requested by the app.

# getAllTags API dependent

  • Return: Array

The function get the list of all hashtags from all available articles.

tumblr.getAllTags();
1

# getRelatedPosts API dependent

  • Return: Array

The function get related posts according to a specific post.

tumblr.getRelatedPosts({
  postId,
  tags,
  limit,
  ignoreTags
});
1
2
3
4
5
6

The function has an object parameter with following fields.

# postId

  • Type: String
  • Default: ''

Tells the function the id of the associated article.

# tags

  • Type: Array
  • Default: []

Tells the function the list of hashtags for the associated article.

# limit

  • Type: Integer
  • Default: 3

Tells the function the limit of results to return.

# ignoreTags

  • Type: Array
  • Default: []

Tells the function the list of hashtags to ignore for the research.

# getRoute

  • Return: String

The function get the current hash from the route.

tumblr.getRoute();
1

# getPageType

  • Return: String||null
  • Possible value: 'home' 'tagged' 'post' null

The function get the page type from the route.

tumblr.getPageType();
1

# getPostIdFromRoute

  • Return: String

The function get the post id from the route (/post/ route only).

tumblr.getPostIdFromRoute();
1

# getHashTagFromRoute

  • Return: String

The function get the hashtag from the route (/tagged/ route only).

tumblr.getHashTagFromRoute();
1