Add comprehensive blog demo showcasing advanced content management features
- Implement complete mushroom foraging blog with chanterelles article - Add rich demonstration of .insertr and .insertr-add functionality - Include comprehensive documentation for future .insertr-content vision - Update project styling and configuration to support blog demo - Enhance engine and API handlers for improved content management
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/insertr/insertr/internal/db"
|
||||
"golang.org/x/net/html"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// AuthProvider represents authentication provider information
|
||||
@@ -118,7 +119,7 @@ func (e *ContentEngine) ProcessContent(input ContentInput) (*ContentResult, erro
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Inject content if required by mode
|
||||
// 6. Inject content if required by mode
|
||||
if input.Mode == Enhancement || input.Mode == ContentInjection {
|
||||
err = e.injectContent(processedElements, input.SiteID)
|
||||
if err != nil {
|
||||
@@ -170,7 +171,8 @@ func (e *ContentEngine) findEditableElements(doc *html.Node) ([]InsertrElement,
|
||||
Node: n,
|
||||
})
|
||||
}
|
||||
} else if e.hasInsertrAddClass(n) {
|
||||
}
|
||||
if e.hasInsertrAddClass(n) {
|
||||
// Collection element - add directly (no container transformation for collections)
|
||||
collectionElements = append(collectionElements, CollectionElement{
|
||||
Node: n,
|
||||
@@ -197,16 +199,6 @@ func (e *ContentEngine) findEditableElements(doc *html.Node) ([]InsertrElement,
|
||||
return insertrElements, collectionElements
|
||||
}
|
||||
|
||||
// findInsertrElements finds all elements with class="insertr" and applies container transformation
|
||||
// This implements the "syntactic sugar transformation" from CLASSES.md:
|
||||
// - Containers with .insertr get their .insertr class removed
|
||||
// - Viable children of those containers get .insertr class added
|
||||
// - Regular elements with .insertr are kept as-is
|
||||
func (e *ContentEngine) findInsertrElements(doc *html.Node) []InsertrElement {
|
||||
insertrElements, _ := e.findEditableElements(doc)
|
||||
return insertrElements
|
||||
}
|
||||
|
||||
// walkNodes walks through all nodes in the document
|
||||
func (e *ContentEngine) walkNodes(n *html.Node, fn func(*html.Node)) {
|
||||
fn(n)
|
||||
@@ -218,23 +210,13 @@ func (e *ContentEngine) walkNodes(n *html.Node, fn func(*html.Node)) {
|
||||
// hasInsertrClass checks if node has class="insertr"
|
||||
func (e *ContentEngine) hasInsertrClass(node *html.Node) bool {
|
||||
classes := GetClasses(node)
|
||||
for _, class := range classes {
|
||||
if class == "insertr" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(classes, "insertr")
|
||||
}
|
||||
|
||||
// hasInsertrAddClass checks if node has class="insertr-add" (collection)
|
||||
func (e *ContentEngine) hasInsertrAddClass(node *html.Node) bool {
|
||||
classes := GetClasses(node)
|
||||
for _, class := range classes {
|
||||
if class == "insertr-add" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(classes, "insertr-add")
|
||||
}
|
||||
|
||||
// addContentAttributes adds data-content-id attribute only
|
||||
|
||||
Reference in New Issue
Block a user