package main // getString extracts a string value from content map. func getString(content map[string]any, key string) string { if v, ok := content[key].(string); ok { return v } return "" } // getInt extracts an int value from content map (handles float64 from JSON). func getInt(content map[string]any, key string, defaultVal int) int { if v, ok := content[key].(float64); ok { return int(v) } if v, ok := content[key].(int); ok { return v } return defaultVal } // getBool extracts a bool from content (handles "true"/"false" strings). func getBool(content map[string]any, key string, defaultVal bool) bool { if v, ok := content[key].(bool); ok { return v } if v, ok := content[key].(string); ok { switch v { case "true", "TRUE", "True", "1", "yes", "on": return true case "false", "FALSE", "False", "0", "no", "off", "": return false } } return defaultVal } // getSlice extracts a slice of maps from content. func getSlice(content map[string]any, key string) []map[string]any { if v, ok := content[key].([]any); ok { result := make([]map[string]any, 0, len(v)) for _, item := range v { if m, ok := item.(map[string]any); ok { result = append(result, m) } } return result } return nil } // normalizeAccent maps the schema accent enum into a CSS class suffix. // Unknown values fall back to "pink" (the default-preset accent slot). func normalizeAccent(raw string) string { switch raw { case "pink", "blue", "lime": return raw default: return "pink" } } // normalizeSpan maps the photo-essay frame span enum. func normalizeSpan(raw string) string { switch raw { case "half", "full", "tall": return raw default: return "half" } }