@zeyolabs/shopping 2026.11.48 → 2026.11.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/basket/pages/Basket.svelte +4 -2
- package/bundles/pages/Bundle.svelte +3 -2
- package/catalogue/pages/Category.svelte +12 -2
- package/catalogue/pages/Product.svelte +2 -3
- package/catalogue/pages/Search.svelte +4 -2
- package/catalogue/pages/Shop.svelte +11 -2
- package/checkout/pages/CheckoutSuccess.svelte +4 -2
- package/customers/pages/Account.svelte +3 -2
- package/fulfilment/manager.server.ts +4 -2
- package/fulfilment/service.server.ts +2 -1
- package/orders/pages/Order.svelte +3 -2
- package/package.json +3 -3
- package/ui/PageTitle.svelte +0 -40
package/README.md
CHANGED
|
@@ -22,7 +22,9 @@ One folder per feature (library, client, service, manager, remote functions, pag
|
|
|
22
22
|
1. Register the site's config once on the server: `configureShopping({...})` (brand, shipping,
|
|
23
23
|
order prefix, `db`, secret names, `mail`), imported by `hooks.server.ts`, and pass its secret
|
|
24
24
|
names to `runWithContext`.
|
|
25
|
-
2. In the root layout, `setShopContext({ imageBaseUrl, siteName, siteUrl, supportEmail })
|
|
25
|
+
2. In the root layout, `setShopContext({ imageBaseUrl, siteName, siteUrl, supportEmail })`, and
|
|
26
|
+
`setHeadContext({ siteName, siteUrl })` from `@zeyolabs/ui/head/context`: the shop pages' `<head>`
|
|
27
|
+
tags come from `@zeyolabs/ui`'s `Head`.
|
|
26
28
|
3. Thin routes: render the pages (`<Basket startCheckout={...} />`, `<Shop description intro shop={data.shop} />`)
|
|
27
29
|
and re-export handlers and loads from `@zeyolabs/shopping/<feature>/*.server`.
|
|
28
30
|
4. Tailwind must scan the components: `@source "../node_modules/@zeyolabs/shopping";`.
|
|
@@ -7,15 +7,16 @@
|
|
|
7
7
|
import { Form } from '@zeyolabs/ui/form';
|
|
8
8
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
9
9
|
import { Select } from '@zeyolabs/ui/form/primitives';
|
|
10
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
10
11
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
11
12
|
import Stack from '@zeyolabs/ui/layout/Stack.svelte';
|
|
12
13
|
import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
|
|
13
14
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
14
15
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
16
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
15
17
|
import { toast } from 'svelte-sonner';
|
|
16
18
|
|
|
17
19
|
import { shopContext } from '../../context';
|
|
18
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
19
20
|
import { ErrorMessage } from '../../utils/errors';
|
|
20
21
|
import { Images } from '../../utils/images';
|
|
21
22
|
import { Money } from '../../utils/money';
|
|
@@ -46,7 +47,8 @@
|
|
|
46
47
|
}
|
|
47
48
|
</script>
|
|
48
49
|
|
|
49
|
-
<
|
|
50
|
+
<Head description="Your basket." title="Basket" />
|
|
51
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Basket</Title>
|
|
50
52
|
|
|
51
53
|
<Boundary message="Could not load your basket.">
|
|
52
54
|
{let [summary, countries] = $derived(await Promise.all([getBasket(), getShippableCountries()]))}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import Minus from '@lucide/svelte/icons/minus';
|
|
5
5
|
import Plus from '@lucide/svelte/icons/plus';
|
|
6
6
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
7
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
7
8
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
8
9
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
9
10
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
@@ -12,7 +13,6 @@
|
|
|
12
13
|
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
13
14
|
|
|
14
15
|
import { shopContext } from '../../context';
|
|
15
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
16
16
|
import { ErrorMessage } from '../../utils/errors';
|
|
17
17
|
import { Images } from '../../utils/images';
|
|
18
18
|
import { Money } from '../../utils/money';
|
|
@@ -172,7 +172,8 @@
|
|
|
172
172
|
}
|
|
173
173
|
</script>
|
|
174
174
|
|
|
175
|
-
<
|
|
175
|
+
<Head description={bundle.description.slice(0, 160)} title={bundle.name} />
|
|
176
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>{bundle.name}</Title>
|
|
176
177
|
|
|
177
178
|
{#if bundle.description}
|
|
178
179
|
<Text class="-mt-4 mb-4 max-w-prose whitespace-pre-line" color="secondary"
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
+
import { page } from '$app/state';
|
|
4
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
3
5
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
6
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
4
7
|
|
|
5
8
|
import type { getCategoryPage } from '../client.remote';
|
|
6
9
|
|
|
7
10
|
import { shopContext } from '../../context';
|
|
8
11
|
import PageLinks from '../../ui/PageLinks.svelte';
|
|
9
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
10
12
|
import ProductCard from '../components/ProductCard.svelte';
|
|
11
13
|
|
|
12
14
|
/** From the route's server `load` (`categoryLoad`). */
|
|
13
15
|
let { data }: { data: Awaited<ReturnType<typeof getCategoryPage>> } = $props();
|
|
14
16
|
|
|
15
17
|
const context = shopContext();
|
|
18
|
+
|
|
19
|
+
// Each listing page is its own page, so `?page=N` stays in the canonical; other parameters don't.
|
|
20
|
+
const listingPage = $derived(Number(page.url.searchParams.get('page')) || 1);
|
|
21
|
+
const canonical = $derived(
|
|
22
|
+
listingPage > 1 ? `${page.url.pathname}?page=${listingPage}` : page.url.pathname
|
|
23
|
+
);
|
|
16
24
|
</script>
|
|
17
25
|
|
|
18
26
|
<Text class="mb-2"><a class="underline" href={resolve('/shop')}>All products</a></Text>
|
|
19
|
-
<
|
|
27
|
+
<Head
|
|
28
|
+
{canonical}
|
|
20
29
|
description="Buy {data.category.name} from {context.siteName}."
|
|
21
30
|
title={data.category.name}
|
|
22
31
|
/>
|
|
32
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>{data.category.name}</Title>
|
|
23
33
|
|
|
24
34
|
{#if data.category.description}
|
|
25
35
|
<Text class="-mt-6 mb-6 max-w-prose whitespace-pre-line" color="secondary">
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { Form } from '@zeyolabs/ui/form';
|
|
7
7
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
8
8
|
import ImageGallery from '@zeyolabs/ui/gallery/ImageGallery.svelte';
|
|
9
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
9
10
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
10
11
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
11
12
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
@@ -18,7 +19,6 @@
|
|
|
18
19
|
import { shopContext } from '../../context';
|
|
19
20
|
import Reviews from '../../reviews/components/Reviews.svelte';
|
|
20
21
|
import { Stock } from '../../stock/library';
|
|
21
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
22
22
|
import Stars from '../../ui/Stars.svelte';
|
|
23
23
|
import { Images } from '../../utils/images';
|
|
24
24
|
import { Money } from '../../utils/money';
|
|
@@ -49,9 +49,8 @@
|
|
|
49
49
|
: 0
|
|
50
50
|
)}
|
|
51
51
|
|
|
52
|
-
<
|
|
52
|
+
<Head
|
|
53
53
|
description={(product.shortDescription || product.description).slice(0, 160)}
|
|
54
|
-
heading={false}
|
|
55
54
|
title={product.name}
|
|
56
55
|
/>
|
|
57
56
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
2
3
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
3
4
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
4
5
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
6
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
5
7
|
|
|
6
8
|
import type { searchShop } from '../client.remote';
|
|
7
9
|
|
|
8
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
9
10
|
import ProductCard from '../components/ProductCard.svelte';
|
|
10
11
|
|
|
11
12
|
let {
|
|
@@ -16,7 +17,8 @@
|
|
|
16
17
|
} = $props();
|
|
17
18
|
</script>
|
|
18
19
|
|
|
19
|
-
<
|
|
20
|
+
<Head description="Search the shop." title="Search" />
|
|
21
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Search</Title>
|
|
20
22
|
|
|
21
23
|
<svelte:head>
|
|
22
24
|
<meta name="robots" content="noindex, follow" />
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
+
import { page } from '$app/state';
|
|
4
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
3
5
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
4
6
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
5
7
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
8
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
6
9
|
|
|
7
10
|
import type { getShop } from '../client.remote';
|
|
8
11
|
|
|
9
12
|
import PageLinks from '../../ui/PageLinks.svelte';
|
|
10
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
11
13
|
import ProductCard from '../components/ProductCard.svelte';
|
|
12
14
|
|
|
13
15
|
let {
|
|
@@ -22,9 +24,16 @@
|
|
|
22
24
|
/** From the route's server `load` (`shopLoad`). */
|
|
23
25
|
shop: Awaited<ReturnType<typeof getShop>>;
|
|
24
26
|
} = $props();
|
|
27
|
+
|
|
28
|
+
// Each listing page is its own page, so `?page=N` stays in the canonical; other parameters don't.
|
|
29
|
+
const listingPage = $derived(Number(page.url.searchParams.get('page')) || 1);
|
|
30
|
+
const canonical = $derived(
|
|
31
|
+
listingPage > 1 ? `${page.url.pathname}?page=${listingPage}` : page.url.pathname
|
|
32
|
+
);
|
|
25
33
|
</script>
|
|
26
34
|
|
|
27
|
-
<
|
|
35
|
+
<Head {canonical} {description} title="Shop" />
|
|
36
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Shop</Title>
|
|
28
37
|
|
|
29
38
|
{#if intro}
|
|
30
39
|
<Text class="-mt-6 mb-6 max-w-prose" color="secondary">{intro}</Text>
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
3
|
import { page } from '$app/state';
|
|
4
4
|
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
5
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
5
6
|
import SkeletonText from '@zeyolabs/ui/skeleton/SkeletonText.svelte';
|
|
6
7
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
8
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
7
9
|
|
|
8
10
|
import { getCheckoutOrder } from '../../orders/client.remote';
|
|
9
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
10
11
|
|
|
11
12
|
const sessionId = page.url.searchParams.get('session_id') ?? '';
|
|
12
13
|
</script>
|
|
13
14
|
|
|
14
|
-
<
|
|
15
|
+
<Head description="Thank you for your order." title="Thank you" />
|
|
16
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Thank you</Title>
|
|
15
17
|
|
|
16
18
|
<Boundary message="Could not load your order number. It will be in your confirmation email.">
|
|
17
19
|
<!-- `/checkout/complete` has already fulfilled the order and emptied the basket on the server. -->
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
|
|
4
4
|
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
5
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
5
6
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
6
7
|
import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
|
|
7
8
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
8
9
|
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
9
10
|
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
10
11
|
|
|
11
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
12
12
|
import { Money } from '../../utils/money';
|
|
13
13
|
import { getMyOrders } from '../client.remote';
|
|
14
14
|
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
};
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
|
-
<
|
|
32
|
+
<Head description="Your orders." title="Your account" />
|
|
33
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Your account</Title>
|
|
33
34
|
|
|
34
35
|
<svelte:head>
|
|
35
36
|
<meta name="robots" content="noindex, nofollow" />
|
|
@@ -111,7 +111,8 @@ export const FulfilmentManager = {
|
|
|
111
111
|
async saveDetails(number: string, details: OrderDetails) {
|
|
112
112
|
const db = shopping().db();
|
|
113
113
|
if (details.shippingService) {
|
|
114
|
-
const
|
|
114
|
+
const shipping = new ShippingService(db);
|
|
115
|
+
const known = await shipping.services();
|
|
115
116
|
if (!known.some((s) => s.service === details.shippingService))
|
|
116
117
|
throw Error400('Choose one of the shop’s postage services.');
|
|
117
118
|
}
|
|
@@ -132,7 +133,8 @@ export const FulfilmentManager = {
|
|
|
132
133
|
|
|
133
134
|
/** Postage services the admin can pick when correcting an order. */
|
|
134
135
|
shippingServices() {
|
|
135
|
-
|
|
136
|
+
const shipping = new ShippingService(shopping().db());
|
|
137
|
+
return shipping.services();
|
|
136
138
|
},
|
|
137
139
|
|
|
138
140
|
/**
|
|
@@ -72,8 +72,9 @@ export class FulfilmentService {
|
|
|
72
72
|
]);
|
|
73
73
|
if (!address) return undefined;
|
|
74
74
|
const productIds = items.flatMap((item) => (item.productId === null ? [] : [item.productId]));
|
|
75
|
+
const coverService = new CoverService(this.db);
|
|
75
76
|
const [covers, estimatedWeightGrams] = await Promise.all([
|
|
76
|
-
|
|
77
|
+
coverService.covers(productIds),
|
|
77
78
|
this.estimateWeight(items),
|
|
78
79
|
]);
|
|
79
80
|
return {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { page } from '$app/state';
|
|
3
3
|
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
4
|
+
import Head from '@zeyolabs/ui/head/Head.svelte';
|
|
4
5
|
import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
|
|
5
6
|
import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
|
|
6
7
|
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
import { shopContext } from '../../context';
|
|
11
12
|
import { getOrderReviews } from '../../reviews/client.remote';
|
|
12
13
|
import ReviewForm from '../../reviews/components/ReviewForm.svelte';
|
|
13
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
14
14
|
import { Money } from '../../utils/money';
|
|
15
15
|
import { getOrderPage } from '../client.remote';
|
|
16
16
|
import { Orders } from '../library';
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
const date = new Intl.DateTimeFormat('en-GB', { dateStyle: 'long', timeZone: 'Europe/London' });
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
|
-
<
|
|
22
|
+
<Head description="Check the status of your order." title="Your order" />
|
|
23
|
+
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>Your order</Title>
|
|
23
24
|
|
|
24
25
|
<svelte:head>
|
|
25
26
|
<meta name="robots" content="noindex, nofollow, noarchive" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeyolabs/shopping",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.50",
|
|
4
4
|
"description": "Shop and order fulfilment for SvelteKit 3 on Cloudflare: catalogue, basket, Stripe Checkout, orders, Royal Mail Click & Drop, order emails, packing, pages and admin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@sveltejs/kit": "^3.1.1",
|
|
59
59
|
"@zeyolabs/kit": ">=2026.11.5",
|
|
60
|
-
"@zeyolabs/ui": ">=2026.11.
|
|
60
|
+
"@zeyolabs/ui": ">=2026.11.42",
|
|
61
61
|
"drizzle-orm": "^0.45.3",
|
|
62
62
|
"svelte": "^5.57.3",
|
|
63
63
|
"zod": "^4.6.5"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@eslint/js": "10.0.1",
|
|
69
69
|
"@sveltejs/kit": "3.2.0",
|
|
70
70
|
"@zeyolabs/kit": "2026.11.42",
|
|
71
|
-
"@zeyolabs/ui": "2026.11.
|
|
71
|
+
"@zeyolabs/ui": "2026.11.42",
|
|
72
72
|
"drizzle-orm": "0.45.4",
|
|
73
73
|
"eslint": "10.15.0",
|
|
74
74
|
"eslint-config-prettier": "10.1.8",
|
package/ui/PageTitle.svelte
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { page } from '$app/state';
|
|
3
|
-
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
4
|
-
|
|
5
|
-
import { shopContext } from '../context';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
description,
|
|
9
|
-
heading = true,
|
|
10
|
-
title,
|
|
11
|
-
}: {
|
|
12
|
-
description: string;
|
|
13
|
-
/** False when the page renders its own `<h1>` (the product page puts it beside the gallery). */
|
|
14
|
-
heading?: boolean;
|
|
15
|
-
title: string;
|
|
16
|
-
} = $props();
|
|
17
|
-
|
|
18
|
-
const context = shopContext();
|
|
19
|
-
// Canonical drops the query string except `?page=N` (each listing page is its own page), so
|
|
20
|
-
// other parameters don't count as duplicate pages.
|
|
21
|
-
const listingPage = $derived(Number(page.url.searchParams.get('page')) || 1);
|
|
22
|
-
const canonical = $derived(
|
|
23
|
-
`${context.siteUrl}${page.url.pathname}${listingPage > 1 ? `?page=${listingPage}` : ''}`
|
|
24
|
-
);
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<svelte:head>
|
|
28
|
-
<title>{title} | {context.siteName}</title>
|
|
29
|
-
<meta name="description" content={description} />
|
|
30
|
-
<link href={canonical} rel="canonical" />
|
|
31
|
-
<meta content={context.siteName} property="og:site_name" />
|
|
32
|
-
<meta content={title} property="og:title" />
|
|
33
|
-
<meta content={description} property="og:description" />
|
|
34
|
-
<meta content={canonical} property="og:url" />
|
|
35
|
-
<meta content="website" property="og:type" />
|
|
36
|
-
</svelte:head>
|
|
37
|
-
|
|
38
|
-
{#if heading}
|
|
39
|
-
<Title class="mb-10 text-[var(--primary-strong)]" level={1}>{title}</Title>
|
|
40
|
-
{/if}
|