diff --git a/src/lib/settings.ts b/src/lib/settings.ts index 1c2e132..f1a69d0 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -11,6 +11,9 @@ export type AppSettings = { /** Markenfarbe als Hex-Wert */ brandColor: string; logoId: number | null; + /** Großes Bild oben auf der Startseite */ + heroEnabled: boolean; + heroImageId: number | null; website: string; contactEmail: string; contactIntro: string; @@ -28,6 +31,8 @@ export const DEFAULT_SETTINGS: AppSettings = { intro: 'Hier findest du Neuigkeiten, Termine und alles Wichtige rund um deine Werkstatt.', brandColor: '#0e7c66', logoId: null, + heroEnabled: true, + heroImageId: null, website: '', contactEmail: '', contactIntro: 'Du hast Fragen oder Ideen für die App? Schreib uns gerne!', diff --git a/src/routes/(app)/+page.server.ts b/src/routes/(app)/+page.server.ts index 69a3fbe..20ede30 100644 --- a/src/routes/(app)/+page.server.ts +++ b/src/routes/(app)/+page.server.ts @@ -1,7 +1,7 @@ import { asc } from 'drizzle-orm'; import { db } from '$lib/server/db'; import { tiles } from '$lib/server/db/schema'; -import { listPosts, upcomingEvents } from '$lib/server/content'; +import { getMedia, listPosts, upcomingEvents } from '$lib/server/content'; import { getSettings } from '$lib/server/settings'; import { addDays, today } from '$lib/dates'; @@ -11,6 +11,9 @@ export const load = () => { return { greeting: s.greeting, intro: s.intro, + heroEnabled: s.heroEnabled, + // Ohne eigenes Bild wird der Platzhalter /hero-placeholder.svg gezeigt + hero: getMedia(s.heroImageId), tiles: db.select().from(tiles).orderBy(asc(tiles.sortOrder), asc(tiles.id)).all(), posts: listPosts({ limit: s.homeNewsCount }).items, events: upcomingEvents({ limit: s.homeEventsCount, kind: 'event' }), diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 67bb9f2..ee0ce06 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -19,21 +19,35 @@
-
- - -
-

{daytime}!

-

{data.greeting}

- {#if data.intro}

{data.intro}

{/if} - +
+ {#if data.heroEnabled} +
+ {data.hero?.alt + + +
+ {/if} +
+ + +
+

{daytime}!

+

{data.greeting}

+ {#if data.intro}

{data.intro}

{/if} + +
diff --git a/src/routes/admin/(panel)/einstellungen/+page.server.ts b/src/routes/admin/(panel)/einstellungen/+page.server.ts index 6cb893c..c8cca47 100644 --- a/src/routes/admin/(panel)/einstellungen/+page.server.ts +++ b/src/routes/admin/(panel)/einstellungen/+page.server.ts @@ -7,7 +7,7 @@ import { cleanHtml } from '$lib/server/sanitize'; export const load = ({ locals }) => { requireAdmin(locals.user); const s = getSettings(); - return { settings: s, logo: getMedia(s.logoId) }; + return { settings: s, logo: getMedia(s.logoId), hero: getMedia(s.heroImageId) }; }; export const actions = { @@ -28,6 +28,8 @@ export const actions = { intro: f.str('intro', 400), brandColor, logoId: f.int('logoId'), + heroEnabled: f.bool('heroEnabled'), + heroImageId: f.int('heroImageId'), website, contactEmail: f.str('contactEmail', 200), contactIntro: f.str('contactIntro', 400), diff --git a/src/routes/admin/(panel)/einstellungen/+page.svelte b/src/routes/admin/(panel)/einstellungen/+page.svelte index 3d6158a..97325cf 100644 --- a/src/routes/admin/(panel)/einstellungen/+page.svelte +++ b/src/routes/admin/(panel)/einstellungen/+page.svelte @@ -4,6 +4,7 @@ import Panel from '$lib/admin/Panel.svelte'; import ImageField from '$lib/admin/ImageField.svelte'; import RichEditor from '$lib/admin/RichEditor.svelte'; + import Switch from '$lib/admin/Switch.svelte'; let { data } = $props(); const s = $derived(data.settings); @@ -37,6 +38,14 @@ + +
+ +

+ Am besten ein Foto im Querformat, mindestens 1600 px breit. Solange keins gewählt ist, erscheint eine + Platzhalter-Illustration. +

+
diff --git a/static/hero-placeholder.svg b/static/hero-placeholder.svg new file mode 100644 index 0000000..1bedcee --- /dev/null +++ b/static/hero-placeholder.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +