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:
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user