Fix collection content injection regression introduced during engine refactoring

Restore missing content hydration logic in reconstructCollectionItems method that was accidentally removed during the engine file split (b46f643). Collection items were appearing empty instead of displaying original developer content. This fix restores the database-first behavior where content is properly extracted, stored, and injected back into .insertr elements within collection items.
This commit is contained in:
2025-10-26 21:45:03 +01:00
parent 448b66a974
commit 0bad96d866
2 changed files with 18 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ server:
- site_id: "blog"
path: "./demos/blog_enhanced"
source_path: "./demos/blog/"
auto_enhance: false
auto_enhance: true
- site_id: "default"
path: "./demos/default_enhanced"
source_path: "./demos/default"

View File

@@ -174,8 +174,23 @@ func (e *ContentEngine) reconstructCollectionItems(collectionNode *html.Node, co
structuralChild.Parent.RemoveChild(structuralChild)
}
// Add hydrated structural elements directly to collection (stored HTML has complete structure)
// The structural template already contains hydrated content from database
// RESTORED: Inject content into .insertr elements within collection items
// Walk through structural elements and hydrate with content from content table
e.walkNodes(structuralChild, func(n *html.Node) {
if n.Type == html.ElementNode && HasClass(n, "insertr") {
// Get content ID from data attribute
contentID := GetAttribute(n, "data-content-id")
if contentID != "" {
// Get actual content from database and inject it
contentItem, err := e.client.GetContent(context.Background(), siteID, contentID)
if err == nil && contentItem != nil {
// Use injector to hydrate content (unified .insertr approach)
e.injector.siteID = siteID
e.injector.injectHTMLContent(n, contentItem.HTMLContent)
}
}
}
})
// Inject data-item-id attribute for collection item identification
if structuralChild.Type == html.ElementNode {