package templates import "fmt" import "strings" import "sort" type IndexProps struct { Title string IsConfigured bool CurrentIP string Config ConfigData Records []DNSRecord UpdateFreqs []UpdateFrequency } type ConfigData struct { ZoneID string Domain string UpdatePeriod string ApiToken string } type DNSRecord struct { ID string Type string Name string Content string TTL int Proxied bool IsStatic bool CreatedOn string } type UpdateFrequency struct { Label string Value string } // Helper type for grouped records type IPGroup struct { IP string Records []DNSRecord } // Helper function to group records by IP func groupRecordsByIP(records []DNSRecord) []IPGroup { groupMap := make(map[string][]DNSRecord) for _, r := range records { groupMap[r.Content] = append(groupMap[r.Content], r) } // Stable order of groups ips := make([]string, 0, len(groupMap)) for ip := range groupMap { ips = append(ips, ip) } sort.Strings(ips) // Convert to slice of IPGroup result := make([]IPGroup, 0, len(ips)) for _, ip := range ips { result = append(result, IPGroup{ IP: ip, Records: groupMap[ip], }) } return result } templ Index(props IndexProps) { @Layout(props.Title) {
Please configure your Cloudflare API credentials to manage your DNS records.
Configure Now| Type | Name | Content | TTL | Proxied | Static | Actions |
|---|---|---|---|---|---|---|
| No DNS records found | ||||||
| { ipGroup.IP } { fmt.Sprintf("%d record(s)", len(ipGroup.Records)) } if ipGroup.IP == currentIP { Current IP } | ||||||