Optional basket page; Button blocks follow the site colour; Site design tidy-up #9
4 changed files with 12 additions and 13 deletions
|
|
@ -154,7 +154,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
|||
### Routing
|
||||
- **Admin app** (`app-admin`): All routes except `/login` are auth-guarded in `hooks.server.ts` (which also refreshes the token per request and sets the cookie's `Secure` flag from the real scheme). The root layout renders the admin shell (grouped sidebar) except on `/login` and `/preview`. The `/preview` route reads `sessionStorage` set by the page editor (same-origin, so it works).
|
||||
- **Public app** (`app-public`): No auth guard. The root layout always renders Header/Footer. `+layout.server.ts` fetches header/footer/colors globals + basket/items/slots for every page.
|
||||
- **Booking and basket links**: booking = the header CTA's address, basket = the optional basket page (`header.basketPage`; '' = the CTA's address), both from `shopLinks(header)` in `packages/shared/src/types.ts` (blocks read `page.data.header`) — never hard-code `/book`.
|
||||
- **Booking and basket links**: booking = the header CTA's address, basket = the optional basket page slug typed in Site design (`header.basketPage`; '' = the CTA's address), both from `shopLinks(header)` in `packages/shared/src/types.ts` (blocks read `page.data.header`) — never hard-code `/book`.
|
||||
- **Class names in components are written out whole** (`'btn-primary'`, not `` `btn-${variant}` ``): Tailwind only generates classes it finds in the source, so a built-up name silently gets no style.
|
||||
- `+page.server.ts` for home fetches `slug = "home" && published = true`
|
||||
- `[slug]/+page.server.ts` fetches by dynamic slug
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ Setup:
|
|||
```
|
||||
Copy the printed `whsec_…` signing secret into `STRIPE_WEBHOOK_SECRET`.
|
||||
4. Import the updated `pb_schema.json` (adds `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`). Two visitors can't take the same place: holds are checked and written in one PocketBase transaction (see *Slot availability*).
|
||||
5. Create a published page (e.g. slug `book`) with a `shop` block and point the header CTA at it (*Site design → Header*); hero buttons without an address and *Book another* after paying lead there too. Put a `checkout` block on the same page, or on a page of its own picked as the optional *Basket page*: the basket in the header and *view basket* in the shop lead there (empty = the CTA's address). Site design warns when the basket's page isn't published or has no `checkout` block.
|
||||
5. Create a published page (e.g. slug `book`) with a `shop` block and point the header CTA at it (*Site design → Header*); hero buttons without an address and *Book another* after paying lead there too. Put a `checkout` block on the same page, or on a page of its own whose slug you type as the optional *Basket page*: the basket in the header and *view basket* in the shop lead there (empty = the CTA's address). Site design warns when the basket's page isn't published or has no `checkout` block.
|
||||
|
||||
## Bundles and codes
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@
|
|||
|
||||
// The page the basket links lead to: the basket page, else the CTA's address when that is a page here.
|
||||
function basketProblem() {
|
||||
const page = pageBySlug(shopLinks(header).basket.replace(/^\/|\/$/g, ''));
|
||||
if (!page) return '';
|
||||
const slug = shopLinks(header).basket.replace(/^\/|\/$/g, '');
|
||||
const page = pageBySlug(slug);
|
||||
// The CTA may point anywhere (even another site); a typed basket slug must be a page here.
|
||||
if (!page) return header.basketPage?.trim() ? `There is no page with the slug “${slug}”.` : '';
|
||||
if (!page.published) return `“${page.title}” isn’t published yet.`;
|
||||
if (!page.hasCheckout) return `“${page.title}” has no Checkout block, so people can’t pay from it.`;
|
||||
return '';
|
||||
|
|
@ -105,13 +107,8 @@
|
|||
</div>
|
||||
<p class="mt-1 text-sm text-base-content/60">Hero buttons without an address and “Book another” after paying lead here too.</p>
|
||||
<h3 class="mt-6 mb-2 font-bold">Basket page <span class="font-normal text-base-content/50">(optional)</span></h3>
|
||||
<select class="select w-full" aria-label="Basket page" bind:value={header.basketPage}>
|
||||
<option value="">— Same as the CTA button —</option>
|
||||
{#each data.pages as page (page.id)}
|
||||
<option value={page.slug}>{page.title} [{page.slug}]</option>
|
||||
{/each}
|
||||
</select>
|
||||
<p class="mt-1 text-sm text-base-content/60">Where people pay: the basket in the header and “view basket” in the shop lead here. Leave it empty if the CTA button’s page has the Checkout block.</p>
|
||||
<input class="input w-full" aria-label="Basket page" bind:value={header.basketPage} placeholder="Same as the CTA button" />
|
||||
<p class="mt-1 text-sm text-base-content/60">The slug of the page where people pay, e.g. <code>basket</code>: the basket in the header and “view basket” in the shop lead there. Leave it empty if the CTA button’s page has the Checkout block.</p>
|
||||
{#if basketProblem()}<p class="mt-1 text-sm font-semibold">⚠ {basketProblem()}</p>{/if}
|
||||
<h3 class="mt-6 mb-2 font-bold">Home page</h3>
|
||||
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export type HeaderGlobal = {
|
|||
/** The header button. Its address is also where hero buttons without one and "Book another" lead. */
|
||||
ctaButton: { label: string; href: string };
|
||||
homePage: string;
|
||||
/** Slug of the page with the Checkout block: the basket in the header and "view basket" lead here ('' = the CTA button's address). */
|
||||
/** Slug of the page with the Checkout block, typed in Site design: the basket in the header and "view basket" lead here ('' = the CTA button's address). */
|
||||
basketPage?: string;
|
||||
};
|
||||
|
||||
|
|
@ -95,7 +95,9 @@ export const defaultHeader: HeaderGlobal = {
|
|||
/** Where booking (the CTA button's address) and the basket (the basket page, else the same address) are. */
|
||||
export function shopLinks(header?: Partial<HeaderGlobal> | null) {
|
||||
const booking = header?.ctaButton?.href || '/book';
|
||||
return { booking, basket: header?.basketPage ? `/${header.basketPage}` : booking };
|
||||
// Typed by hand, so tolerate "/basket", "basket/" and spaces.
|
||||
const basketSlug = header?.basketPage?.trim().replace(/^\/+|\/+$/g, '');
|
||||
return { booking, basket: basketSlug ? `/${basketSlug}` : booking };
|
||||
}
|
||||
|
||||
export const defaultFooter: FooterGlobal = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue