diff --git a/package.json b/package.json index 916f998..af1cd98 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@mdi/js": "^7.4.47", "@prisma/client": "^5.8.1", "svelte-floating-ui": "^1.5.8", + "svelte-markdown": "^0.4.1", "zod": "^3.22.4" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9af6efd..1ab8cad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ dependencies: svelte-floating-ui: specifier: ^1.5.8 version: 1.5.8 + svelte-markdown: + specifier: ^0.4.1 + version: 0.4.1(svelte@4.2.9) zod: specifier: ^3.22.4 version: 3.22.4 @@ -856,6 +859,10 @@ packages: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true + /@types/marked@5.0.2: + resolution: {integrity: sha512-OucS4KMHhFzhz27KxmWg7J+kIYqyqoW5kdIEI319hqARQQUTqhao3M/F+uFnDXD0Rg72iDDZxZNxq5gvctmLlg==} + dev: false + /@types/node@20.11.7: resolution: {integrity: sha512-GPmeN1C3XAyV5uybAf4cMLWT9fDWcmQhZVtMFu7OR32WjrqGG+Wnk2V1d0bmtUyE/Zy1QJ9BxyiTih9z8Oks8A==} dependencies: @@ -2096,6 +2103,12 @@ packages: dependencies: '@jridgewell/sourcemap-codec': 1.4.15 + /marked@5.1.2: + resolution: {integrity: sha512-ahRPGXJpjMjwSOlBoTMZAK7ATXkli5qCPxZ21TG44rx1KEo44bii4ekgTDQPNRQ4Kh7JMb9Ub1PVk1NxRSsorg==} + engines: {node: '>= 16'} + hasBin: true + dev: false + /mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} @@ -2872,6 +2885,16 @@ packages: dependencies: svelte: 4.2.9 + /svelte-markdown@0.4.1(svelte@4.2.9): + resolution: {integrity: sha512-pOlLY6EruKJaWI9my/2bKX8PdTeP5CM0s4VMmwmC2prlOkjAf+AOmTM4wW/l19Y6WZ87YmP8+ZCJCCwBChWjYw==} + peerDependencies: + svelte: ^4.0.0 + dependencies: + '@types/marked': 5.0.2 + marked: 5.1.2 + svelte: 4.2.9 + dev: false + /svelte-preprocess@5.1.3(postcss@8.4.33)(svelte@4.2.9)(typescript@5.3.3): resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} diff --git a/prisma/migrations/20240113185049_init/migration.sql b/prisma/migrations/20240113185049_init/migration.sql index ff8c396..e9f7a31 100644 --- a/prisma/migrations/20240113185049_init/migration.sql +++ b/prisma/migrations/20240113185049_init/migration.sql @@ -78,7 +78,7 @@ CREATE TABLE "entry_versions" ( "id" SERIAL NOT NULL, "entry_id" INTEGER NOT NULL, "text" TEXT NOT NULL, - "date" TIMESTAMP(3) NOT NULL, + "date" DATE NOT NULL, "category_id" INTEGER, "priority" BOOLEAN NOT NULL, "author_id" INTEGER NOT NULL, diff --git a/prisma/schema.prisma b/prisma/schema.prisma index aebefd9..915ca43 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -116,7 +116,7 @@ model EntryVersion { entry_id Int text String - date DateTime + date DateTime @db.Date category Category? @relation(fields: [category_id], references: [id], onDelete: SetNull) category_id Int? diff --git a/src/app.pcss b/src/app.pcss index 2d53edd..4abb4ca 100644 --- a/src/app.pcss +++ b/src/app.pcss @@ -7,6 +7,10 @@ button { text-align: initial; } +.heading { + @apply text-2xl font-bold; +} + .ellipsis { overflow: hidden; white-space: nowrap; diff --git a/src/hooks.client.ts b/src/hooks.client.ts new file mode 100644 index 0000000..5c7d379 --- /dev/null +++ b/src/hooks.client.ts @@ -0,0 +1,28 @@ +import type { HandleClientError } from "@sveltejs/kit"; +import { TRPCClientError } from "@trpc/client"; + +const CHECK_CONNECTION = + "Die Seite konnte nicht geladen werden, prüfen sie ihre Verbindung"; + +export const handleError: HandleClientError = async ({ error, message, status }) => { + // If there are client-side errors, SvelteKit always returns the nondescript + // "Internal error" message. The most common errors should be mapped to a more + // detailed description + if (status === 500) { + // eslint-disable-next-line no-console + console.error("Client error:", error); + + if ( + error instanceof TypeError && + error.message.includes("dynamically imported module") + ) { + // Could not load JS module + message = CHECK_CONNECTION; + } else if (error instanceof TRPCClientError && !error.data) { + // Could not load fetched data + message = CHECK_CONNECTION; + } + } + + return { message }; +}; diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 2b69631..065efc2 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -65,6 +65,7 @@ export const handle = sequence( return opt.session; }, }, + trustHost: true, }), authorization, createTRPCHandle({ router, createContext }) diff --git a/src/lib/components/filter/Autocomplete.svelte b/src/lib/components/filter/Autocomplete.svelte index 7b55b89..2f34a43 100644 --- a/src/lib/components/filter/Autocomplete.svelte +++ b/src/lib/components/filter/Autocomplete.svelte @@ -22,6 +22,7 @@ export let cacheKey: string | undefined = undefined; export let placeholder: string | undefined = undefined; export let padding = true; + export let cls = ""; /** Selection callback. Returns the new input value after selection */ export let onSelect: (item: SelectionOrText, kb: boolean) => OnSelectResult = ( @@ -195,7 +196,7 @@ }); -