Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): Cannot read property of undefined error…
Browse files Browse the repository at this point in the history
… with polylang (#19331)

Fixes #19285
  • Loading branch information
maktouch authored and pieh committed Nov 7, 2019
1 parent 1c75e70 commit bd48b21
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/gatsby-source-wordpress/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,19 @@ exports.mapPolylangTranslations = entities =>
entities.map(entity => {
if (entity.polylang_translations) {
entity.polylang_translations___NODE = entity.polylang_translations.map(
translation =>
entities.find(
translation => {
const post = entities.find(
t =>
t.wordpress_id === translation.wordpress_id &&
entity.__type === t.__type
).id
)

if (!post) {
return null
}

return post.id
}
)

delete entity.polylang_translations
Expand Down

0 comments on commit bd48b21

Please sign in to comment.