diff --git a/packages/gatsby-source-wordpress/src/fetch.js b/packages/gatsby-source-wordpress/src/fetch.js index 6e249f6fb25a2..d3ac7fb27f428 100644 --- a/packages/gatsby-source-wordpress/src/fetch.js +++ b/packages/gatsby-source-wordpress/src/fetch.js @@ -71,19 +71,27 @@ Mama Route URL: ${url} password: _auth.htaccess_pass, } } - + if (_hostingWPCOM && _accessToken) { options.headers = { Authorization: `Bearer ${_accessToken}`, } } - + allRoutes = await axios(options) } catch (e) { httpExceptionHandler(e) } - let entities = [] + let entities = [ + { + __type: `wordpress__site_metadata`, + name: allRoutes.data.name, + description: allRoutes.data.description, + url: allRoutes.data.url, + home: allRoutes.data.home, + }, + ] if (allRoutes) { let validRoutes = getValidRoutes({ diff --git a/packages/gatsby-source-wordpress/src/normalize.js b/packages/gatsby-source-wordpress/src/normalize.js index 4292a8a993899..f96c033ff0ff1 100644 --- a/packages/gatsby-source-wordpress/src/normalize.js +++ b/packages/gatsby-source-wordpress/src/normalize.js @@ -165,9 +165,16 @@ exports.liftRenderedField = entities => }) // Exclude entities of unknown shape -// Assume all entities contain a wordpress_id, except for whitelisted type wp_settings +// Assume all entities contain a wordpress_id, +// except for whitelisted type wp_settings and the site_metadata exports.excludeUnknownEntities = entities => - entities.filter(e => e.wordpress_id || e.__type === `wordpress__wp_settings`) // Excluding entities without ID, or WP Settings + entities.filter( + e => + e.wordpress_id || + e.__type === `wordpress__wp_settings` || + e.__type === `wordpress__site_metadata` + ) +// Excluding entities without ID, or WP Settings // Create node ID from known entities // excludeUnknownEntities whitelisted types don't contain a wordpress_id