diff --git a/diary.go b/diary.go index 4a63c8a..82fba13 100644 --- a/diary.go +++ b/diary.go @@ -28,7 +28,8 @@ type diaryHandler struct{} // page anchor (or to the year-file editor when ?edit is set). // // 1. `today` / `this-month` / `this-year` shortcuts resolve directly to a -// year+anchor target (or insert flow when today's section is missing). +// year+anchor target (never the editor, even when today's section does +// not exist yet). // 2. A virtual month URL (/diary//YYYY/MM/) redirects to // /diary//YYYY/#YYYY-MM (or to ?edit§ion=N when ?edit is set). // 3. A virtual day URL (/diary//YYYY/MM/DD/) redirects to @@ -57,7 +58,7 @@ func (d *diaryHandler) dateShortcutRedirect(root, fsPath, urlPath string) (strin parentFS := filepath.Dir(fsPath) parentURLPath := parentURL(urlPath) - _, diaryRootFS, diaryRootURL, ok := findDiaryContext(root, parentFS, parentURLPath) + _, _, diaryRootURL, ok := findDiaryContext(root, parentFS, parentURLPath) if !ok { return "", false } @@ -71,16 +72,7 @@ func (d *diaryHandler) dateShortcutRedirect(root, fsPath, urlPath string) (strin switch base { case "today": dayHeading := fmt.Sprintf("%s-%s-%s", year, month, day) - raw, _ := os.ReadFile(filepath.Join(diaryRootFS, year, "index.md")) - sections := splitSections(raw) - if _, found := findSectionIndex(sections, dayHeading); found { - return yearURL + "#" + dayHeading, true - } - // Missing day: route through the insert flow so today's section - // is spliced in at the right chronological position. - insertIdx := computeInsertIndex(sections, dayHeading) - return fmt.Sprintf("%s?edit&insert_before=%d&heading=%s", - yearURL, insertIdx, url.QueryEscape(dayHeading)), true + return yearURL + "#" + dayHeading, true case "this-month": return yearURL + "#" + fmt.Sprintf("%s-%s", year, month), true case "this-year":