Files
website/src/routes/trackers/notes/+page.server.ts
Stan Runge e33afe5387
All checks were successful
Deploy production / deploy (push) Successful in 1m19s
notes: private Obsidian vault tracker at /trackers/notes
Vault files stay the source of truth (bind-mounted read-write at /notes):
atomic writes chowned to the vault owner, hash-checked saves (409 on a
newer file), deletes to .trash. notes.* is a full-text/link index kept
current by a recursive watcher plus a 60s rescan; live updates over the
owner-only /ws/notes channel (paths and hashes only). Wikilinks, embeds,
backlinks, tags, callouts, image paste. Owner-only everywhere (404).
2026-10-26 01:28:57 +00:00

24 lines
852 B
TypeScript

import { requireOwner } from '#lib/server/owner.js';
import { backlinks } from '#lib/server/notes/indexer.js';
import { readNote, VaultError } from '#lib/server/notes/vault.js';
import { cleanVaultPath, kindOf } from '#lib/notes/shared.js';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async (event) => {
requireOwner(event);
const path = cleanVaultPath(event.url.searchParams.get('note'));
if (!path || kindOf(path) === 'attachment')
return { note: null, missing: !!event.url.searchParams.get('note') };
try {
const note = await readNote(path);
return {
note: { path, ...note, backlinks: await backlinks(path).catch(() => []) },
missing: false
};
} catch (e) {
if (e instanceof VaultError && (e.status === 404 || e.status === 400))
return { note: null, missing: true };
throw e;
}
};