Skip to content

Commit

Permalink
Get WordPress Menu's Items (gatsbyjs#2535)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienfi authored and KyleAMathews committed Oct 19, 2017
1 parent 1fd2a02 commit 5f8edc6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/gatsby-source-wordpress/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,23 @@ async function fetchData({
routeResponse.__type = type
entities.push(routeResponse)
}

// WordPress exposes the menu items in meta links.
if (type == `wordpress__wp_api_menus_menus`) {
for (let menu of routeResponse) {
if (menu.meta && menu.meta.links && menu.meta.links.self) {
entities = entities.concat(
await fetchData({
route: { url: menu.meta.links.self, type: `${type}_items` },
_verbose,
_perPage,
_hostingWPCOM,
_auth,
_accessToken,
})
)
}
}
}
// TODO : Get the number of created nodes using the nodes in state.
let length
if (routeResponse && Array.isArray(routeResponse)) {
Expand Down

0 comments on commit 5f8edc6

Please sign in to comment.