Add home page selection to header and increase body size limit in Docker config
This commit is contained in:
parent
8d8e6cfd27
commit
ad34d78d40
6 changed files with 32 additions and 3 deletions
|
|
@ -40,6 +40,7 @@ export type HeaderGlobal = {
|
||||||
logo: { url: string; alt: string };
|
logo: { url: string; alt: string };
|
||||||
navLinks: { label: string; href: string }[];
|
navLinks: { label: string; href: string }[];
|
||||||
ctaButton: { label: string; href: string };
|
ctaButton: { label: string; href: string };
|
||||||
|
homePage: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FooterGlobal = {
|
export type FooterGlobal = {
|
||||||
|
|
@ -59,7 +60,8 @@ export const defaultHeader: HeaderGlobal = {
|
||||||
{ label: 'About', href: '/about' },
|
{ label: 'About', href: '/about' },
|
||||||
{ label: 'Services', href: '/services' }
|
{ label: 'Services', href: '/services' }
|
||||||
],
|
],
|
||||||
ctaButton: { label: 'Book Now', href: '/book' }
|
ctaButton: { label: 'Book Now', href: '/book' },
|
||||||
|
homePage: 'home'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultFooter: FooterGlobal = {
|
export const defaultFooter: FooterGlobal = {
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,7 @@ export const load: LayoutServerLoad = async ({ locals, url }) => {
|
||||||
getGlobal(locals.pb, 'colors', defaultColors)
|
getGlobal(locals.pb, 'colors', defaultColors)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!header.homePage) header.homePage = defaultHeader.homePage;
|
||||||
|
|
||||||
return { header, footer, colors, user: locals.user, url: { pathname: url.pathname } };
|
return { header, footer, colors, user: locals.user, url: { pathname: url.pathname } };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,21 @@
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
import { defaultHeader } from '$lib/types';
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals }) => {
|
export const load: PageServerLoad = async ({ locals }) => {
|
||||||
|
// Get home page slug from header global, fallback to 'home'
|
||||||
|
let homeSlug = defaultHeader.homePage;
|
||||||
try {
|
try {
|
||||||
const page = await locals.pb.collection('pages').getFirstListItem('slug = "home" && published = true');
|
const header = await locals.pb.collection('globals').getFirstListItem('key = "header"');
|
||||||
|
homeSlug = header.data?.homePage || homeSlug;
|
||||||
|
} catch {
|
||||||
|
// Use default
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const page = await locals.pb
|
||||||
|
.collection('pages')
|
||||||
|
.getFirstListItem(`slug = "${homeSlug}" && published = true`);
|
||||||
return { page };
|
return { page };
|
||||||
} catch {
|
} catch {
|
||||||
throw error(404, 'Page not found');
|
throw error(404, 'Page not found');
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,11 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||||
getGlobal(locals.pb, 'colors', defaultColors)
|
getGlobal(locals.pb, 'colors', defaultColors)
|
||||||
]);
|
]);
|
||||||
return { header, footer, colors };
|
|
||||||
|
// Fetch all pages for the home page selector
|
||||||
|
const pages = await locals.pb.collection('pages').getFullList({ sort: 'slug' });
|
||||||
|
|
||||||
|
return { header, footer, colors, pages };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,14 @@
|
||||||
<h3 class="mt-6 font-bold">CTA button</h3>
|
<h3 class="mt-6 font-bold">CTA button</h3>
|
||||||
<input class="input input-bordered mb-2 w-full" bind:value={header.ctaButton.label} placeholder="Label" />
|
<input class="input input-bordered mb-2 w-full" bind:value={header.ctaButton.label} placeholder="Label" />
|
||||||
<input class="input input-bordered w-full" bind:value={header.ctaButton.href} placeholder="Href" />
|
<input class="input input-bordered w-full" bind:value={header.ctaButton.href} placeholder="Href" />
|
||||||
|
<h3 class="mt-6 font-bold">Home page</h3>
|
||||||
|
<select class="select select-bordered w-full" bind:value={header.homePage}>
|
||||||
|
<option value="">— Select a page —</option>
|
||||||
|
{#each data.pages as page}
|
||||||
|
<option value={page.slug}>{page.title} [{page.slug}]</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
<p class="text-sm text-base-content/60 mt-1">The page that "/" will redirect to.</p>
|
||||||
<div class="flex-grow"></div>
|
<div class="flex-grow"></div>
|
||||||
<button class="btn btn-primary mt-6 block w-full" type="submit">Save header</button>
|
<button class="btn btn-primary mt-6 block w-full" type="submit">Save header</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ services:
|
||||||
POCKETBASE_INTERNAL_URL: http://pocketbase:80
|
POCKETBASE_INTERNAL_URL: http://pocketbase:80
|
||||||
PUBLIC_POCKETBASE_URL: http://localhost:8090
|
PUBLIC_POCKETBASE_URL: http://localhost:8090
|
||||||
ORIGIN: http://localhost:3000
|
ORIGIN: http://localhost:3000
|
||||||
|
BODY_SIZE_LIMIT: 5242880 # 5MB
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue