diff --git a/doc/content/gateways/models/browan-minihub-pro/_index.md b/doc/content/gateways/models/browan-minihub-pro/_index.md index ca765512c9..660e3ec751 100644 --- a/doc/content/gateways/models/browan-minihub-pro/_index.md +++ b/doc/content/gateways/models/browan-minihub-pro/_index.md @@ -4,7 +4,7 @@ vendor: Browan vendor_page: "https://www.browan.com/product/minihub-pro/detail" description: "The Browan Minihub Pro is a low-cost LoRaWAN® gateway with a WiFi backhaul." ip_rating: -backhaul: ["Wi-Fi"] +backhaul: [Wi-Fi] weight: aliases: [/gateways/browan-minihub-pro] image: [minihub-pro.png] diff --git a/doc/content/gateways/models/ciscowirelessgateway/_index.md b/doc/content/gateways/models/ciscowirelessgateway/_index.md index 1c030828b0..d9baa0b796 100644 --- a/doc/content/gateways/models/ciscowirelessgateway/_index.md +++ b/doc/content/gateways/models/ciscowirelessgateway/_index.md @@ -4,7 +4,7 @@ vendor: "Cisco" vendor_page: "https://www.cisco.com/c/en/us/products/routers/wireless-gateway-lorawan/" description: "The Cisco LoRaWAN Gateway is carrier-grade solution suitable for users who have experience with Cisco software, and that are looking for an industrial-grade LoRaWAN gateway. It supports 16 channels, as well as geolocation." ip_rating: "IP67" -backhaul: ["Ethernet", "Wi-Fi (add-on)", "Cellular (add-on)"] +backhaul: [Ethernet, Wi-Fi (add-on), Cellular (add-on)] alias: [/gateways/ciscowirelessgateway] image: [cisco.png] --- diff --git a/doc/content/gateways/models/cloudgate/_index.md b/doc/content/gateways/models/cloudgate/_index.md index 9827065db6..6606b286d8 100644 --- a/doc/content/gateways/models/cloudgate/_index.md +++ b/doc/content/gateways/models/cloudgate/_index.md @@ -4,7 +4,7 @@ vendor: "Option" vendor_page: "https://www.option.com/products/" description: "Option Wireless Technology’s CloudGate is the carrier-approved IoT solution platform that delivers device connectivity, security and processing power for global IoT applications." ip_rating: -backhaul: ["Ethernet", "Wi-Fi (add-on)", "Cellular (add-on)"] +backhaul: [Ethernet, Wi-Fi (add-on), Cellular (add-on)] aliases: [/gateways/cloudgate] image: [CloudGate.png] --- diff --git a/doc/content/gateways/models/cotx/x1/_index.md b/doc/content/gateways/models/cotx/x1/_index.md index 0132e04e56..ee31ed8c8c 100644 --- a/doc/content/gateways/models/cotx/x1/_index.md +++ b/doc/content/gateways/models/cotx/x1/_index.md @@ -4,7 +4,7 @@ vendor: COTX vendor_page: "https://www.cotxnetworks.com/hotspot/cotx-x1" description: "COTX X1 is a standard LoRaWAN® indoor gateway. It is easy to install and deploy, highly compatible and has a user-friendly interface. COTX offers rich software tools, powerful back office management and technical support." ip_rating: -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] aliases: [/gateways/cotx/x1] image: [X1_1.png] --- diff --git a/doc/content/gateways/models/cotx/x3/_index.md b/doc/content/gateways/models/cotx/x3/_index.md index 4ec4e7fd9d..1a219d05df 100644 --- a/doc/content/gateways/models/cotx/x3/_index.md +++ b/doc/content/gateways/models/cotx/x3/_index.md @@ -4,7 +4,7 @@ vendor: COTX vendor_page: "https://www.cotxnetworks.com/hotspot/cotx-x3/" description: "The COTX X3 gateway has similar characteristics to the COTX X1 gateway, only with additional features like outdoor support, BLE support, a small screen for easy monitoring and more." ip_rating: -backhaul: ["Ethernet", "Wi-Fi"] +backhaul: [Ethernet, Wi-Fi] aliases: [/gateways/cotx/x3] image: [X3_1.png] --- diff --git a/doc/content/gateways/models/cotx/x5/_index.md b/doc/content/gateways/models/cotx/x5/_index.md index a7a2bb8742..ee5e009439 100644 --- a/doc/content/gateways/models/cotx/x5/_index.md +++ b/doc/content/gateways/models/cotx/x5/_index.md @@ -5,7 +5,7 @@ vendor_page: "https://www.cotxnetworks.com/hotspot/cotx-x5/" description: "The COTX X5 gateway is an outdoor gateway intended for industrial IoT use cases, with a water and dust proof aluminium case." aliases: [/gateways/cotx/x5] ip_rating: "IP67" -backhaul: ["Ethernet", "Wi-Fi", "Cellular"] +backhaul: [Ethernet, Wi-Fi, Cellular] image: [X5_1.png] --- diff --git a/doc/content/gateways/models/dragino-lps8/_index.md b/doc/content/gateways/models/dragino-lps8/_index.md index 171e768f70..ea25d36ad4 100644 --- a/doc/content/gateways/models/dragino-lps8/_index.md +++ b/doc/content/gateways/models/dragino-lps8/_index.md @@ -4,7 +4,7 @@ vendor: "Dragino" vendor_page: "https://www.dragino.com/products/lora-lorawan-gateway/item/200-lps8n.html/" description: "The Dragino LPS8N is a LoRaWAN® indoor gateway based on the open-source OpenWrt Linux operating system. The LPS8N provides ten programmable parallel demodulation paths. The gateway can be connected to the internet using Ethernet, WiFi, or optional Cellular (3G/4G) connectivity." ip_rating: -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] weight: aliases: [/gateways/dragino-lps8] image: [dragino-lps8n.jpg] diff --git a/doc/content/gateways/models/kerlinkwirnetistation/_index.md b/doc/content/gateways/models/kerlinkwirnetistation/_index.md index 804b3e6464..b5f5f008d0 100644 --- a/doc/content/gateways/models/kerlinkwirnetistation/_index.md +++ b/doc/content/gateways/models/kerlinkwirnetistation/_index.md @@ -2,9 +2,9 @@ title: "Kerlink Wirnet iStation" vendor: "Kerlink" vendor_page: "https://www.kerlink.com/product/wirnet-istation/" -description: "he Kerlink Wirnet iStation is an outdoor LoRaWAN® gateway. It offers cellular (4G with 3G/2G fallback) and Ethernet backhauls, as well as fully integrated internal GPS, 4G and LoRa antennas." +description: "The Kerlink Wirnet iStation is an outdoor LoRaWAN® gateway. It offers cellular (4G with 3G/2G fallback) and Ethernet backhauls, as well as fully integrated internal GPS, 4G and LoRa antennas." ip_rating: "IP67" -backhaul: ["Ethernet", "Cellular (optional)"] +backhaul: [Ethernet, Cellular (optional)] aliases: [/guides/connecting-gateways/kerlinkwirnetistation, /gateways/kerlinkwirnetistation] image: [Kerlink-Wirnet-iStation.png] --- diff --git a/doc/content/gateways/models/kerlinkwirnetstation/_index.md b/doc/content/gateways/models/kerlinkwirnetstation/_index.md index 766b904490..886335eded 100644 --- a/doc/content/gateways/models/kerlinkwirnetstation/_index.md +++ b/doc/content/gateways/models/kerlinkwirnetstation/_index.md @@ -4,7 +4,7 @@ vendor: "Kerlink" vendor_page: "https://www.kerlink.com/product/wirnet-station/" description: "The Kerlink Wirnet Station is a robust and highly reliable outdoor LoRaWAN gateway. It was the first commercially available LoRaWAN® gateway on the global market. It offers Ethernet and cellular (3G/2G) backhauls." ip_rating: -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] aliases: [/gateways/kerlinkwirnetstation] image: [wirnet-station.png] --- diff --git a/doc/content/gateways/models/laird-sentrius/_index.md b/doc/content/gateways/models/laird-sentrius/_index.md index 81fe85af10..f37e5bdcac 100644 --- a/doc/content/gateways/models/laird-sentrius/_index.md +++ b/doc/content/gateways/models/laird-sentrius/_index.md @@ -4,7 +4,7 @@ vendor: "Laird" vendor_page: "https://www.lairdconnect.com/iot-devices/lorawan-iot-devices/sentrius-rg1xx-lorawan-gateway-wi-fi-ethernet-optional-lte-us-only" description: "The Laird Sentrius™ RG1xx is a secure, scalable, robust LoRaWAN-Enabled Gateway that supports Wi-Fi, Ethernet, and LTE backends." ip_rating: "IP67 (optional)" -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] aliases: [/gateways/laird-sentrius] image: [laird.png] --- diff --git a/doc/content/gateways/models/mikrotik-knot/_index.md b/doc/content/gateways/models/mikrotik-knot/_index.md index 6467798fe7..cfea3d4bc6 100644 --- a/doc/content/gateways/models/mikrotik-knot/_index.md +++ b/doc/content/gateways/models/mikrotik-knot/_index.md @@ -4,7 +4,7 @@ vendor: "MikroTik" vendor_page: "https://mikrotik.com/product/knot" description: "The MikroTik KNOT LR8/LR9 kit is a universal device with exceptional connectivity options and protocol support. It is an IoT Gateway which can use ethernet or LTE-M (also known as CAT-M) technology as the gateway backhaul." ip_rating: "IP20" -backhaul: ["Ethernet", "Wi-Fi", "Cellular"] +backhaul: [Ethernet, Wi-Fi, Cellular] aliases: ["/gateways/mikrotik-knot"] image: [mikrotik-knot.jpeg] --- diff --git a/doc/content/gateways/models/mikrotik-ltap/_index.md b/doc/content/gateways/models/mikrotik-ltap/_index.md index fd85d0e275..7a5a4cc4c5 100644 --- a/doc/content/gateways/models/mikrotik-ltap/_index.md +++ b/doc/content/gateways/models/mikrotik-ltap/_index.md @@ -4,7 +4,7 @@ vendor: "MikroTik" vendor_page: "https://mikrotik.com/product/ltap_lte_kit" description: "The LtAP LTE kit is a compact weatherproof wireless access point with a built-in cellular modem that supports 4G (LTE) connectivity." ip_rating: "IP54" -backhaul: ["Ethernet", "Wi-Fi", "Cellular"] +backhaul: [Ethernet, Wi-Fi, Cellular] aliases: ["/gateways/mikrotik-ltap"] image: [LtaP.jpg] --- diff --git a/doc/content/gateways/models/mikrotikrouterboard/_index.md b/doc/content/gateways/models/mikrotikrouterboard/_index.md index aa69dabdc6..046e08da50 100644 --- a/doc/content/gateways/models/mikrotikrouterboard/_index.md +++ b/doc/content/gateways/models/mikrotikrouterboard/_index.md @@ -4,7 +4,7 @@ vendor: "MikroTik" vendor_page: "https://mikrotik.com/product/wap_lr8_kit" description: "MikroTik Routerboard wAP LoRa8 kit is a LoRaWAN® gateway that contains a pre-installed UDP packet forwarder and an outdoor weatherproof wireless access point with 2.4 GHz WLAN interface and Ethernet port that could be used as a backend." ip_rating: "IP54" -backhaul: ["Ethernet", "Wi-Fi", "Cellular"] +backhaul: [Ethernet, Wi-Fi, Cellular] aliases: ["/gateways/mikrotikrouterboard"] image: [lr8_kit.png] --- diff --git a/doc/content/gateways/models/milesightug65/_index.md b/doc/content/gateways/models/milesightug65/_index.md index 909fd84b7b..34a98a61c5 100644 --- a/doc/content/gateways/models/milesightug65/_index.md +++ b/doc/content/gateways/models/milesightug65/_index.md @@ -4,7 +4,7 @@ vendor: "Milesight" vendor_page: "https://www.milesight.com/iot/product/lorawan-gateway/ug65" description: "The Milesight UG65 is a high-performance 8-channel LoRaWAN® gateway that offers reliable connectivity for industrial applications." ip_rating: "IP65" -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] aliases: [/gateways/milesightug65] image: [ug65.png] --- diff --git a/doc/content/gateways/models/milesightug67/_index.md b/doc/content/gateways/models/milesightug67/_index.md index def9b1aba3..e7f74a07e1 100644 --- a/doc/content/gateways/models/milesightug67/_index.md +++ b/doc/content/gateways/models/milesightug67/_index.md @@ -4,7 +4,7 @@ vendor: "Milesight" vendor_page: "https://www.milesight.com/iot/product/lorawan-gateway/ug67" description: "The Milesight UG67 is a robust outdoor LoRaWAN® gateway designed for outdoor deployments. Powered by the SX1302 LoRa chip and a high-performance quad-core CPU, the UG67 can support connectivity with over 2000 nodes." ip_rating: "IP67" -backhaul: ["Ethernet", "Cellular (optional)"] +backhaul: [Ethernet, Cellular (optional)] aliases: [/gateways/milesightug67] image: [ug67.png] --- diff --git a/doc/content/gateways/models/milesightug85/_index.md b/doc/content/gateways/models/milesightug85/_index.md index d5948cd419..ae6c6ce264 100644 --- a/doc/content/gateways/models/milesightug85/_index.md +++ b/doc/content/gateways/models/milesightug85/_index.md @@ -4,7 +4,7 @@ vendor: "Milesight" vendor_page: "https://resource.milesight.com/milesight/iot/document/ug85_user_guide_en.pdf" description: "The Milesight UG85 industrial LoRaWAN gateway delivers tenacious connection over network with full-featured design such as automated failover/failback, extended operating temperature, dual SIM cards, hardware watchdog, VPN, Gigabit Ethernet and beyond." ip_rating: "IP30" -backhaul: ["Ethernet", "Wi-Fi (optional)", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi (optional), Cellular (optional)] aliases: [/gateways/milesightug85] image: [ug85.png] --- diff --git a/doc/content/gateways/models/milesightug87/_index.md b/doc/content/gateways/models/milesightug87/_index.md index f0a73d638b..b051f65d34 100644 --- a/doc/content/gateways/models/milesightug87/_index.md +++ b/doc/content/gateways/models/milesightug87/_index.md @@ -4,7 +4,7 @@ vendor: "Milesight" vendor_page: "https://resource.milesight.com/milesight/iot/document/ug87_quick_start_guide_en.pdf" description: "The Milesight UG87 industrial LoRaWAN gateway delivers tenacious connection over network with full-featured design such as automated failover/failback, extended operating temperature, dual SIM cards, hardware watchdog, VPN, Gigabit Ethernet and beyond." ip_rating: "IP67" -backhaul: ["Ethernet", "Wi-Fi (optional)", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi (optional), Cellular (optional)] aliases: [/gateways/milesightug87] image: [ug87.png] --- diff --git a/doc/content/gateways/models/moko-mkgw2-lw/_index.md b/doc/content/gateways/models/moko-mkgw2-lw/_index.md index 24fbfdde0c..dad14a9b5b 100644 --- a/doc/content/gateways/models/moko-mkgw2-lw/_index.md +++ b/doc/content/gateways/models/moko-mkgw2-lw/_index.md @@ -4,7 +4,7 @@ vendor: "MOKOSMART" vendor_page: "https://www.mokosmart.com/lorawan-gateway-mkgw2-lw/" description: "MOKOSMART's 8 channel MKGW2 gateway is embedded with Semtech’s high performance multi-channel transceiver SX1301/SX1257 and MTK platform. It is for indoor use and is easy to install." ip_rating: "IP66" -backhaul: ["Ethernet", "Wi-Fi"] +backhaul: [Ethernet, Wi-Fi] aliases: [/gateways/moko-mkgw2-lw] image: [mkgw2-lw.jpg] --- diff --git a/doc/content/gateways/models/multitechconduit/_index.md b/doc/content/gateways/models/multitechconduit/_index.md index 8b4f52aed0..3fa0991b6a 100644 --- a/doc/content/gateways/models/multitechconduit/_index.md +++ b/doc/content/gateways/models/multitechconduit/_index.md @@ -4,7 +4,7 @@ vendor: "MultiTech" vendor_page: "http://www.multitech.net/developer/products/multiconnect-Conduit-platform/" description: "The MultiTech MultiConnect® Conduit™ is a configurable, scalable cellular communications gateway for industrial IoT applications." ip_rating: "IP30" -backhaul: ["Ethernet", "Wi-Fi (optional)", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi (optional), Cellular (optional)] aliases: [/guides/connecting-gateways/multitechconduit, /gateways/multitechconduit] image: [multitech-conduit.png] --- diff --git a/doc/content/gateways/models/nasysoutdoorgateway/_index.md b/doc/content/gateways/models/nasysoutdoorgateway/_index.md index 8b85ed011b..a736641842 100644 --- a/doc/content/gateways/models/nasysoutdoorgateway/_index.md +++ b/doc/content/gateways/models/nasysoutdoorgateway/_index.md @@ -4,7 +4,7 @@ vendor: "NASys" vendor_page: "https://www.nasys.no/product/lorawan-gateway/" description: "NASys LoRaWAN Outdoor Gateway is an 8 Channel LoRaWAN gateway." ip_rating: "IP67" -backhaul: ["Ethernet", "Cellular (optional)"] +backhaul: [Ethernet, Cellular (optional)] aliases: [/gateways/nasysoutdoorgateway] image: [IX1001.png] --- diff --git a/doc/content/gateways/models/peplink-20x/_index.md b/doc/content/gateways/models/peplink-20x/_index.md index 36b855a91d..5ee4702674 100644 --- a/doc/content/gateways/models/peplink-20x/_index.md +++ b/doc/content/gateways/models/peplink-20x/_index.md @@ -4,7 +4,7 @@ vendor: "Peplink" vendor_page: "https://www.peplink.com/products/balance-20x/" description: "Peplink’s Balance 20X is an SD-WAN branch router with an option to add LoRaWAN® gateway functionality using a LoRaWAN FlexModule Mini." ip_rating: -backhaul: ["Ethernet", "Wi-Fi", "Cellular (optional)"] +backhaul: [Ethernet, Wi-Fi, Cellular (optional)] aliases: [/gateways/peplink] image: [B20X_LoRa.png] --- diff --git a/doc/content/gateways/models/rak-7240/_index.md b/doc/content/gateways/models/rak-7240/_index.md index 956ae2ec36..387eff7c05 100644 --- a/doc/content/gateways/models/rak-7240/_index.md +++ b/doc/content/gateways/models/rak-7240/_index.md @@ -4,7 +4,7 @@ vendor: [RAKwireless] vendor_page: "https://www.rakwireless.com/en-us/products/lpwan-gateways-and-concentrators/rak7240" description: "The RAK7240 (WisGate Edge Prime) is a macro outdoor LoRaWAN® gateway, ideal for large scale deployments. It is highly reliable, customizable, and offers a WiFi, LTE and Ethernet backhaul." ip_rating: "IP65" -backhaul: ["Ethernet", "Wi-Fi", "Cellular"] +backhaul: [Ethernet, Wi-Fi, Cellular] aliases: [/gateways/rak-7240] image: [rak7240.jpg] --- diff --git a/doc/content/gateways/models/tektelickonamicro/_index.md b/doc/content/gateways/models/tektelickonamicro/_index.md index 7294df52ec..6557f5e0ab 100644 --- a/doc/content/gateways/models/tektelickonamicro/_index.md +++ b/doc/content/gateways/models/tektelickonamicro/_index.md @@ -4,7 +4,7 @@ vendor: "Tektelic" vendor_page: "https://tektelic.com/products/gateways/kona-micro-iot-gateway/" description: "Tektelic Kona Micro IoT LoRaWAN Gateway is an 8 channel LoRaWAN gateway." ip_rating: "IP30" -backhaul: ["Ethernet", "Cellular"] +backhaul: [Ethernet, Cellular] aliases: [/gateways/tektelickonamicro] image: [kona-micro.jpg] --- diff --git a/doc/content/gateways/models/thethingsindoorgateway/_index.md b/doc/content/gateways/models/thethingsindoorgateway/_index.md index 1a53738406..b71c3af285 100644 --- a/doc/content/gateways/models/thethingsindoorgateway/_index.md +++ b/doc/content/gateways/models/thethingsindoorgateway/_index.md @@ -4,7 +4,7 @@ vendor: "The Things Industries" vendor_page: "https://www.thethingsshop.com/products/the-things-indoor-gateway" description: "The Things Indoor Gateway is an 8 Channel LoRaWAN® gateway." ip_rating: -backhaul: ["Wi-Fi"] +backhaul: [Wi-Fi] distributions: ["Sandbox", "Cloud"] new_in_version: 3.13.3 aliases: [/gateways/thethingsindoorgateway] diff --git a/doc/content/gateways/models/thethingskickstartergateway/_index.md b/doc/content/gateways/models/thethingskickstartergateway/_index.md index b986ff2b83..7082bc1683 100644 --- a/doc/content/gateways/models/thethingskickstartergateway/_index.md +++ b/doc/content/gateways/models/thethingskickstartergateway/_index.md @@ -4,7 +4,7 @@ vendor: "The Things Industries" vendor_page: "https://www.thethingsnetwork.org/docs/gateways/gateway/" description: "The Things Kickstarter Gateway is a LoRaWAN gateway." ip_rating: -backhaul: ["Ethernet", "Wi-Fi"] +backhaul: [Ethernet, Wi-Fi] aliases: [/gateways/thethingskickstartergateway] image: [TTKG.png] --- diff --git a/doc/content/gateways/models/thethingsoutdoor/_index.md b/doc/content/gateways/models/thethingsoutdoor/_index.md index e2260e1de8..0a9cb471e3 100644 --- a/doc/content/gateways/models/thethingsoutdoor/_index.md +++ b/doc/content/gateways/models/thethingsoutdoor/_index.md @@ -4,7 +4,7 @@ vendor: "The Things Industries" vendor_page: "https://www.thethingsnetwork.org/docs/gateways/thethingsoutdoor/" description: "The Things Outdoor Gateway (TTOG) is an industrial, outdoor and fully compliant gateway at a very low cost." ip_rating: "IP67" -backhaul: ["Ethernet", "Cellular"] +backhaul: [Ethernet, Cellular] aliases: [/gateways/thethingsoutdoor] image: [TTOG.png] --- diff --git a/doc/content/gateways/models/wifx-l1/_index.md b/doc/content/gateways/models/wifx-l1/_index.md index a3d28e1ed8..04f154eb75 100644 --- a/doc/content/gateways/models/wifx-l1/_index.md +++ b/doc/content/gateways/models/wifx-l1/_index.md @@ -4,7 +4,7 @@ vendor: "Wifx" vendor_page: "https://iot.wifx.net/en/products/wifx-l1/" description: "The Wifx L1 is a robust and professional grade outdoor LoRaWAN® gateway in an ultra compact form factor, designed and assembled in Switzerland. It is the successor of the Wifx LORIX One." ip_rating: "IP65" -backhaul: ["Ethernet"] +backhaul: [Ethernet] image: [wifx-l1.png] --- diff --git a/doc/content/gateways/models/wifx-lorix-one/_index.md b/doc/content/gateways/models/wifx-lorix-one/_index.md index 3524b74814..0691660b6c 100644 --- a/doc/content/gateways/models/wifx-lorix-one/_index.md +++ b/doc/content/gateways/models/wifx-lorix-one/_index.md @@ -4,7 +4,7 @@ vendor: "Wifx" vendor_page: "https://iot.wifx.net/en/products/lorix-one/" description: "The LORIX One is a robust and professional grade outdoor LoRaWAN® gateway in an ultra compact form factor, designed and assembled in Switzerland." ip_rating: "IP65" -backhaul: ["Ethernet"] +backhaul: [Ethernet] image: [lorix-one.png] --- diff --git a/frontmatter.go b/frontmatter.go new file mode 100644 index 0000000000..a401fc7962 --- /dev/null +++ b/frontmatter.go @@ -0,0 +1,124 @@ +package main + +import ( + "bufio" + "encoding/csv" + "os" + "path/filepath" + "strings" +) + +func parseFrontMatter(filePath string) (map[string]string, error) { + frontMatter := make(map[string]string) + file, err := os.Open(filePath) + if err != nil { + return nil, err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + readingFrontMatter := false + + for scanner.Scan() { + line := scanner.Text() + if line == "---" { + if readingFrontMatter { + break + } else { + readingFrontMatter = true + continue + } + } + if readingFrontMatter { + parts := strings.SplitN(line, ":", 2) + if len(parts) == 2 { + key := strings.TrimSpace(parts[0]) + value := strings.Trim(strings.TrimSpace(parts[1]), "\"[]") + frontMatter[key] = value + } + } + } + + if err := scanner.Err(); err != nil { + return nil, err + } + + return frontMatter, nil +} + +func hasRequiredFields(frontMatter map[string]string, requiredFields []string) bool { + for _, field := range requiredFields { + if _, ok := frontMatter[field]; !ok { + return false + } + } + return true +} + +func frontMatterToCSV(rootDirectory, csvPath, repoBaseURL string) error { + csvFile, err := os.Create(csvPath) + if err != nil { + return err + } + defer csvFile.Close() + + writer := csv.NewWriter(csvFile) + defer writer.Flush() + + headers := []string{"title", "vendor", "vendor_page", "description", "ip_rating", "backhaul", "image_url"} + if err := writer.Write(headers); err != nil { + return err + } + + requiredFields := []string{"title", "vendor", "description", "image"} + + err = filepath.Walk(rootDirectory, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.IsDir() || filepath.Base(path) != "_index.md" { + return nil + } + + frontMatter, err := parseFrontMatter(path) + if err != nil { + return err + } + + if hasRequiredFields(frontMatter, requiredFields) { + imageRelativePath := frontMatter["image"] + imagePath := filepath.Join(filepath.Dir(path), imageRelativePath) + relPath, err := filepath.Rel(rootDirectory, imagePath) + if err != nil { + return err + } + imageURL := repoBaseURL + "/" + strings.ReplaceAll(relPath, "\\", "/") + + row := make([]string, len(headers)) + for i, header := range headers[:len(headers)-1] { // Exclude image_url from headers for mapping + row[i] = frontMatter[header] + } + row[len(headers)-1] = imageURL // Add image_url at the end + if err := writer.Write(row); err != nil { + return err + } + } + + return nil + }) + + if err != nil { + return err + } + + return nil +} + +func main() { + rootDirectoryPath := "doc/content/gateways/models" + csvPath := "gateways.csv" + repoBaseURL := "https://raw.githubusercontent.com/TheThingsIndustries/lorawan-stack-docs/master/doc/content/gateways/models" + if err := frontMatterToCSV(rootDirectoryPath, csvPath, repoBaseURL); err != nil { + panic(err) + } +}