Skip to content

Commit

Permalink
feat: index pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Ellison committed Aug 25, 2023
1 parent 3dc1fbb commit d92e309
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/hooks/usePageContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ function deepMergeObj(target, source) {

function mergeObjects(obj1, obj2) {

// console.debug('mergeObjects:obj1', obj1)

// console.debug('mergeObjects:obj2', obj2)

// Extract the directory from the URL
Expand All @@ -447,13 +449,13 @@ function mergeObjects(obj1, obj2) {
// Iterate over each category
Object.keys(obj2[directory]).forEach(category => {
// If category does not exist in obj1, create it
if (!obj1.children[category]) {
if (obj1.children && !obj1.children[category]) {
obj1.children[category] = [];
}

obj2[directory][category].forEach(item => {
// Check if URL exists in obj1's category array
if (!obj1.children[category].some(e => e.url === item.url)) {
if ( obj1.children && !obj1.children[category].some(e => e.url === item.url)) {
obj1.children[category].push(item);
}
});
Expand Down

0 comments on commit d92e309

Please sign in to comment.