Skip to content

Commit b398215

Browse files
MoocarKyleAMathews
authored andcommitted
loader getPage -> loadPageSync (#14264)
1 parent f4f506c commit b398215

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

packages/gatsby/cache-dir/api-runner-browser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const {
44
getResourcesForPathnameSync,
55
getResourceURLsForPathname,
66
loadPage,
7-
getPage,
7+
loadPageSync,
88
} = require(`./loader`).publicLoader
99

1010
exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => {
@@ -24,14 +24,14 @@ exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => {
2424
return undefined
2525
}
2626

27-
// Deprecated April 2019. Use `getPage` instead
27+
// Deprecated April 2019. Use `loadPageSync` instead
2828
args.getResourcesForPathnameSync = getResourcesForPathnameSync
2929
// Deprecated April 2019. Use `loadPage` instead
3030
args.getResourcesForPathname = getResourcesForPathname
3131
// Deprecated April 2019. Use resources passed in `onPostPrefetch` instead
3232
args.getResourceURLsForPathname = getResourceURLsForPathname
3333
args.loadPage = loadPage
34-
args.getPage = getPage
34+
args.loadPageSync = loadPageSync
3535

3636
const result = plugin.plugin[api](args, plugin.options)
3737
if (result && argTransform) {

packages/gatsby/cache-dir/ensure-resources.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EnsureResources extends React.Component {
1717

1818
this.state = {
1919
location: { ...location },
20-
pageResources: loader.getPageOr404(location.pathname),
20+
pageResources: loader.loadPageOr404Sync(location.pathname),
2121
}
2222
}
2323

@@ -34,7 +34,7 @@ class EnsureResources extends React.Component {
3434

3535
static getDerivedStateFromProps({ location }, prevState) {
3636
if (prevState.location !== location) {
37-
const pageResources = loader.getPageOr404(location.pathname)
37+
const pageResources = loader.loadPageOr404Sync(location.pathname)
3838

3939
return {
4040
pageResources,
@@ -60,7 +60,7 @@ class EnsureResources extends React.Component {
6060
retryResources(nextProps) {
6161
const { pathname } = nextProps.location
6262

63-
if (!loader.getPage(pathname)) {
63+
if (!loader.loadPageSync(pathname)) {
6464
// Store the previous and next location before resolving resources
6565
const prevLocation = this.props.location
6666
this.nextLocation = nextProps.location

packages/gatsby/cache-dir/loader.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,18 @@ const queue = {
330330
.loadPage(rawPath)
331331
.then(result =>
332332
result === null && rawPath !== `/404.html`
333-
? queue.getPage(`/404.html`)
333+
? queue.loadPageSync(`/404.html`)
334334
: null
335335
),
336336

337-
getPage: rawPath => pathScriptsCache[cleanAndFindPath(rawPath)],
337+
loadPageSync: rawPath => pathScriptsCache[cleanAndFindPath(rawPath)],
338338

339-
getPageOr404: rawPath => {
340-
const page = queue.getPage(rawPath)
339+
loadPageOr404Sync: rawPath => {
340+
const page = queue.loadPageSync(rawPath)
341341
if (page) {
342342
return page
343343
} else if (rawPath !== `/404.html`) {
344-
return queue.getPage(`/404.html`)
344+
return queue.loadPageSync(`/404.html`)
345345
} else {
346346
return null
347347
}
@@ -352,7 +352,7 @@ const queue = {
352352
// already loaded into the browser by the time this function is
353353
// called. Use the resource URLs passed in `onPostPrefetch` instead.
354354
getResourceURLsForPathname: path => {
355-
const pageData = queue.getPage(path)
355+
const pageData = queue.loadPageSync(path)
356356
if (pageData) {
357357
return createComponentUrls(pageData.componentChunkName)
358358
} else {
@@ -382,9 +382,9 @@ export const publicLoader = {
382382
},
383383
getResourcesForPathnameSync: rawPath => {
384384
console.warn(
385-
`Warning: getResourcesForPathnameSync is deprecated. Use getPage instead`
385+
`Warning: getResourcesForPathnameSync is deprecated. Use loadPageSync instead`
386386
)
387-
return queue.getPage(rawPath)
387+
return queue.loadPageSync(rawPath)
388388
},
389389
getResourceURLsForPathname: pathname => {
390390
console.warn(
@@ -395,8 +395,8 @@ export const publicLoader = {
395395

396396
// Real methods
397397
loadPage: queue.loadPage,
398-
getPage: queue.getPage,
399-
getPageOr404: queue.getPageOr404,
398+
loadPageSync: queue.loadPageSync,
399+
loadPageOr404Sync: queue.loadPageOr404Sync,
400400
}
401401

402402
export default queue

packages/gatsby/cache-dir/navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function maybeRedirect(pathname) {
1818

1919
if (redirect != null) {
2020
if (process.env.NODE_ENV !== `production`) {
21-
const pageResources = loader.getPage(pathname)
21+
const pageResources = loader.loadPageSync(pathname)
2222

2323
if (pageResources != null) {
2424
console.error(

packages/gatsby/cache-dir/public-page-renderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import loader from "./loader"
55
import JSONStore from "./json-store"
66

77
const DevPageRenderer = ({ location }) => {
8-
const pageResources = loader.getPage(location.pathname)
8+
const pageResources = loader.loadPageSync(location.pathname)
99
return React.createElement(JSONStore, {
1010
location,
1111
pageResources,

packages/gatsby/cache-dir/public-page-renderer-prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import InternalPageRenderer from "./page-renderer"
55
import loader from "./loader"
66

77
const ProdPageRenderer = ({ location }) => {
8-
const pageResources = loader.getPageOr404(location.pathname)
8+
const pageResources = loader.loadPageOr404Sync(location.pathname)
99
if (!pageResources) {
1010
return null
1111
}

packages/gatsby/cache-dir/root.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class RouteHandler extends React.Component {
5454
)
5555
}
5656

57-
const dev404PageResources = loader.getPage(`/dev-404-page`)
58-
const real404PageResources = loader.getPage(`/404.html`)
57+
const dev404PageResources = loader.loadPageSync(`/dev-404-page`)
58+
const real404PageResources = loader.loadPageSync(`/404.html`)
5959
let custom404
6060
if (real404PageResources) {
6161
custom404 = (

0 commit comments

Comments
 (0)