[dyad] Improve headline validation - wrote 1 file(s)
This commit is contained in:
@@ -71,15 +71,21 @@ const HeadlineNodeDisplay = ({
|
|||||||
node.level === 2 && node.children && node.children.length > 0;
|
node.level === 2 && node.children && node.children.length > 0;
|
||||||
const isCollapsed = collapsedStates[path];
|
const isCollapsed = collapsedStates[path];
|
||||||
|
|
||||||
const levelSkipped = parentLevel > 0 && node.level > parentLevel + 1;
|
const levelSkipped =
|
||||||
|
(parentLevel === 0 && node.level > 1) ||
|
||||||
|
(parentLevel > 0 && node.level > parentLevel + 1);
|
||||||
const hasError = isDuplicateH1 || levelSkipped;
|
const hasError = isDuplicateH1 || levelSkipped;
|
||||||
|
|
||||||
let errorTooltip: string | null = null;
|
let errorTooltip: string | null = null;
|
||||||
if (isDuplicateH1) {
|
if (isDuplicateH1) {
|
||||||
errorTooltip = "Duplicate H1 tag. Only one H1 is recommended per page.";
|
errorTooltip = "Duplicate H1 tag. Only one H1 is recommended per page.";
|
||||||
} else if (levelSkipped) {
|
} else if (levelSkipped) {
|
||||||
|
if (parentLevel === 0) {
|
||||||
|
errorTooltip = `Incorrect hierarchy. The structure should start with an H1, not an H${node.level}.`;
|
||||||
|
} else {
|
||||||
errorTooltip = `Incorrect hierarchy. An H${node.level} should not directly follow an H${parentLevel}.`;
|
errorTooltip = `Incorrect hierarchy. An H${node.level} should not directly follow an H${parentLevel}.`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user