Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): image fixes (#29813) (#29886)
Browse files Browse the repository at this point in the history
Co-authored-by: Ward Peeters <ward@coding-tech.com>
(cherry picked from commit 28124dd)

Co-authored-by: Tyler Barnes <tyler@gatsbyjs.com>
Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
  • Loading branch information
3 people authored Mar 1, 2021
1 parent 85bb8ea commit c8bf571
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const buildGatsbyNodeObjectResolver = ({ field, fieldName }) => async (
schema: { typePrefix: prefix },
} = getPluginOptions()

if (!existingNode.__typename.startsWith(prefix)) {
if (existingNode?.__typename && !existingNode.__typename.startsWith(prefix)) {
existingNode.__typename = buildTypeName(existingNode.__typename)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { isWebUri } = require(`valid-url`)
const Queue = require(`better-queue`)
const readChunk = require(`read-chunk`)
const fileType = require(`file-type`)
const { createProgress } = require(`gatsby-source-filesystem/utils`)

const { createFileNode } = require(`gatsby-source-filesystem/create-file-node`)
const {
Expand Down Expand Up @@ -431,7 +430,7 @@ module.exports = ({
}

if (totalJobs === 0) {
bar = createProgress(`Downloading remote files`, reporter)
bar = reporter.createProgress(`Downloading remote files`)
bar.start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export const errorPanicker = ({
)
)
reporter.panic(error)
} else {
console.error(error)
reporter.panic()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,11 @@ const replaceNodeHtmlLinks = ({ wpUrl, nodeString, node }) => {
const normalizedPath = path.replace(/\\/g, ``)

// replace normalized match with relative path
const thisMatchRegex = new RegExp(normalizedMatch, `g`)
const thisMatchRegex = new RegExp(
normalizedMatch + `(?!/?wp-content|/?wp-admin|/?wp-includes)`,
`g`
)

nodeString = nodeString.replace(thisMatchRegex, normalizedPath)
} catch (e) {
console.error(e)
Expand Down

0 comments on commit c8bf571

Please sign in to comment.