Skip to content

Commit

Permalink
fix: test slate blocks content
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Apr 10, 2024
1 parent cf07f66 commit 22a1e39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const MegaMenu = ({ item, pathname }) => {
} else {
//megamenu
let hasBlocks = hasBlocksData(item);

console.log(hasBlocks, item);
if (item?.blocks && Object.keys(item.blocks).length === 1) {
let b = item.blocks[Object.keys(item.blocks)[0]];

Expand All @@ -153,6 +153,11 @@ const MegaMenu = ({ item, pathname }) => {
}
}
}
if (b['@type'] === 'slate') {
if (b.plaintext?.length === 0) {
hasBlocks = false;
}
}
}

const childrenGroups = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const fieldDataToPlainText = (field) => {
if (index > 0) accumulator += ' ';
accumulator += field.blocks[item].text?.blocks[0].text ?? '';
}
if (field.blocks[item]['@type'] === 'slate') {
if (index > 0) accumulator += ' ';
accumulator += field.blocks[item].plaintext ?? '';
}
return accumulator;
}, '');
};
Expand Down

0 comments on commit 22a1e39

Please sign in to comment.