Skip to content

Commit

Permalink
Add page data to navigation entries
Browse files Browse the repository at this point in the history
  • Loading branch information
noelleleigh committed May 7, 2022
1 parent 2509dc6 commit bec5132
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eleventy-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ function findNavigationEntries(nodes = [], key = "") {
if(entry.data && entry.data.eleventyNavigation) {
let nav = entry.data.eleventyNavigation;
if(!key && !nav.parent || nav.parent === key) {
// Extract the page data without the eleventyNavigation key
const {eleventyNavigation, ...pageDataWithoutNav} = entry.data
pages.push(Object.assign({}, nav, {
url: nav.url || entry.data.page.url,
pluginType: "eleventy-navigation"
}, key ? { parentKey: key } : {}));
}, key ? { parentKey: key } : {},
{ data: pageDataWithoutNav }));
}
}
}
Expand Down

0 comments on commit bec5132

Please sign in to comment.