diff --git a/insertr.yaml b/insertr.yaml index 7df2f2b..3ce48f6 100644 --- a/insertr.yaml +++ b/insertr.yaml @@ -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" diff --git a/internal/engine/collection.go b/internal/engine/collection.go index 94dcaf7..a79fe74 100644 --- a/internal/engine/collection.go +++ b/internal/engine/collection.go @@ -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 {