Skip to content

Commit 5fd864c

Browse files
spicyfalafelclaude
andcommitted
fix: don't use h1 anchor in search result URLs
h1 represents the page itself, not a section. Text following h1 should link to the page without a #fragment. h2–h6 anchors are preserved as before. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49670d7 commit 5fd864c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/scraper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ export async function scrapePage(
258258
}
259259

260260
// Save anchor from heading for text content that follows
261-
lastHeadingAnchor = element.id || undefined;
261+
// lvl1 (h1) is the page itself, not a section — don't use its anchor
262+
lastHeadingAnchor = level >= 2 ? (element.id || undefined) : undefined;
262263
break;
263264
}
264265
}

0 commit comments

Comments
 (0)