feat: caching

This commit is contained in:
2026-01-20 20:07:14 +01:00
parent ff2a2fee48
commit 0f13d67f10
17 changed files with 333 additions and 224 deletions
+17 -16
View File
@@ -1,36 +1,37 @@
# Plan: Nextcloud WebDAV Integration
# Plan: Nextcloud WebDAV Integration (COMPLETED)
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.
- [x] Replace `@sveltejs/adapter-static` with `@sveltejs/adapter-node`.
- [x] Update `svelte.config.js` to use the Node adapter.
- [x] 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).
- [x] Install `webdav` client library.
- [x] Install `dotenv` (handled by SvelteKit's built-in env support).
## 3. Secure Configuration
- [ ] Set up `.env` with:
- [x] Set up `.env` with:
- `NEXTCLOUD_URL`
- `NEXTCLOUD_USER`
- `NEXTCLOUD_PASSWORD`
- [ ] Use `$env/dynamic/private` to access these in server-side code only.
- [x] 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:
- [x] Create `src/lib/server/nextcloud.ts` to initialize and export the WebDAV client.
- [x] 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.
- [x] 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:
- [x] Create a catch-all server route (e.g., `src/routes/assets/[...path]/+server.ts`).
- [x] 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.
- [x] 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.
## 6. Optimization
- [x] Implement server-side caching to avoid hitting Nextcloud on every single request.
- [x] Implement dynamic route discovery to automatically create pages from Nextcloud folders.