Showcasing an Interactive Food Truck Locator Blog Using Mapbox and Serverless Functions
I recently built a niche blog that doubles as a real‑time food truck locator. The site is generated with Hugo, but the core novelty is a Mapbox GL JS map that pulls live data from a city open‑data API. To keep the static site fast, I use Netlify Functions to act as a lightweight proxy: they fetch the GeoJSON, filter by cuisine type, and cache the results in Cloudflare Workers KV for 10 minutes. The map is embedded in a dedicated post-food-truck-locator.md using a Hugo shortcode that injects the Mapbox token and the function URL.
Key challenges I tackled:
- Efficiently rendering over 500 truck markers without jank.
- Ensuring the map is fully responsive on both desktop and mobile.
- Providing a search UI that filters markers on the client while keeping the data payload minimal.
- Managing Mapbox access token rotation without breaking cached requests.
- What techniques have you used to keep Mapbox maps lightweight when handling large GeoJSON files?
- How do you balance serverless function caching with the need for near‑real‑time updates in a map‑centric blog?
Feel free to share code snippets or screenshots of your implementation!