My personal site — dann.my. Next.js, TypeScript, Tailwind, Bun.
bun install
bun dev # http://localhost:3000
bun run build
bun run lint
bun run test:travelNothing is required; features without their vars just stay quiet. Put them in .env.local.
| Variable | Used for |
|---|---|
SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, SPOTIFY_REFRESH_TOKEN |
Now playing |
UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN |
Presence and travel storage |
PRESENCE_SECRET |
Auth for POST /api/presence |
LOCATION_SECRET |
Auth for POST/DELETE /api/location |
LOCATION_HOME, LOCATION_HOME_RADIUS_KM |
Optional lat,lng of home and a radius (default 20 km); updates inside it show as Leeds |
TRAVEL_ADMIN_PASSWORD |
Travel editor password (16+ chars) |
TRAVEL_REDIS_KEY |
Optional override of the travel key, for preview/test environments |
app/ pages and API routes
components/ UI
lib/ blog loading, GitHub, Redis, travel model/store/auth
data/ generated map data and landmark metadata
posts/ blog posts (MDX)
scripts/ travel password + map generation
Drop an .mdx file in posts/ and it appears at /blog/<filename>:
---
title: hello world
description: my first post
date: "August 12, 2024"
---The homepage lists three public, non-fork repos by most recent push, refreshed hourly with no token. Set pinnedRepository in lib/github.ts to pin one first (currently website), or null for none.
The homepage shows "Currently in City, Country" as a text line linking to Apple Maps, with "as of …" once the update is over 12 hours old. An iOS Shortcut sends it, so no paid API is needed.
- The server rounds coordinates to one decimal place (about 11 km) before doing anything else with them.
- The city is looked up from that rounded point with OpenStreetMap Nominatim at city level, so a village name can't reveal more than the rounding. If the lookup fails, no city is stored and the line stays hidden until the next update.
GET /api/locationreturns only city, country and the update time, never coordinates.- The line is hidden when there's no city or country, and after 30 days without an update.
- If
LOCATION_HOMEis set, any update withinLOCATION_HOME_RADIUS_KMof it is published as Leeds instead (HOME_ASin the route), with no lookup.
Shortcut (Shortcuts app → new shortcut):
-
Get Current Location
-
Get Contents of URL →
https://dann.my/api/location, MethodPOST, HeaderAuthorization: Bearer <LOCATION_SECRET>, Request BodyJSONwith these fields. For each one, insert the Current Location variable and tap it to pick the property:latitude(Number) → Current Location › Latitudelongitude(Number) → Current Location › Longitudecountry(Text, optional) → Current Location › Country (Region on UK English, Apple's "Country or Region"). Only used if the lookup doesn't return a country.
A
cityfield is ignored if sent, so older versions of the Shortcut keep working.
Then in Automation, run it on whatever triggers you like (for example Time of Day every morning, or Arrive at an airport), set to Run Immediately. To hide the location, send the same request with Method DELETE and no body.
Editing: run bun run travel:password once (stores a generated password in .env.local), restart, and open /admin/travel. Add, edit or remove visits, pick the most recent country, preview, then save. In production, set TRAVEL_ADMIN_PASSWORD in the host's environment; changing it signs out existing sessions.
Storage: visits live in Redis at travel:passport:v1. Until the first save, the 16-country list in lib/travel/model.ts is shown. Saves are compare-and-set on a revision, so two tabs can't silently overwrite each other. The public GET /api/travel is CDN-cached for about a minute. Sign-in is rate limited to 20 attempts per 15 minutes.
Map: paths come from Natural Earth v5.1.2 (public domain), regenerated with bun run travel:map and bundled locally. Overseas territories have their own codes; UK nations count together as GB. Each location has a landmark in data/travel-landmarks.json and an illustration at public/travel-landmarks/<code>.svg, with photo credits shown in the map's info popover.