mirror of
https://github.com/waynesutton/markdown-site.git
synced 2026-01-12 04:09:14 +00:00
- Added visitor map section to README.md after GitHub Contributions Graph - Updated visitor map description in content/pages/docs.md with privacy details - Documents configuration options in src/config/siteConfig.ts - Explains Netlify geo detection and theme-aware colors
33 lines
873 B
TypeScript
33 lines
873 B
TypeScript
import type { Context } from "@netlify/edge-functions";
|
|
|
|
// Returns the user's geo location from Netlify's automatic geo headers
|
|
// Privacy friendly: only returns city/country/coordinates, no IP address stored
|
|
export default async function handler(
|
|
_request: Request,
|
|
context: Context,
|
|
): Promise<Response> {
|
|
// Netlify provides geo data automatically via context.geo
|
|
const geo = context.geo;
|
|
|
|
const data = {
|
|
city: geo?.city || null,
|
|
country: geo?.country?.code || null,
|
|
countryName: geo?.country?.name || null,
|
|
latitude: geo?.latitude || null,
|
|
longitude: geo?.longitude || null,
|
|
};
|
|
|
|
return new Response(JSON.stringify(data), {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"Cache-Control": "private, max-age=3600",
|
|
"Access-Control-Allow-Origin": "*",
|
|
},
|
|
});
|
|
}
|
|
|
|
export const config = {
|
|
path: "/api/geo",
|
|
};
|
|
|