feat: implement collision-free lightweight hierarchical ID generation

- Replace content-hash based ID generation with position-based algorithm
- Use file + element identity + position index + hash for unique IDs
- Generate human-readable prefixes (e.g. index-lead-, index-p-2-)
- Add collision-resistant hash suffixes for guaranteed uniqueness
- Update Generate() to accept filePath parameter for context
- Fix ID collisions where hero and footer elements shared same ID
- Clean demo site files removing all data-content-id attributes
- Preserve insertr-gate elements for authentication functionality

Results: Hero gets 'index-lead-2-fc31f2', footer gets 'index-p-13-99fd13'
No more content cross-contamination between different elements.
This commit is contained in:
2025-09-11 17:38:15 +02:00
parent cfb744f091
commit 72bd31b626
5 changed files with 132 additions and 167 deletions

View File

@@ -713,6 +713,7 @@ func (h *ContentHandler) generateContentID(ctx *ElementContext) string {
}
// Use existing parser ID generator
// For API-generated IDs, use a placeholder filePath since we don't have file context
idGenerator := parser.NewIDGenerator()
return idGenerator.Generate(virtualNode)
return idGenerator.Generate(virtualNode, "api-generated")
}