feat: Implement syntactic sugar and site-specific discovery config
- Add syntactic sugar for container transformation: .insertr containers → children get .insertr - Fix discovery auto-running when disabled with site-specific config loading - Add comprehensive styling test examples for HTML attribute preservation - Include test input for syntactic sugar validation - Update discovery defaults to respect developer intent (disabled by default)
This commit is contained in:
@@ -13,11 +13,12 @@ import (
|
||||
|
||||
// SiteConfig represents configuration for a registered site
|
||||
type SiteConfig struct {
|
||||
SiteID string `yaml:"site_id"`
|
||||
Path string `yaml:"path"` // Served path (enhanced output)
|
||||
SourcePath string `yaml:"source_path"` // Source path (for enhancement)
|
||||
Domain string `yaml:"domain,omitempty"`
|
||||
AutoEnhance bool `yaml:"auto_enhance"`
|
||||
SiteID string `yaml:"site_id"`
|
||||
Path string `yaml:"path"` // Served path (enhanced output)
|
||||
SourcePath string `yaml:"source_path"` // Source path (for enhancement)
|
||||
Domain string `yaml:"domain,omitempty"`
|
||||
AutoEnhance bool `yaml:"auto_enhance"`
|
||||
Discovery *DiscoveryConfig `yaml:"discovery,omitempty"` // Override discovery settings
|
||||
}
|
||||
|
||||
// SiteManager handles registration and enhancement of static sites
|
||||
@@ -159,17 +160,27 @@ func (sm *SiteManager) EnhanceSite(siteID string) error {
|
||||
}
|
||||
|
||||
// Create enhancer with auth provider for this operation
|
||||
defaultConfig := EnhancementConfig{
|
||||
Discovery: DiscoveryConfig{
|
||||
Enabled: true,
|
||||
Aggressive: false,
|
||||
Containers: true,
|
||||
Individual: true,
|
||||
},
|
||||
// Discovery disabled by default - developers should explicitly mark elements with class="insertr"
|
||||
discoveryConfig := DiscoveryConfig{
|
||||
Enabled: false, // Changed from true - respect developer intent
|
||||
Aggressive: false,
|
||||
Containers: true,
|
||||
Individual: true,
|
||||
}
|
||||
|
||||
// Override with site-specific discovery config if provided
|
||||
if site.Discovery != nil {
|
||||
discoveryConfig = *site.Discovery
|
||||
log.Printf("🔧 Using site-specific discovery config for %s: enabled=%v, aggressive=%v",
|
||||
siteID, discoveryConfig.Enabled, discoveryConfig.Aggressive)
|
||||
}
|
||||
|
||||
config := EnhancementConfig{
|
||||
Discovery: discoveryConfig,
|
||||
ContentInjection: true,
|
||||
GenerateIDs: true,
|
||||
}
|
||||
enhancer := NewEnhancerWithAuth(sm.contentClient, siteID, defaultConfig, sm.authProvider)
|
||||
enhancer := NewEnhancerWithAuth(sm.contentClient, siteID, config, sm.authProvider)
|
||||
|
||||
// Perform enhancement from source to output
|
||||
if err := enhancer.EnhanceDirectory(sourcePath, outputPath); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user