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

@@ -132,7 +132,7 @@ func (p *Parser) createElement(node *html.Node, filePath string, classes []strin
// Resolve content ID (existing or generated)
contentID, hasExistingID := p.resolveContentID(node)
if !hasExistingID {
contentID = p.idGenerator.Generate(node)
contentID = p.idGenerator.Generate(node, filePath)
}
// Detect content type