All Projects → LekoArts → Gatsby Source Tmdb

LekoArts / Gatsby Source Tmdb

Licence: mit
🎬 Source from TheMovieDB in Gatsby

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gatsby Source Tmdb

Gatsby Plugin Meta Redirect
Write Gatsby redirects to html files with a meta refresh
Stars: ✭ 18 (-64%)
Mutual labels:  gatsby
Gatsby Starter Spectral
Gatsby.js V2 starter template based on Spectral by HTML5 UP
Stars: ✭ 34 (-32%)
Mutual labels:  gatsby
Awesome Docs With Static Site Generators
Pointers to all templates and implementations based on static site generators
Stars: ✭ 44 (-12%)
Mutual labels:  gatsby
Blog
My blog created with React, Gatsby & Markdown
Stars: ✭ 29 (-42%)
Mutual labels:  gatsby
Elastic Graph Recommender
Building recommenders with Elastic Graph!
Stars: ✭ 33 (-34%)
Mutual labels:  tmdb
Website
The API Platform website
Stars: ✭ 38 (-24%)
Mutual labels:  gatsby
Themoviedb React
TMDb API with React.
Stars: ✭ 20 (-60%)
Mutual labels:  tmdb
Jamtemplates.com
Curated collection of free Gatsby themes.
Stars: ✭ 47 (-6%)
Mutual labels:  gatsby
Gatsby Starter Kontent Lumen
Lumen is a minimal, lightweight and mobile-first starter for creating blogs using Gatsby and Kentico Kontent.
Stars: ✭ 34 (-32%)
Mutual labels:  gatsby
Gatsby Starter Strict
A Gatsby starter with strict linting and auto-formatting rules.
Stars: ✭ 43 (-14%)
Mutual labels:  gatsby
Gatsby Remark Embed Gist
Gatsby remark gists preprocessor
Stars: ✭ 30 (-40%)
Mutual labels:  gatsby
Gatsby Pagination
Gatsby utility that generates pages with pagination
Stars: ✭ 33 (-34%)
Mutual labels:  gatsby
Ibaslogic
Dev Articles for the Self-Starter
Stars: ✭ 40 (-20%)
Mutual labels:  gatsby
Leo Blog
My 🏡 on the ☁️
Stars: ✭ 27 (-46%)
Mutual labels:  gatsby
Gatsby Embedder Excalidraw
🤴 Custom transformer to embed Excalidraw diagrams
Stars: ✭ 45 (-10%)
Mutual labels:  gatsby
Gatsby Starter Blog Grommet
A Gatsby v2 starter based on Grommet v2 UI. Demo:
Stars: ✭ 21 (-58%)
Mutual labels:  gatsby
Golang Tmdb
This is a Golang wrapper for working with TMDb API. It aims to support version 3.
Stars: ✭ 36 (-28%)
Mutual labels:  tmdb
Gatsby Starter Typescript Deluxe
A Gatsby starter with TypeScript, Storybook, Styled Components, Framer Motion, Jest, and more.
Stars: ✭ 50 (+0%)
Mutual labels:  gatsby
No.lol
🍩 Lauren's personal blog
Stars: ✭ 46 (-8%)
Mutual labels:  gatsby
Gatsby Source Instagram All
⚛️📸 Gatsby source plugin for fetching all your instagram posts
Stars: ✭ 42 (-16%)
Mutual labels:  gatsby

gatsby-source-tmdb

Source from The Movie Database (TMDb) API (v3) in Gatsby.

You can see a live example at tmdb.lekoarts.de (Source Code).

Built with moviedb-promise.


Install

npm install --save gatsby-source-tmdb

How to use

Prerequisites

First, you need a way to pass environment variables to the build process, so secrets and other secured data aren't committed to source control. I recommend using dotenv which will then expose environment variables. Read more about dotenv and using environment variables here. Then you can use these environment variables and configure your plugin.

You'll need an API Key and Session ID from TMDb.

  1. Create your API Key
  2. Create your Session ID
  3. Save both to your environment variable file

It should look something like this:

API_KEY=your-api-key-here
SESSION_ID=your-session-id-here

You can find all information on the API endpoints in the official The Movie Database API v3 documentation.

gatsby-config

Minimal

