diff --git a/HackerTube/Features/Search/SearchSuggestion.swift b/HackerTube/Features/Search/SearchSuggestion.swift index 659b7c7..63ee50b 100644 --- a/HackerTube/Features/Search/SearchSuggestion.swift +++ b/HackerTube/Features/Search/SearchSuggestion.swift @@ -13,28 +13,13 @@ struct SearchSuggestion: Identifiable { } extension SearchSuggestion { - static let defaultSuggestions: [SearchSuggestion] = [ - "Freedom", "Linux", "Ethics", "Internet of Things", - "Security", "Lightning talks", "Climate", "Cryptography", "Encryption", - "Internet", "Software", "Hardware", "Cloud", "Networking", - "Privacy", "Mental health", "Accessibility", - "Artificial intelligence", "AI", "Machine learning", "Neural networks", "Language models", - "Electronics", "Robotics", "Quantum computing", "Microcontroller", - "Python", "Rust", - "Science", "Chemistry", "Math", "Physics", "Biology", "Biohacking", "DNA", "Biometrics", - "Information theory", "Communication", "GPS", - "The ultimate talk", "Radio communications", "Badge", - "Blockchain", "Cryptocurrency", - "Digital forensics", - "Drones", "Autonomous vehicles", "Smart cities", - "Cybersecurity", "Digital rights", "Ethical hacking", "Data Science", - "Internet governance", "Hacktivism", - "Open source", "Free software", - "Malware analysis", "Data protection", "Forensics", "Social engineering", - "Network security", - "Virtual reality (VR)", "Augmented reality (AR)", "Wearable tech", - "Penetration testing", "Bug bounties", "Reverse engineering", - "Dark web", "Anonymity", - "4G", "5G", "Cellular", - ].map(SearchSuggestion.init) + static let defaultSuggestions: [SearchSuggestion] = { + guard let url = Bundle.main.url(forResource: "SearchSuggestions", withExtension: "json5"), + let data = try? Data(contentsOf: url) + else { return [] } + let decoder = JSONDecoder() + decoder.allowsJSON5 = true + guard let titles = try? decoder.decode([String].self, from: data) else { return [] } + return titles.map(SearchSuggestion.init) + }() } diff --git a/HackerTube/Features/Search/SearchSuggestions.json5 b/HackerTube/Features/Search/SearchSuggestions.json5 new file mode 100644 index 0000000..d1b0abb --- /dev/null +++ b/HackerTube/Features/Search/SearchSuggestions.json5 @@ -0,0 +1,51 @@ +[ + // Hacking & security + "Security", "Cybersecurity", "Ethical hacking", "Penetration testing", + "Cryptography", "Encryption", "Post-quantum cryptography", + "Privacy", "Anonymity", "Data protection", "Surveillance", "Spyware", + "Malware analysis", "Digital forensics", "Social engineering", + "Reverse engineering", "Fuzzing", "Side-channel attacks", + "Certificate transparency", "Passkeys", "WebAuthn", + "Secure boot", "Bootloader", "CTF", + + // Systems & infrastructure + "Linux", "NixOS", "Containers", "Kubernetes", + "Cloud", "Self-hosting", "Internet", "Networking", + "IPv6", "BGP", "DNS", "DNSSEC", "eBPF", "VPN", + "4G", "5G", "Cellular", "LoRa", + + // AI & data + "Artificial intelligence", "AI", "Machine learning", "Neural networks", + "Language models", "Large language models", "RAG", "AI agents", + "Data Science", + + // Hardware & making + "Electronics", "Hardware", "Microcontroller", "FPGA", "Embedded systems", + "ESP32", "Raspberry Pi", "3D printing", "Laser", + "Robotics", "Drones", "Autonomous vehicles", + "Wearable tech", "Virtual reality (VR)", "Augmented reality (AR)", + "Quantum computing", "Amateur radio", "Internet of Things", + + // Programming + "Software", "Open source", "Free software", + "Python", "Rust", "Go", "Haskell", + + // Communications & protocols + "Matrix", "Fediverse", "Signal", "Meshtastic", "Meshcore", + "End-to-end encryption", "Federated", "Decentralized", + + // Society, politics & law + "Freedom", "Ethics", "Digital sovereignty", "Digital rights", + "Internet governance", "Hacktivism", "Elections", + "Chat control", "E-voting", "Surveillance capitalism", + "Climate", "Mental health", "Accessibility", + + // Science & space + "Science", "Chemistry", "Math", "Physics", "Biology", + "Biohacking", "DNA", "Biometrics", + "Information theory", "GPS", "Satellites", + + // Community & culture + "Lightning talks", "The ultimate talk", "Badge", "Radio communications", + "OpenStreetMap", "Game development", "Godot", "Infrastructure review" +] diff --git a/HackerTube/Features/Search/SearchView.swift b/HackerTube/Features/Search/SearchView.swift index 146cae8..eee8094 100644 --- a/HackerTube/Features/Search/SearchView.swift +++ b/HackerTube/Features/Search/SearchView.swift @@ -14,7 +14,7 @@ struct SearchView: View { @State var query = "" @State var isLoading = false @State var error: Error? - @State var suggestions: [SearchSuggestion] = SearchSuggestion.defaultSuggestions.shuffled() + @State var suggestions = SearchSuggestion.defaultSuggestions.shuffled().prefix(15) @Environment(ApiService.self) var api var body: some View {