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