feat(workspace): backlinks at the end of a note

GET /documents/{id}/backlinks lists the notes the user can open whose
blocks link [[Title]] (also |alias and #section, case-insensitive),
excluding the note itself and the trash. The collapsible "Verlinkt auf
diese Notiz" section shows each note with folder and the linking bullets;
a click jumps straight to the bullet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-29 08:00:57 +01:00
1 parent f69f74fdc7
commit 677fe0fc0a
11 files changed
+303

No files matched your search

+10
View File
@@ -176,6 +176,7 @@ func (s *Server) Router() http.Handler {
r.Get("/api/v1/documents/trash", s.handleGetTrash)
r.Delete("/api/v1/documents/trash", s.handleEmptyTrash)
r.Post("/api/v1/documents/{id}/restore", s.handleRestoreDocument)
r.Get("/api/v1/documents/{id}/backlinks", s.handleGetBacklinks)
r.Delete("/api/v1/documents/{id}/permanent", s.handlePurgeDocument)
r.Post("/api/v1/documents/{id}/blocks/{blockId}/enhanced-task", s.handleCreateEnhancedTask)
@@ -1117,6 +1118,15 @@ func (s *Server) handleGetDocument(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, doc)
}
func (s *Server) handleGetBacklinks(w http.ResponseWriter, r *http.Request) {
links, err := s.store.GetBacklinks(auth.GetUserID(r.Context()), chi.URLParam(r, "id"))
if err != nil {
writeError(w, http.StatusNotFound, "Dokument nicht gefunden")
return
}
writeJSON(w, http.StatusOK, links)
}
func (s *Server) handleUpdateDocument(w http.ResponseWriter, r *http.Request) {
userID := auth.GetUserID(r.Context())
docID := chi.URLParam(r, "id")