Skip to content

Commit bf32fae

Browse files
committed
update code and tests from rebase
1 parent b493adb commit bf32fae

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

packages/gatsby-source-contentful/src/__tests__/gatsby-node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ describe(`gatsby-node`, () => {
607607
expect(getNode(blogEntry[`author___NODE`])).toBeTruthy()
608608
})
609609

610-
expect(actions.createNode).toHaveBeenCalledTimes(46)
610+
expect(actions.createNode).toHaveBeenCalledTimes(44)
611611
expect(actions.deleteNode).toHaveBeenCalledTimes(0)
612612
expect(actions.touchNode).toHaveBeenCalledTimes(32)
613613
expect(reporter.info.mock.calls).toMatchInlineSnapshot(`
@@ -697,7 +697,7 @@ describe(`gatsby-node`, () => {
697697
expect(getNode(blogEntry[`author___NODE`])).toBeTruthy()
698698
})
699699

700-
expect(actions.createNode).toHaveBeenCalledTimes(54)
700+
expect(actions.createNode).toHaveBeenCalledTimes(52)
701701
expect(actions.deleteNode).toHaveBeenCalledTimes(0)
702702
expect(actions.touchNode).toHaveBeenCalledTimes(72)
703703
expect(reporter.info.mock.calls).toMatchInlineSnapshot(`
@@ -850,7 +850,7 @@ describe(`gatsby-node`, () => {
850850
)
851851
})
852852

853-
expect(actions.createNode).toHaveBeenCalledTimes(52)
853+
expect(actions.createNode).toHaveBeenCalledTimes(48)
854854
expect(actions.deleteNode).toHaveBeenCalledTimes(2)
855855
expect(actions.touchNode).toHaveBeenCalledTimes(72)
856856
expect(reporter.info.mock.calls).toMatchInlineSnapshot(`
@@ -936,7 +936,7 @@ describe(`gatsby-node`, () => {
936936
locales
937937
)
938938

939-
expect(actions.createNode).toHaveBeenCalledTimes(54)
939+
expect(actions.createNode).toHaveBeenCalledTimes(48)
940940
expect(actions.deleteNode).toHaveBeenCalledTimes(2)
941941
expect(actions.touchNode).toHaveBeenCalledTimes(72)
942942
expect(reporter.info.mock.calls).toMatchInlineSnapshot(`

packages/gatsby-source-contentful/src/image-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ export function createUrl(imgUrl, options = {}) {
5252
}
5353
}
5454

55-
return `${imgUrl}?${searchParams.toString()}`
55+
return `https:${imgUrl}?${searchParams.toString()}`
5656
}

packages/gatsby-source-contentful/src/source-nodes.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,6 @@ export async function sourceNodes(
246246
})
247247

248248
const { deletedEntries, deletedAssets } = currentSyncData
249-
250-
const allDeletedNodes = [...deletedEntries, ...deletedAssets]
251-
const deletedNodeIds = []
252-
253-
locales.forEach(locale => {
254-
allDeletedNodes.forEach(n => {
255-
deletedNodeIds.push(
256-
makeId({
257-
spaceId: n.sys.space.sys.id,
258-
id: n.sys.id,
259-
type: n.sys.type,
260-
currentLocale: locale.code,
261-
defaultLocale,
262-
})
263-
)
264-
})
265-
})
266-
267249
const deletedEntryGatsbyReferenceIds = new Set()
268250

269251
function deleteContentfulNode(node) {
@@ -316,7 +298,7 @@ export async function sourceNodes(
316298
!deletedEntryGatsbyReferenceIds.has(n.id)
317299
)
318300
.forEach(n => {
319-
if (n.contentful_id && foreignReferenceMap[generateReferenceId(n)]) {
301+
if (n.sys.id && foreignReferenceMap[generateReferenceId(n)]) {
320302
foreignReferenceMap[generateReferenceId(n)].forEach(
321303
foreignReference => {
322304
const { name, id, type, spaceId } = foreignReference
@@ -326,7 +308,7 @@ export async function sourceNodes(
326308
spaceId,
327309
id,
328310
type,
329-
currentLocale: n.node_locale,
311+
currentLocale: n.sys.locale,
330312
defaultLocale,
331313
})
332314
)
@@ -348,7 +330,7 @@ export async function sourceNodes(
348330
}
349331

350332
// Remove references to deleted nodes
351-
if (n.contentful_id && deletedEntryGatsbyReferenceIds.size) {
333+
if (n.sys.id && deletedEntryGatsbyReferenceIds.size) {
352334
Object.keys(n).forEach(name => {
353335
// @todo Detect reference fields based on schema. Should be easier to achieve in the upcoming version.
354336
if (!name.endsWith(`___NODE`)) {
@@ -503,6 +485,7 @@ export async function sourceNodes(
503485
await createNode({
504486
id: createNodeId(`ContentfulTag__${space.sys.id}__${tag.sys.id}`),
505487
name: tag.name,
488+
// @todo update the structure of tags
506489
contentful_id: tag.sys.id,
507490
internal: {
508491
type: `ContentfulTag`,

0 commit comments

Comments
 (0)