The plugin sets some defaults for the endpoints and options. Hence you can use it only with the two mandatory entries apiKey and sessionID. You can see the default values in the "All options" overview.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-tmdb',
      options: {
        // apiKey and sessionID are mandatory
        apiKey: process.env.API_KEY,
        sessionID: process.env.SESSION_ID,
      },
    },
  ],
}

All options

The plugin exposes some TMDb API options you can modify, e.g. language, region and timezone.

The modules option gives your control over the querying of data from the TMDb API. The names are the function names of moviedb-promise. By default all endpoints (which make sense) are inserted into the arrays. Note: Therefore the modules option can be used to minimize the data requested.

The following gatsby-config shows all available options with their default values.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-tmdb',
      options: {
        // apiKey and sessionID are mandatory

        apiKey: process.env.API_KEY,
        sessionID: process.env.SESSION_ID,

        // Pass a ISO 639-1 value. Pattern: ([a-z]{2})-([A-Z]{2})
        // Specify the language of titles, descriptions etc.
        // Applied to all results

        language: 'en-US',

        // Specify a ISO 3166-1 code. Pattern: [A-Z]{2}
        // Will narrow the search to only display results within the specified country

        region: 'US',

        // You can specify what modules to use and which endpoints to grab data from
        // If you want to use the default endpoints but deactivate modules,
        // set the value of "activate" to true or false.

        modules: {
          account: {
            activate: true,
            endpoints: {
              tvs: ['accountFavoriteTv', 'accountRatedTv', 'accountTvWatchlist'],
              movies: ['accountFavoriteMovies', 'accountRatedMovies', 'accountMovieWatchlist'],
              list: 'accountLists',
            },
          },
          misc: {
            activate: false,
            // The number behind the name specifies the amount of pages you want to pull
            // By default it's set to 3 pages as otherwise, e.g. the endpoint "MiscPopularMovies
            // would pull ~8000 pages (probably all movies)
            // Each page contains 20 items

            endpoints: [
              ['miscUpcomingMovies'],
              ['miscNowPlayingMovies'],
              ['miscPopularMovies', 2],
              ['miscTopRatedMovies', 2],
              ['miscTopRatedTvs', 1],
              ['miscPopularTvs', 1],
            ],
          },
          tv: {
            activate: false,
            endpoints: [['tvAiringToday'], ['tvOnTheAir', 2]],
          },
        },

        // Specify a timezone to offset the day calculation
        // e.g. used in tvAiringToday
        // See all timezones: https://developers.themoviedb.org/3/configuration/get-timezones

        timezone: 'Europe/London',

        // TMDb allows 40 Requests per 10 seconds
        // If you pull a lot of data you could have an error
        // telling you that you're over that limit. With this
        // option you can do less requests per 10 seconds

        reqPerTenSeconds: 36,

        // Decide whether you want to download images from
        // poster_path and backdrop_path URLs or not.
        // This can save you a lot of time if you're not using one/both
        // of them anyway

        poster: true,
        backdrop: false,
      },
    },
  ],
}

Examples

Example 1: You only want accountFavoriteTv

modules: {
  account: {
    activate: true,
    endpoints: {
      tvs: ['accountFavoriteTv'],
    },
  },
}

Example 2: You only want accountFavoriteTv, accountRatedMovies and accountMovieWatchlist

modules: {
  account: {
    activate: true,
    endpoints: {
      tvs: ['accountFavoriteTv'],
      movies: ['accountRatedMovies', 'accountMovieWatchlist'],
    },
  },
}

Example 3: You only want miscPopularMovies with 5 pages of results and miscUpcomingMovies with 3 pages of results (3 pages is the default)

5 pages x 20 result per page = 100 items

modules: {
  misc: {
    activate: true,
    endpoints: [
      ['miscUpcomingMovies'],
      ['miscPopularMovies', 5],
    ],
  },
}

Example 4: You only want accountFavoriteTv and tvAiringToday

modules: {
  account: {
    activate: true,
    endpoints: {
      tvs: ['accountFavoriteTv'],
    },
  },
  tv: {
    activate: true,
    endpoints: [['tvAiringToday']],
  },
}

Example 5: You don't want account but all endpoints from misc and tv

modules: {
  account: {
    activate: false,
  },
  misc: {
    activate: true,
  },
  tv: {
    activate: true,
  },
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].