Moon and retrograde calendars, "today in the sky" on the own chart
CI / test (push) Successful in 2m6s
CI / build (push) Skipped
CI / deploy (push) Skipped

New public pages: /holdnaptar (new and full moons, quarters, eclipses and
the Moon's sign changes, month by month, with the Moon of today) and
/retrograd (the retrograde periods of Mercury to Pluto with their shadows,
and which planets are retrograde now), each with a page per year around
the current one. The own chart gets a "Ma az égen" card: the Moon's sign,
phase and natal house, the tightest transits to the chart in fixed
sentences, and the retrograde planets. No AI, nothing stored.

The events come from astro-engine (sampling and bisection, checked against
swetest and the 2026 eclipses) through horoscope-api GET /v1/sky and
/v1/sky/events; the backend serves them at /v1/public/sky… and keeps them
in memory (the sky now for five minutes, a year's events for good). Links
in the mobile menu, the footer, the sitemap and the free tools on the home
page; the desktop header is unchanged (it is full at 1280 px).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-23 17:21:36 +00:00
co-authored by Claude Opus 5.5
parent 3255e939c4
commit 699ce2abbd
30 changed files with 2230 additions and 5 deletions
+41
View File
@@ -0,0 +1,41 @@
// The sky by date from the backend, for the moon and retrograde calendars and
// the "today in the sky" card. The same for everyone, so it is cached.
import "server-only";
import { BACKEND_URL } from "./server";
import type { SkyEvents, SkyNow } from "./types";
/** Years the calendar pages have, around the current one (as the backend). */
export const YEARS_AROUND = 5;
/** The year in Hungary now. */
export function currentYear(): number {
return Number(new Intl.DateTimeFormat("en", { year: "numeric", timeZone: "Europe/Budapest" }).format(new Date()));
}
/** A year the calendar pages have (`/holdnaptar/2027`), or `null`. */
export function calendarYear(text: string): number | null {
if (!/^\d{4}$/.test(text)) return null;
const year = Number(text);
return Math.abs(year - currentYear()) <= YEARS_AROUND ? year : null;
}
/** The sky now (a few minutes old at most); `null` when the backend does not answer. */
export async function loadSky(): Promise<SkyNow | null> {
try {
const res = await fetch(`${BACKEND_URL}/v1/public/sky`, { next: { revalidate: 300 } });
return res.ok ? ((await res.json()) as SkyNow) : null;
} catch {
return null;
}
}
/** A year's lunar phases, Moon sign changes and retrograde periods. */
export async function loadSkyEvents(year: number): Promise<SkyEvents | null> {
try {
const res = await fetch(`${BACKEND_URL}/v1/public/sky/events?year=${year}`, { next: { revalidate: 86400 } });
return res.ok ? ((await res.json()) as SkyEvents) : null;
} catch {
return null;
}
}
+261
View File
@@ -0,0 +1,261 @@
// Hungarian words and short texts for the sky calendars and the "today in
// the sky" card. No AI: fixed sentences put together from parts.
import { POINTS, SIGNS } from "./astro";
import type { LunationKind, SkyLunation, SkyPosition } from "./types";
/** "in Aries": `Kosban`. */
export const SIGN_IN: Record<string, string> = {
aries: "Kosban",
taurus: "Bikában",
gemini: "Ikrekben",
cancer: "Rákban",
leo: "Oroszlánban",
virgo: "Szűzben",
libra: "Mérlegben",
scorpio: "Skorpióban",
sagittarius: "Nyilasban",
capricorn: "Bakban",
aquarius: "Vízöntőben",
pisces: "Halakban",
};
/** "into Aries": `Kosba`. */
export const SIGN_INTO: Record<string, string> = {
aries: "Kosba",
taurus: "Bikába",
gemini: "Ikrekbe",
cancer: "Rákba",
leo: "Oroszlánba",
virgo: "Szűzbe",
libra: "Mérlegbe",
scorpio: "Skorpióba",
sagittarius: "Nyilasba",
capricorn: "Bakba",
aquarius: "Vízöntőbe",
pisces: "Halakba",
};
/** The mood of the days with the Moon in a sign. */
export const MOON_IN_SIGN: Record<string, string> = {
aries: "Lendület és türelmetlenség. Jó nap elkezdeni valamit.",
taurus: "Nyugalom, kényelem, érzéki örömök. Ráérősebb tempó.",
gemini: "Kíváncsiság, beszélgetések, sok apró ügy egyszerre.",
cancer: "Otthon, család, érzékenység. Jólesik a biztonság.",
leo: "Önkifejezés, játékosság, a figyelem öröme.",
virgo: "Rendrakás, részletek, a test és a napi rutin.",
libra: "Kapcsolatok, harmónia, kompromisszumok.",
scorpio: "Mélység és intenzitás: erősebb érzések, kevesebb felszínesség.",
sagittarius: "Derűlátás, tanulás, kalandvágy.",
capricorn: "Kötelességek, tervezés, kitartó munka.",
aquarius: "Szabadság, barátok, szokatlan ötletek.",
pisces: "Álmodozás, együttérzés, megérzések.",
};
/** What a phase of the Moon is good for, in the astrological tradition. */
export const PHASE_MEANING: Record<string, string> = {
new_moon: "Újrakezdés: jó pillanat szándékot megfogalmazni, valami újat elindítani.",
waxing_crescent: "Az elindított dolgok szárba szöknek: lendület, első lépések.",
first_quarter: "Próbatétel: ami elindult, most döntéseket és kitartást kér.",
waxing_gibbous: "Csiszolás és finomhangolás a kiteljesedés előtt.",
full_moon: "Tetőpont: felfokozott érzelmek, minden láthatóbbá válik.",
waning_gibbous: "Az eredmények ideje: megosztás, hála, tanulságok.",
last_quarter: "Rendrakás: amitől ideje elbúcsúzni, attól most könnyebb.",
waning_crescent: "Pihenés és elengedés a következő újhold előtt.",
};
export const LUNATION_NAMES: Record<LunationKind, string> = {
new_moon: "Újhold",
first_quarter: "Első negyed",
full_moon: "Telihold",
last_quarter: "Utolsó negyed",
};
/** Moon glyphs of the four main phases: the filled part is the lit one (gold on the dark page). */
export const LUNATION_GLYPHS: Record<LunationKind, string> = {
new_moon: "○",
first_quarter: "◑",
full_moon: "●",
last_quarter: "◐",
};
export function eclipseName(e: NonNullable<SkyLunation["eclipse"]>): string {
const type = { total: "teljes", annular: "gyűrűs", hybrid: "hibrid", partial: "részleges", penumbral: "félárnyékos" }[
e.eclipse_type
];
return `${type} ${e.kind === "solar" ? "napfogyatkozás" : "holdfogyatkozás"}`;
}
/** What a natal house is about, as the subject of "kerülnek előtérbe". */
export const HOUSE_THEMES: Record<number, string> = {
1: "a hangulatod és a megjelenésed",
2: "a pénzügyeid és az anyagi biztonságod",
3: "a beszélgetések és a rövid utak",
4: "az otthonod és a családod",
5: "az örömeid és a kreativitásod",
6: "a munkád és a napi teendőid",
7: "a párkapcsolatod és a társaid",
8: "a közös anyagiak és az intimitás",
9: "a tanulás és az utazás",
10: "a hivatásod és a céljaid",
11: "a barátaid és a közösségeid",
12: "a pihenés és a belső világod",
};
/** What a planet brings when it moves over a chart (one noun, for the sentences). */
const TRANSIT_THEME: Record<string, string> = {
sun: "az önkifejezés",
moon: "a hangulat",
mercury: "a kommunikáció",
venus: "a szeretet",
mars: "a lendület",
jupiter: "a bizalom",
saturn: "a felelősség",
uranus: "a változás",
neptune: "a képzelet",
pluto: "az átalakulás",
};
/** What a point of the birth chart stands for (yours). */
const NATAL_THEME: Record<string, string> = {
sun: "az önazonosságod",
moon: "az érzelmeid",
mercury: "a gondolkodásod",
venus: "a kapcsolataid",
mars: "a cselekvőkészséged",
jupiter: "az optimizmusod",
saturn: "a kötelességtudatod",
uranus: "a függetlenséged",
neptune: "az érzékenységed",
pluto: "a belső erőd",
ascendant: "a fellépésed",
midheaven: "a hivatásod",
};
/** "with your natal Moon": the point in the instrumental, with "your". */
const NATAL_WITH: Record<string, string> = {
sun: "Napoddal",
moon: "Holdaddal",
mercury: "Merkúroddal",
venus: "Vénuszoddal",
mars: "Marsoddal",
jupiter: "Jupitereddel",
saturn: "Szaturnuszoddal",
uranus: "Uránuszoddal",
neptune: "Neptunuszoddal",
pluto: "Plútóddal",
ascendant: "aszcendenseddel",
midheaven: "MC-ddel",
};
/** The aspect as "in trine" (`trigonban`). */
const ASPECT_IN: Record<string, string> = {
conjunction: "együttállásban",
sextile: "szextilben",
square: "kvadrátban",
trine: "trigonban",
opposition: "szembenállásban",
};
/** "A tranzit Vénusz trigonban áll a születési Holdaddal." */
export function transitLine(transiting: string, aspect: string, natal: string): string {
return `A tranzit ${POINTS[transiting]?.hu ?? transiting} ${ASPECT_IN[aspect] ?? aspect} áll a születési ${NATAL_WITH[natal] ?? natal}.`;
}
/** One sentence on what the aspect suggests. */
export function transitMeaning(transiting: string, aspect: string, natal: string): string {
const a = TRANSIT_THEME[transiting] ?? transiting;
const b = NATAL_THEME[natal] ?? natal;
if (aspect === "conjunction") return `Egybefonódik ${a} és ${b}.`;
if (aspect === "trine" || aspect === "sextile") return `Könnyen összhangba kerül ${a} és ${b}.`;
return `Súrlódás lehet ${a} és ${b} között; megéri tudatosan kezelni.`;
}
/** What a retrograde period of the planet is said to bring. */
export const RETROGRADE_MEANING: Record<string, string> = {
mercury:
"Kommunikáció, utazás, technika, szerződések: gyakoribb félreértések, késések, előkerülő régi ügyek. Jó idő átnézni, javítani, újragondolni.",
venus:
"Kapcsolatok és értékek: régi szerelmek, kapcsolati kérdések kerülhetnek elő. A nagy vásárlásokat, látványos változtatásokat a külsőn sokan elhalasztják.",
mars: "Energia és cselekvés: a lendület befelé fordul, régi konfliktusok kerülhetnek elő. Inkább befejezni érdemes, mint új harcba kezdeni.",
jupiter: "Növekedés, hit, tanulás: a kifelé terjeszkedés helyett belső fejlődés, a meggyőződések átgondolása.",
saturn: "Felelősség és struktúra: a kötelezettségek, határok és hosszú távú tervek felülvizsgálata.",
uranus: "Változás és szabadság: a változások belül érlelődnek, mielőtt kifelé is megmutatkoznának.",
neptune: "Álmok és illúziók: a köd ritkul, könnyebb tisztán látni, mi volt csak vágyálom.",
pluto: "Átalakulás és hatalom: régi minták kerülnek felszínre, mély, belső átalakulás.",
};
/** `"2026-03-03T12:38"` as a date in Hungarian (no time zone shift: the text is local already). */
export function localDate(
local: string,
opts: { time?: boolean; weekday?: boolean; year?: boolean; short?: boolean } = {},
): string {
const [date, clock = "00:00"] = local.split("T");
const [y, m, d] = date.split("-").map(Number);
const [h, min] = clock.split(":").map(Number);
const text = new Intl.DateTimeFormat("hu-HU", {
...(opts.year ? { year: "numeric" } : {}),
month: opts.short ? "short" : "long",
day: "numeric",
...(opts.weekday ? { weekday: "long" } : {}),
timeZone: "UTC",
}).format(new Date(Date.UTC(y, m - 1, d)));
return opts.time ? `${text} ${String(h).padStart(2, "0")}:${String(min).padStart(2, "0")}` : text;
}
/** `Halak 8°29′`. */
export function positionText(p: SkyPosition): string {
const deg = Math.floor(p.degree_in_sign);
const min = Math.floor((p.degree_in_sign - deg) * 60);
return `${SIGNS[p.sign]?.hu ?? p.sign} ${deg}°${String(min).padStart(2, "0")}′`;
}
/** Hungarian month names, January first. */
export const MONTH_NAMES = [
"Január",
"Február",
"Március",
"Április",
"Május",
"Június",
"Július",
"Augusztus",
"Szeptember",
"Október",
"November",
"December",
];
/** `a Kosba`, `az Ikrekbe`: the article before a Hungarian word. */
export function withArticle(word: string): string {
return `${/^[aáeéiíoóöőuúüű]/i.test(word) ? "az" : "a"} ${word}`;
}
/** "ma", "holnap" or the date, for a local time relative to another one. */
export function dayWord(local: string, today: string): string {
const day = (t: string) => {
const [y, m, d] = t.slice(0, 10).split("-").map(Number);
return Date.UTC(y, m - 1, d);
};
const diff = Math.round((day(local) - day(today)) / 86400000);
if (diff === 0) return "ma";
if (diff === 1) return "holnap";
return localDate(local, { short: true });
}
/** `december 13-ig`: a date with "until" (the date's closing dot dropped). */
export function until(local: string, opts: Parameters<typeof localDate>[1] = {}): string {
return `${localDate(local, opts).replace(/\.$/, "")}-ig`;
}
/** `2026-ban`, `2027-ben`: a year with "in", by how its last word sounds. */
export function yearIn(year: number): string {
const last = year % 10;
const tens = Math.floor(year / 10) % 10;
let back: boolean;
if (last !== 0) back = [3, 6, 8].includes(last);
else if (tens !== 0) back = [2, 3, 6, 8].includes(tens);
// "…száz": -ban, "…ezer": -ben.
else back = Math.floor(year / 100) % 10 !== 0;
return `${year}-${back ? "ban" : "ben"}`;
}
+98
View File
@@ -0,0 +1,98 @@
// Today's transits to a birth chart: the planets now against the chart's
// planets and angles. A plain calculation on data the page already has.
import type { ChartResult, SkyPlanet } from "./types";
export interface Transit {
transiting: string;
natal: string;
aspect: "conjunction" | "sextile" | "square" | "trine" | "opposition";
/** Degrees from exact. */
orb: number;
/** Getting closer (otherwise past exact and fading). */
applying: boolean;
}
const ASPECTS: [Transit["aspect"], number][] = [
["conjunction", 0],
["sextile", 60],
["square", 90],
["trine", 120],
["opposition", 180],
];
/** Orbs for a day's view: the faster the planet, the shorter it stays in one. */
const ORB: Record<string, number> = {
moon: 2,
sun: 2,
mercury: 2,
venus: 2,
mars: 2,
jupiter: 1.5,
saturn: 1.5,
uranus: 1,
neptune: 1,
pluto: 1,
};
const PLANETS = Object.keys(ORB);
/** Angular distance `[0, 180]`. */
function separation(a: number, b: number): number {
const d = Math.abs(a - b) % 360;
return d > 180 ? 360 - d : d;
}
/** The chart points measured to: the ten planets, and with a birth time the Ascendant and the MC (the Moon only then). */
function natalPoints(chart: ChartResult, timeKnown: boolean): [string, number][] {
const out: [string, number][] = chart.points
.filter((p) => PLANETS.includes(p.id) && (timeKnown || p.id !== "moon"))
.map((p) => [p.id, p.longitude]);
if (timeKnown && chart.angles) {
for (const id of ["ascendant", "midheaven"]) {
const a = chart.angles[id];
if (a && typeof a === "object") out.push([id, a.longitude]);
}
}
return out;
}
/** The tightest transits now, closest first (relative to the orb allowed). */
export function todaysTransits(sky: SkyPlanet[], chart: ChartResult, timeKnown: boolean, limit = 3): Transit[] {
const found: (Transit & { score: number })[] = [];
for (const t of sky) {
const maxOrb = ORB[t.id];
if (maxOrb === undefined) continue;
// Where it will be in about an hour: closer or farther from exact.
const later = t.position.longitude + t.speed / 24;
for (const [natal, lon] of natalPoints(chart, timeKnown)) {
for (const [aspect, angle] of ASPECTS) {
const orb = Math.abs(separation(t.position.longitude, lon) - angle);
if (orb > maxOrb) continue;
const applying = Math.abs(separation(later, lon) - angle) < orb;
found.push({ transiting: t.id, natal, aspect, orb, applying, score: orb / maxOrb });
}
}
}
// The Moon passes everything within hours: one of its aspects at most.
let moon = 0;
return found
.sort((a, b) => a.score - b.score)
.filter((t) => t.transiting !== "moon" || moon++ === 0)
.slice(0, limit)
.map(({ score: _, ...t }) => t);
}
/** The natal house a longitude falls in (1–12), or `null` without houses. */
export function natalHouse(chart: ChartResult, longitude: number): number | null {
const cusps = chart.houses?.cusps;
if (!cusps || cusps.length !== 12) return null;
const sorted = [...cusps].sort((a, b) => a.house - b.house).map((c) => c.longitude);
for (let i = 0; i < 12; i++) {
const start = sorted[i];
const end = sorted[(i + 1) % 12];
const span = (end - start + 360) % 360;
if ((longitude - start + 360) % 360 < span) return i + 1;
}
return null;
}
+72
View File
@@ -669,3 +669,75 @@ export interface Invoice {
gross_huf: number;
paid_at: string;
}
/** The sky by date (`/v1/public/sky…`): tropical, geocentric, the same for everyone. */
export interface SkyPosition {
longitude: number;
sign: string;
degree_in_sign: number;
degree_in_sign_dms: string;
}
export interface SkyMoment {
moment_utc: string;
/** `YYYY-MM-DDTHH:MM` on the Hungarian clock. */
local_time: string;
}
export interface SkyStation extends SkyMoment {
/** Turns retrograde here (otherwise direct). */
retrograde: boolean;
position: SkyPosition;
}
export type LunationKind = "new_moon" | "first_quarter" | "full_moon" | "last_quarter";
export interface SkyLunation extends SkyMoment {
kind: LunationKind;
position: SkyPosition;
eclipse: { kind: "solar" | "lunar"; eclipse_type: "total" | "annular" | "hybrid" | "partial" | "penumbral" } | null;
}
export interface SkyIngress extends SkyMoment {
sign: string;
}
export interface SkyPlanet {
id: string;
position: SkyPosition;
/** Degrees a day (negative: retrograde). */
speed: number;
retrograde: boolean;
next_station: SkyStation | null;
}
export interface SkyNow extends SkyMoment {
timezone: string;
utc_offset: string;
planets: SkyPlanet[];
moon: {
position: SkyPosition;
phase: string;
illumination: number;
elongation: number;
waxing: boolean;
sign_change: SkyIngress | null;
next_phases: SkyLunation[];
};
}
export interface SkyRetrograde {
planet: string;
station_retrograde: SkyStation;
station_direct: SkyStation;
shadow_start: SkyMoment;
shadow_end: SkyMoment;
}
export interface SkyEvents {
year: number;
timezone: string;
lunations: SkyLunation[];
moon_ingresses: SkyIngress[];
retrogrades: SkyRetrograde[];
}