# Plan: Nextcloud WebDAV Integration Transition from static file hosting to a dynamic SvelteKit (Node.js) application that fetches content directly from Nextcloud. ## 1. Infrastructure Shift - [ ] Replace `@sveltejs/adapter-static` with `@sveltejs/adapter-node`. - [ ] Update `svelte.config.js` to use the Node adapter. - [ ] Remove `fallback: undefined` and other static-specific configurations. ## 2. Dependencies - [ ] Install `webdav` client library. - [ ] Install `dotenv` (if not already handled by SvelteKit's built-in env support). ## 3. Secure Configuration - [ ] Set up `.env` with: - `NEXTCLOUD_URL` - `NEXTCLOUD_USER` - `NEXTCLOUD_PASSWORD` - [ ] Use `$env/dynamic/private` to access these in server-side code only. ## 4. Server-Side Data Fetching - [ ] Create `src/lib/server/nextcloud.ts` to initialize and export the WebDAV client. - [ ] Implement `+page.server.ts` for each content route: - Fetch Markdown content from Nextcloud. - Return the raw string to the frontend. - [ ] Update `Markdown.svelte` to receive and render raw strings instead of fetching from a URL on the client. ## 5. Asset Proxying - [ ] Create a catch-all server route (e.g., `src/routes/assets/[...path]/+server.ts`). - [ ] This route will: - Authenticate with WebDAV. - Stream images/files from Nextcloud directly to the browser. - [ ] Update Markdown rendering logic to rewrite image URLs to point to this proxy route. ## 6. Optimization (Optional but Recommended) - [ ] Implement server-side caching (e.g., using a simple TTL cache or Redis) to avoid hitting Nextcloud on every single request.