Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit b0b40f5

Browse files
authored
v3 (#14)
1 parent c6ac596 commit b0b40f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4722
-6842
lines changed

.changeset/stale-worms-drive.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"gatsby-source-tmdb": major
3+
---
4+
5+
**Description:**
6+
7+
Hello!
8+
9+
With https://github.com/LekoArts/gatsby-source-tmdb/pull/14 merged a new `v3` of `gatsby-source-tmdb` is out.
10+
11+
**Key highlights** of this release:
12+
13+
- Full compatibility with Gatsby 4
14+
- Improved error handling
15+
- Ability to download images specific to an endpoint
16+
17+
**Breaking Changes:**
18+
19+
- By default no images are downloaded anymore and you'll have to specifically opt-in to that. The shape (`localFile` on e.g. `poster_path`) stayed the same but you'll need to either enable image downloading globally or individually for each endpoint
20+
21+
You can read a migration guide here: https://github.com/LekoArts/gatsby-source-tmdb/blob/main/MIGRATING.md

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ module.exports = {
8585
"react/jsx-fragments": 0,
8686
"react/jsx-curly-brace-presence": 0,
8787
"react/jsx-pascal-case": 0,
88+
"react/function-component-definition": 0,
89+
"react/jsx-no-useless-fragment": 0,
8890
"react/jsx-filename-extension": [
8991
1,
9092
{

.github/actions/publish-starter/Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/actions/publish-starter/entrypoint.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/publish-starter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
with:
1313
node-version: '12'
1414
- name: Publish Starter
15-
uses: ./.github/actions/publish-starter
15+
uses: LekoArts/actions-push-subdirectories@master
1616
env:
1717
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
1818
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,16 @@ jobs:
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
- name: Wait for NPM package propagation
42+
if: steps.changesets.outputs.published == 'true'
43+
uses: kibertoad/wait-action@1.0.1
44+
with:
45+
time: "30s"
46+
- name: Publish Starters
47+
if: steps.changesets.outputs.published == 'true'
48+
uses: LekoArts/actions-push-subdirectories@master
49+
env:
50+
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
with:
53+
args: example LekoArts starter-name main

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.13.0

MIGRATING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,83 @@
22

33
If you want to update to a new major version of `gatsby-source-tmdb`, follow the steps below. Please note that once a new major version is out support for the old version has ended (only critical security fixes will be backported).
44

5+
## Migrating from v2 to v3
6+
7+
This major update makes `gatsby-source-tmdb` compatible with Gatsby 4! With Gatsby 4 some larger underlying changes were made to Gatsby and new features like Deferred Static Generation, Server Side Rendering, and Parallel Query Running were released. In order to support all these new features `gatsby-source-tmdb` needed to go through some changes. You can find the PR here: https://github.com/LekoArts/gatsby-source-tmdb/pull/14
8+
9+
If you want to start with a fresh project you can clone [gatsby-starter-tmdb](https://github.com/LekoArts/gatsby-starter-tmdb).
10+
11+
### Updating your dependencies
12+
13+
You need to update your `package.json` to use the latest version of `gatsby-source-tmdb`.
14+
15+
```json
16+
{
17+
"dependencies": {
18+
"gatsby-source-tmdb": "^3.0.0"
19+
}
20+
}
21+
```
22+
23+
### Update Gatsby packages
24+
25+
This plugin also now requires you to use Gatsby 4 (see [Gatsby's migration guide](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v3-to-v4/)). Update Gatsby and all related packages.
26+
27+
### Handle image downloading
28+
29+
In `gatsby-source-tmdb` v2 you were able to query `localFile` on any `backdrop_path`, `poster_path` etc. field. In v3 of this plugin you'll still be able to do that, but you have to explicitly opt-in to the download of the images now. Under the hood the plugin had to change the lazy-downloading to download everything upfront.
30+
31+
Your easiest solution to restore the old behavior is to set `downloadImages: true` globally for the plugin:
32+
33+
```diff
34+
require("dotenv").config()
35+
36+
module.exports = {
37+
plugins: [
38+
{
39+
resolve: "gatsby-source-tmdb",
40+
options: {
41+
apiKey: process.env.API_KEY,
42+
sessionID: process.env.SESSION_ID,
43+
+ downloadImages: true,
44+
}
45+
}
46+
]
47+
}
48+
```
49+
50+
But please note that this will download **all** images for every node & endpoint you have. The amount of images and the time it takes to download & process them might be huge. Instead, you better set the option on an individual level for each endpoint where you want to use e.g. `gatsby-plugin-image`:
51+
52+
```diff
53+
require("dotenv").config()
54+
55+
module.exports = {
56+
plugins: [
57+
{
58+
resolve: "gatsby-source-tmdb",
59+
options: {
60+
apiKey: process.env.API_KEY,
61+
sessionID: process.env.SESSION_ID,
62+
endpoints: [
63+
{
64+
url: "tv/:tv_id",
65+
+ downloadImages: true,
66+
context: {
67+
tv_id: "66732"
68+
},
69+
searchParams: {
70+
append_to_response: "videos,similar"
71+
}
72+
},
73+
]
74+
}
75+
}
76+
]
77+
}
78+
```
79+
80+
In this setup you'll only be able to use `localFile` on the specified endpoint and its fields.
81+
582
## Migrating from v1 to v2
683

784
The major update from v1 to v2 was a complete overhaul of the plugin (you can find the PR here: https://github.com/LekoArts/gatsby-source-tmdb/pull/9). The codebase was moved to TS, the implementation of custom API endpoints was redone, and underlying libraries were replaced. Thus some breaking changes were necessary to allow for these new features.

example/gatsby-config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ module.exports = {
77
siteUrl: process.env.URL || `https://tmdb.lekoarts.de`,
88
logo: `/logo.png`,
99
},
10-
flags: {
11-
DEV_SSR: false,
12-
FAST_DEV: true,
13-
},
1410
plugins: [
1511
{
1612
resolve: `gatsby-source-tmdb`,
@@ -22,6 +18,7 @@ module.exports = {
2218
endpoints: [
2319
{
2420
url: `account/:account_id/lists`,
21+
downloadImages: true,
2522
extension: {
2623
url: `list/:list_id`,
2724
},
@@ -34,6 +31,7 @@ module.exports = {
3431
},
3532
{
3633
url: `account/:account_id/favorite/tv`,
34+
downloadImages: true,
3735
extension: {
3836
url: `tv/:tv_id`,
3937
},

example/gatsby-node.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ exports.onCreateBabelConfig = ({ actions }) => {
66
})
77
}
88

9-
exports.onCreateWebpackConfig = ({ actions, stage }) => {
10-
if (stage === `develop` || stage === `build-javascript`) {
11-
actions.setWebpackConfig({
12-
plugins: [new VanillaExtractPlugin()],
13-
})
14-
}
9+
exports.onCreateWebpackConfig = ({ actions }) => {
10+
actions.setWebpackConfig({
11+
plugins: [new VanillaExtractPlugin()],
12+
})
1513
}

example/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
"license": "MIT",
66
"starter-name": "gatsby-starter-tmdb",
77
"dependencies": {
8-
"@vanilla-extract/babel-plugin": "^1.0.0",
9-
"@vanilla-extract/css": "^1.0.0",
10-
"@vanilla-extract/webpack-plugin": "^1.0.1",
11-
"date-fns": "^2.22.1",
12-
"gatsby": "^3.7.0",
13-
"gatsby-plugin-gatsby-cloud": "^2.7.0",
14-
"gatsby-plugin-image": "^1.7.0",
8+
"@vanilla-extract/babel-plugin": "^1.1.3",
9+
"@vanilla-extract/css": "^1.6.8",
10+
"@vanilla-extract/webpack-plugin": "^2.1.4",
11+
"date-fns": "^2.27.0",
12+
"gatsby": "^4.4.0",
13+
"gatsby-plugin-gatsby-cloud": "^4.4.0",
14+
"gatsby-plugin-image": "^2.4.0",
1515
"gatsby-plugin-react-helmet-async": "^1.2.0",
16-
"gatsby-plugin-sharp": "^3.7.0",
16+
"gatsby-plugin-sharp": "^4.4.0",
1717
"gatsby-source-tmdb": "^2.0.0",
18-
"gatsby-transformer-sharp": "^3.7.0",
18+
"gatsby-transformer-sharp": "^4.4.0",
1919
"node-fetch": "^2.6.1",
2020
"react": "^17.0.2",
21-
"react-content-loader": "^6.0.3",
21+
"react-content-loader": "^6.1.0",
2222
"react-dom": "^17.0.2",
23-
"react-helmet-async": "^1.0.9",
24-
"react-query": "^3.16.1",
25-
"react-spring": "^9.2.2",
26-
"react-tabs": "^3.2.2"
23+
"react-helmet-async": "^1.2.2",
24+
"react-query": "^3.34.5",
25+
"react-spring": "^9.3.2",
26+
"react-tabs": "^3.2.3"
2727
},
2828
"scripts": {
2929
"develop": "gatsby develop",

0 commit comments

Comments
 (0)