@tansy/theme-storefront 0.0.0-stage → 0.1.1
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/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/client.d.ts +81 -0
- package/client.js +461 -0
- package/fonts/GeistVF.woff +0 -0
- package/fonts/README.md +1 -0
- package/icons.d.ts +21 -0
- package/icons.js +23 -0
- package/index.d.ts +21 -0
- package/index.js +90 -0
- package/lib.d.ts +11 -0
- package/lib.js +17 -0
- package/messages.d.ts +159 -0
- package/messages.js +159 -0
- package/package.json +35 -4
- package/render.d.ts +4 -0
- package/render.js +274 -0
- package/schema.json +106 -0
- package/styles.css +461 -0
- package/theme.css +2454 -0
package/render.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import localFont from "next/font/local";
|
|
3
|
+
import { BillingButton, SubscribeButton } from "@tansy/payments/react";
|
|
4
|
+
import { Cart as ShopCart, CartLink, OrderReturn } from "@tansy/shop/react";
|
|
5
|
+
import { OrderList } from "@tansy/shop/render";
|
|
6
|
+
import { Menu, Pager, pickWords, RichText, StreamField } from "tansy/react";
|
|
7
|
+
import { defineThemeComponents } from "tansy/theme";
|
|
8
|
+
import { BackLink, BuyBox, PageTransition, ProductGallery, ProductSearch, ShareButton, ViewTransitionNames } from "./client";
|
|
9
|
+
import { ArrowUpRight, Bag, Bars, BookOpen, ChevronLeft, Download, Globe, Lock, Search, Store, User } from "./icons";
|
|
10
|
+
import { cardAnchor, cx, fileIds, ids, money, num, text } from "./lib";
|
|
11
|
+
import { messages } from "./messages";
|
|
12
|
+
import "./theme.css";
|
|
13
|
+
// Served from the site's own origin, as font-src 'self' requires.
|
|
14
|
+
const font = localFont({ src: "./fonts/GeistVF.woff", variable: "--storefront-font", weight: "100 900" });
|
|
15
|
+
const items = (list) => list?.items ?? [];
|
|
16
|
+
const byId = (list) => new Map(items(list).map((record) => [record.id, record]));
|
|
17
|
+
/** An address in the page's language: "/shop" is "/ar/shop" on an Arabic page. */
|
|
18
|
+
const inLanguage = (props, path) => props.language?.href(path) ?? path;
|
|
19
|
+
/** From the collection's URL pattern, so links follow whatever the owner sets. */
|
|
20
|
+
const hrefOf = (record, props) => (record && text(record.recordPath) ? inLanguage(props, text(record.recordPath)) : undefined);
|
|
21
|
+
/** The shop's currency and front page, from the `store` list every template here reads. */
|
|
22
|
+
const storeOf = (data) => items(data.store)[0];
|
|
23
|
+
const currencyOf = (data) => text(storeOf(data)?.currency) || "usd";
|
|
24
|
+
const shopHref = (props) => hrefOf(storeOf(props.data), props) ?? inLanguage(props, "/shop");
|
|
25
|
+
const forClient = (words) => (words ? pickWords(words, "storefront") : undefined);
|
|
26
|
+
/* ------------------------------------------------------------------ shared */
|
|
27
|
+
const container = "sf:mx-auto sf:w-full sf:max-w-wide sf:px-gutter";
|
|
28
|
+
const iconButton = "sf:relative sf:grid sf:size-11 sf:shrink-0 sf:place-items-center sf:rounded-full sf:border sf:border-line sf:bg-page sf:text-ink sf:no-underline sf:transition sf:hover:border-ink sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent";
|
|
29
|
+
const pill = "sf:inline-flex sf:h-10 sf:items-center sf:rounded-full sf:border sf:px-5 sf:text-sm sf:font-medium sf:no-underline sf:transition";
|
|
30
|
+
function SectionHeading({ id, title, aside }) {
|
|
31
|
+
return (_jsxs("div", { className: "sf:mb-8 sf:flex sf:flex-wrap sf:items-end sf:justify-between sf:gap-4", children: [_jsx("h2", { id: id, className: "sf:text-3xl sf:font-semibold sf:tracking-tight sf:text-ink sf:sm:text-4xl", children: title }), aside && _jsx("p", { className: "sf:text-sm sf:text-muted", children: aside })] }));
|
|
32
|
+
}
|
|
33
|
+
/* ------------------------------------------------------------------ layout */
|
|
34
|
+
function Brand({ branding, language }) {
|
|
35
|
+
return (_jsxs("a", { href: inLanguage({ language }, "/"), className: "sf:flex sf:shrink-0 sf:items-center sf:gap-2.5 sf:text-2xl sf:font-bold sf:tracking-tight sf:text-ink sf:no-underline", children: [branding.logoUrl && _jsx("img", { src: branding.logoUrl, alt: "", width: 32, height: 32, className: "sf:size-8 sf:rounded-full sf:object-cover" }), _jsx("span", { children: branding.name })] }));
|
|
36
|
+
}
|
|
37
|
+
/** The same page in each language it's published in, as one button however many languages the site adds. */
|
|
38
|
+
function LanguageSwitcher({ language, t }) {
|
|
39
|
+
if (!language)
|
|
40
|
+
return null;
|
|
41
|
+
const available = language.locales.filter((locale) => language.alternates[locale.code]);
|
|
42
|
+
if (available.length < 2)
|
|
43
|
+
return null;
|
|
44
|
+
return (_jsx("nav", { "aria-label": t("storefront.language"), children: _jsxs("details", { className: "sf-popover sf:relative", children: [_jsxs("summary", { className: iconButton, children: [_jsx(Globe, {}), _jsx("span", { className: "sf:sr-only", children: t("storefront.language") })] }), _jsx("ul", { className: "sf:absolute sf:end-0 sf:top-full sf:z-40 sf:mt-2 sf:min-w-48 sf:rounded-3xl sf:border sf:border-line sf:bg-page sf:p-2 sf:shadow-card", children: available.map((locale) => (_jsx("li", { children: _jsxs("a", { href: language.alternates[locale.code], hrefLang: locale.code, lang: locale.code, "aria-current": locale.code === language.locale ? "true" : undefined, className: "sf:flex sf:items-center sf:justify-between sf:gap-4 sf:rounded-2xl sf:px-3 sf:py-2 sf:text-ink sf:no-underline sf:hover:bg-surface sf:aria-[current]:font-semibold sf:aria-[current]:text-accent", children: [_jsx("span", { children: locale.label }), _jsx("span", { className: "sf:text-xs sf:text-muted sf:uppercase", children: locale.code })] }) }, locale.code))) })] }) }));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Moving between the theme's pages animates where the browser can: the page fades through, and a
|
|
48
|
+
* product's picture flies from its card to the product page and back. Every link here is a
|
|
49
|
+
* plain page load, so this is the browser's cross-document view transition, switched on only
|
|
50
|
+
* while a page in this theme's layout is showing, and never for visitors who ask for less motion.
|
|
51
|
+
* The animations themselves are in styles.css.
|
|
52
|
+
*/
|
|
53
|
+
const VIEW_TRANSITIONS = "@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }";
|
|
54
|
+
/** Which tab of the bar at the bottom of small screens a page belongs to. */
|
|
55
|
+
const TAB_OF = { home: "shop", "shop-store": "shop", "shop-categories": "shop", "shop-products": "shop", library: "library", "shop-cart": "cart", "shop-account": "orders" };
|
|
56
|
+
/**
|
|
57
|
+
* A dot under the current tab. It carries the same view-transition name on every page, so moving
|
|
58
|
+
* between tabs slides it from one to the other.
|
|
59
|
+
*/
|
|
60
|
+
const TabDot = () => _jsx("span", { "aria-hidden": "true", className: "sf-tab-dot", style: { viewTransitionName: "sf-tab-dot" } });
|
|
61
|
+
const tab = "sf-tab sf:relative sf:flex sf:min-w-0 sf:flex-1 sf:flex-col sf:items-center sf:justify-center sf:gap-1 sf:pt-2 sf:pb-1.5 sf:text-[0.6875rem] sf:font-medium sf:text-muted sf:no-underline sf:select-none sf:aria-[current]:text-accent";
|
|
62
|
+
/**
|
|
63
|
+
* The bar at the bottom of small screens, as an app has: the shop, search, the cart with its
|
|
64
|
+
* count, orders and the menu. The menu opens as a sheet from the bottom, with no script.
|
|
65
|
+
*/
|
|
66
|
+
function TabBar({ props, menu, current }) {
|
|
67
|
+
const { options, language, t, words } = props;
|
|
68
|
+
const shop = shopHref(props);
|
|
69
|
+
return (_jsx("nav", { "aria-label": t("storefront.tabs"), className: "sf-tabbar sf:fixed sf:inset-x-0 sf:bottom-0 sf:z-40 sf:border-t sf:border-line/70 sf:lg:hidden", children: _jsxs("div", { className: "sf:mx-auto sf:flex sf:max-w-xl sf:items-stretch sf:px-2", children: [_jsxs("a", { href: shop, className: tab, "aria-current": current === "shop" ? "page" : undefined, children: [_jsx(Store, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.tabShop") }), current === "shop" && _jsx(TabDot, {})] }), options.search && _jsxs("a", { href: `${shop}#sf-search`, className: tab, children: [_jsx(Search, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.tabSearch") })] }), options.library && _jsxs("a", { href: inLanguage({ language }, "/library"), className: tab, "aria-current": current === "library" ? "page" : undefined, children: [_jsx(BookOpen, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.library") }), current === "library" && _jsx(TabDot, {})] }), _jsx(CartLink, { className: cx(tab, "sf-tab-cart"), label: _jsxs(_Fragment, { children: [_jsx(Bag, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.cart") }), current === "cart" && _jsx(TabDot, {})] }), words: words ? pickWords(words, "shop") : undefined }), options.accountLinks && _jsxs("a", { href: inLanguage({ language }, "/orders"), className: tab, "aria-current": current === "orders" ? "page" : undefined, children: [_jsx(User, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.tabOrders") }), current === "orders" && _jsx(TabDot, {})] }), menu && (_jsxs("details", { className: "sf-sheet sf:flex sf:min-w-0 sf:flex-1", children: [_jsxs("summary", { className: cx(tab, "sf:w-full"), children: [_jsx(Bars, { className: "sf:size-6" }), _jsx("span", { children: t("storefront.openMenu") })] }), _jsxs("nav", { "aria-label": t("storefront.menu"), className: "sf-sheet-panel sf-menu sf-menu-stacked sf:fixed sf:inset-x-0 sf:bottom-0 sf:z-50 sf:max-h-[70dvh] sf:overflow-y-auto sf:rounded-t-[2rem] sf:border-t sf:border-line sf:bg-page sf:px-4 sf:pt-3 sf:shadow-card", children: [_jsx("span", { "aria-hidden": "true", className: "sf:mx-auto sf:mb-3 sf:block sf:h-1 sf:w-10 sf:rounded-full sf:bg-line" }), _jsx(Menu, { items: menu })] })] }))] }) }));
|
|
70
|
+
}
|
|
71
|
+
function Layout(props) {
|
|
72
|
+
const { branding, globals, options, children, language, t, words, collection } = props;
|
|
73
|
+
const menu = globals["site-menu"]?.items;
|
|
74
|
+
const hasMenu = Array.isArray(menu) && menu.length > 0;
|
|
75
|
+
const page = collection ?? "home";
|
|
76
|
+
return (_jsxs("div", { className: "sf-shell sf:flex sf:min-h-dvh sf:flex-col sf:bg-page sf:font-sans sf:text-ink sf:antialiased", "data-scheme": options.colorScheme, "data-page": page, children: [_jsx("style", { href: "sf-view-transitions", precedence: "default", children: VIEW_TRANSITIONS }), _jsx(ViewTransitionNames, {}), _jsx("a", { href: "#sf-content", className: "sf:sr-only sf:focus:not-sr-only sf:focus:fixed sf:focus:start-4 sf:focus:top-4 sf:focus:z-50 sf:focus:rounded-full sf:focus:bg-ink sf:focus:px-5 sf:focus:py-3 sf:focus:text-page", children: t("storefront.skip") }), _jsx("header", { className: "sf-header sf:sticky sf:top-0 sf:z-30 sf:border-b sf:border-line/70 sf:bg-page/85 sf:backdrop-blur-xl", children: _jsxs("div", { className: cx(container, "sf:flex sf:h-16 sf:items-center sf:gap-8 sf:lg:h-20"), children: [_jsx(Brand, { branding: branding, language: language }), hasMenu && _jsx("nav", { className: "sf-menu sf:hidden sf:lg:block", "aria-label": t("storefront.menu"), children: _jsx(Menu, { items: menu }) }), _jsxs("div", { className: "sf:ms-auto sf:flex sf:items-center sf:gap-2", children: [_jsx(LanguageSwitcher, { language: language, t: t }), options.library && (_jsxs("a", { href: inLanguage({ language }, "/library"), className: cx(iconButton, "sf:max-lg:hidden"), "aria-current": collection === "library" ? "page" : undefined, children: [_jsx(BookOpen, {}), _jsx("span", { className: "sf:sr-only", children: t("storefront.library") })] })), options.accountLinks && (_jsxs("a", { href: inLanguage({ language }, "/orders"), className: cx(iconButton, "sf:max-lg:hidden"), children: [_jsx(User, {}), _jsx("span", { className: "sf:sr-only", children: t("storefront.orders") })] })), _jsx(CartLink, { className: cx("sf-cart-button sf-header-cart", iconButton), label: _jsxs(_Fragment, { children: [_jsx(Bag, {}), _jsx("span", { className: "sf:sr-only", children: t("storefront.cart") })] }), words: words ? pickWords(words, "shop") : undefined })] })] }) }), _jsx("div", { id: "sf-content", className: "sf:flex-1", children: _jsx(PageTransition, { children: children }) }), _jsx(TabBar, { props: props, menu: hasMenu ? menu : null, current: TAB_OF[page] }), _jsx("footer", { className: "sf:mt-24 sf:rounded-t-[3rem] sf:bg-surface", children: _jsxs("div", { className: cx(container, "sf:grid sf:gap-10 sf:py-14 sf:md:grid-cols-[1fr_auto]"), children: [_jsxs("div", { className: "sf:flex sf:max-w-sm sf:flex-col sf:gap-3", children: [_jsx(Brand, { branding: branding, language: language }), _jsx("p", { className: "sf:text-muted", children: options.tagline || t("storefront.heroIntro") })] }), hasMenu && _jsx("nav", { className: "sf-menu sf-menu-footer", "aria-label": t("storefront.footerMenu"), children: _jsx(Menu, { items: menu }) }), _jsxs("p", { className: "sf:border-t sf:border-line sf:pt-6 sf:text-sm sf:text-muted sf:md:col-span-2", children: ["\u00A9 ", new Date().getFullYear(), " ", branding.name, ". ", t("storefront.rights")] })] }) })] }));
|
|
77
|
+
}
|
|
78
|
+
/* -------------------------------------------------------------- products */
|
|
79
|
+
/**
|
|
80
|
+
* The name a product's picture carries on its card and on its own page, so moving between them
|
|
81
|
+
* flies the picture from one to the other. Unique per product, as a page may name each only once.
|
|
82
|
+
*/
|
|
83
|
+
const productTransition = (id) => `sf-product-${id}`;
|
|
84
|
+
/**
|
|
85
|
+
* Marks a picture that leads to a product's page. A page may show the same product twice, such
|
|
86
|
+
* as the front page's spotlight beside its card, and may name it only once. So the picture tapped
|
|
87
|
+
* gets the name as the page is left (ViewTransitionNames in client.tsx), and that one flies.
|
|
88
|
+
*/
|
|
89
|
+
const flies = (product, href) => (href ? { "data-sf-vt": productTransition(product.id), "data-sf-vt-href": href } : {});
|
|
90
|
+
/** Physical, digital, or both, from the product's Format, for a badge. Empty when it has none. */
|
|
91
|
+
function formatLabel(product, t) {
|
|
92
|
+
const format = text(product.format);
|
|
93
|
+
return format === "physical" ? t("storefront.formatPhysical") : format === "digital" ? t("storefront.formatDigital") : format === "both" ? t("storefront.formatBoth") : "";
|
|
94
|
+
}
|
|
95
|
+
/** A product as a tall soft card: its picture with an arrow over it, then price and name. The whole card is one link. */
|
|
96
|
+
function ProductCard({ product, categories, props, eager = false }) {
|
|
97
|
+
const href = hrefOf(product, props);
|
|
98
|
+
const image = fileIds(product.images)[0];
|
|
99
|
+
const price = num(product.price);
|
|
100
|
+
const was = num(product.compareAtPrice);
|
|
101
|
+
const onSale = price !== null && was !== null && was > price;
|
|
102
|
+
const soldOut = product.stock === 0;
|
|
103
|
+
const format = formatLabel(product, props.t);
|
|
104
|
+
const category = categories.get(ids(product.categories)[0] ?? -1);
|
|
105
|
+
const subtitle = text(category?.name) || text(product.summary);
|
|
106
|
+
const currency = currencyOf(props.data);
|
|
107
|
+
return (_jsxs("article", { id: cardAnchor(product.id), className: "sf-press sf-card sf:group sf:relative sf:flex sf:flex-col sf:gap-4", lang: typeof product.locale === "string" ? product.locale : undefined, children: [_jsxs("div", { className: "sf:relative sf:isolate sf:grid sf:aspect-[4/5] sf:place-items-center sf:overflow-hidden sf:rounded-[3rem] sf:bg-surface sf:transition-shadow sf:duration-300 sf:group-hover:shadow-card", children: [_jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:inset-x-[12%] sf:top-[14%] sf:-z-10 sf:aspect-square sf:rounded-full sf:bg-page/60 sf:blur-xl" }), image
|
|
108
|
+
// eslint-disable-next-line @next/next/no-img-element -- an access-checked API address that redirects to a signed URL, which next/image can't optimize
|
|
109
|
+
? _jsx("img", { src: props.fileUrl(image, "800x0"), alt: props.fileText(image).alt, loading: eager ? "eager" : "lazy", style: { viewTransitionName: productTransition(product.id) }, ...flies(product, href), className: cx("sf-vt-product sf:size-[80%] sf:object-contain sf:drop-shadow-[0_18px_22px_rgba(0,0,0,0.16)] sf:transition-transform sf:duration-500 sf:ease-out sf:group-hover:scale-105 sf:group-hover:-rotate-2 sf:motion-reduce:transition-none", soldOut && "sf:opacity-60 sf:grayscale") })
|
|
110
|
+
: _jsx(Bag, { className: "sf:size-12 sf:text-muted/50", strokeWidth: 1 }), _jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-1/2 sf:left-1/2 sf:grid sf:size-14 sf:-translate-1/2 sf:place-items-center sf:rounded-full sf:border sf:border-page/60 sf:bg-page/40 sf:text-ink sf:backdrop-blur-md sf:transition sf:duration-300 sf:group-hover:scale-110 sf:group-hover:border-accent sf:group-hover:bg-accent sf:group-hover:text-on-accent", children: _jsx(ArrowUpRight, { className: "sf:size-5 sf:rtl:-scale-x-100" }) }), format && _jsx("span", { className: "sf:absolute sf:end-5 sf:top-5 sf:rounded-full sf:bg-page/80 sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:text-ink sf:backdrop-blur", children: format }), (onSale || soldOut) && (_jsx("span", { className: cx("sf:absolute sf:start-5 sf:top-5 sf:rounded-full sf:px-3 sf:py-1 sf:text-xs sf:font-semibold", soldOut ? "sf:bg-ink sf:text-page" : "sf:bg-accent sf:text-on-accent"), children: soldOut ? props.t("storefront.soldOut") : props.t("storefront.sale") }))] }), _jsxs("div", { className: "sf:flex sf:flex-col sf:gap-1 sf:px-2", children: [price !== null && (_jsxs("p", { className: "sf:flex sf:items-baseline sf:gap-2 sf:text-xl sf:font-semibold sf:tracking-tight sf:text-ink sf:tabular-nums", children: [money(props.formatNumber, price, currency), onSale && _jsx("s", { className: "sf:text-sm sf:font-normal sf:text-muted", children: money(props.formatNumber, was, currency) })] })), _jsx("h3", { className: "sf:text-base sf:font-medium sf:text-ink", children: href
|
|
111
|
+
? _jsx("a", { href: href, className: "sf:text-inherit sf:no-underline sf:outline-none sf:after:absolute sf:after:inset-0 sf:after:rounded-[3rem] sf:focus-visible:after:outline-2 sf:focus-visible:after:outline-offset-4 sf:focus-visible:after:outline-accent", children: text(product.title) })
|
|
112
|
+
: text(product.title) }), subtitle && _jsx("p", { className: "sf:line-clamp-1 sf:text-sm sf:text-muted", children: subtitle })] })] }));
|
|
113
|
+
}
|
|
114
|
+
function ProductGrid({ products, props, empty }) {
|
|
115
|
+
if (!products.length) {
|
|
116
|
+
return (_jsxs("div", { className: "sf:grid sf:place-items-center sf:gap-3 sf:rounded-card sf:border sf:border-dashed sf:border-line sf:px-6 sf:py-20 sf:text-center sf:text-muted", children: [_jsx(Bag, { className: "sf:size-10", strokeWidth: 1.25 }), _jsx("p", { children: empty })] }));
|
|
117
|
+
}
|
|
118
|
+
const categories = byId(props.data.categories);
|
|
119
|
+
return (_jsx("ul", { className: "sf:grid sf:grid-cols-2 sf:gap-x-4 sf:gap-y-10 sf:sm:gap-x-6 sf:md:grid-cols-3 sf:xl:grid-cols-4", children: products.map((product, index) => _jsx("li", { children: _jsx(ProductCard, { product: product, categories: categories, props: props, eager: index < 4 }) }, product.id)) }));
|
|
120
|
+
}
|
|
121
|
+
/** Every category as a chip, the current one filled. "All" is the shop's own page. */
|
|
122
|
+
function CategoryChips({ props, current }) {
|
|
123
|
+
const categories = items(props.data.categories);
|
|
124
|
+
if (!categories.length)
|
|
125
|
+
return null;
|
|
126
|
+
const chip = (active) => cx(pill, active ? "sf:border-ink sf:bg-ink sf:text-page" : "sf:border-line sf:bg-page sf:text-ink sf:hover:border-ink");
|
|
127
|
+
// The chosen chip has the same name on every page, so moving between categories slides it across.
|
|
128
|
+
const slide = (active) => (active ? { viewTransitionName: "sf-chip" } : undefined);
|
|
129
|
+
return (_jsx("nav", { "aria-label": props.t("storefront.categories"), className: "sf-chips sf:-mx-gutter sf:mb-10 sf:overflow-x-auto sf:px-gutter", children: _jsxs("ul", { className: "sf:flex sf:w-max sf:gap-2", children: [_jsx("li", { children: _jsx("a", { href: shopHref(props), className: chip(current === "all"), style: slide(current === "all"), "aria-current": current === "all" ? "page" : undefined, children: props.t("storefront.all") }) }), categories.map((category) => {
|
|
130
|
+
const href = hrefOf(category, props);
|
|
131
|
+
const active = current === category.id;
|
|
132
|
+
return _jsx("li", { children: href ? _jsx("a", { href: href, className: chip(active), style: slide(active), "aria-current": active ? "page" : undefined, children: text(category.name) }) : _jsx("span", { className: chip(active), children: text(category.name) }) }, category.id);
|
|
133
|
+
})] }) }));
|
|
134
|
+
}
|
|
135
|
+
function ProductPager({ props, list }) {
|
|
136
|
+
return _jsx(Pager, { list: list, path: props.path, previous: props.t("storefront.previousPage"), next: props.t("storefront.nextPage"), className: "sf-pager", words: props.words });
|
|
137
|
+
}
|
|
138
|
+
/** The newest product, large, beside the front page's heading. */
|
|
139
|
+
function Spotlight({ product, props }) {
|
|
140
|
+
const image = fileIds(product.images)[0];
|
|
141
|
+
const href = hrefOf(product, props);
|
|
142
|
+
const price = num(product.price);
|
|
143
|
+
return (_jsxs("div", { className: "sf:relative sf:isolate sf:mx-auto sf:hidden sf:aspect-square sf:w-full sf:max-w-[34rem] sf:place-items-center sf:lg:grid", children: [_jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:inset-[6%] sf:-z-20 sf:rounded-full sf:bg-surface" }), _jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-[56%] sf:left-1/2 sf:-z-10 sf:h-[24%] sf:w-[112%] sf:-translate-x-1/2 sf:-rotate-6 sf:rounded-[50%] sf:border sf:border-ink/15" }), image ? _jsx("img", { src: props.fileUrl(image, "800x0"), alt: props.fileText(image).alt, ...flies(product, href), className: "sf-vt-product sf:size-[74%] sf:object-contain sf:drop-shadow-[0_30px_36px_rgba(0,0,0,0.2)]" }) : _jsx(Bag, { className: "sf:size-20 sf:text-muted/40", strokeWidth: 1 }), _jsxs("div", { className: "sf:absolute sf:start-0 sf:bottom-[8%] sf:flex sf:max-w-[18rem] sf:items-center sf:gap-4 sf:rounded-3xl sf:border sf:border-line sf:bg-page/90 sf:p-4 sf:pe-5 sf:shadow-card sf:backdrop-blur", children: [_jsxs("div", { className: "sf:min-w-0", children: [_jsx("p", { className: "sf:text-xs sf:font-medium sf:tracking-wide sf:text-accent sf:uppercase", children: props.t("storefront.featured") }), _jsx("p", { className: "sf:truncate sf:font-semibold sf:text-ink", children: href ? _jsx("a", { href: href, className: "sf:text-inherit sf:no-underline sf:after:absolute sf:after:inset-0 sf:after:rounded-3xl", children: text(product.title) }) : text(product.title) }), price !== null && _jsx("p", { className: "sf:text-sm sf:text-muted sf:tabular-nums", children: money(props.formatNumber, price, currencyOf(props.data)) })] }), _jsx("span", { "aria-hidden": "true", className: "sf:grid sf:size-10 sf:shrink-0 sf:place-items-center sf:rounded-full sf:bg-accent sf:text-on-accent", children: _jsx(ArrowUpRight, { className: "sf:size-4 sf:rtl:-scale-x-100" }) })] })] }));
|
|
144
|
+
}
|
|
145
|
+
/* --------------------------------------------------------------- templates */
|
|
146
|
+
/**
|
|
147
|
+
* The front page, at the site's root and at the shop's address. On the shop's address, its
|
|
148
|
+
* heading and introduction come from the Shop page record.
|
|
149
|
+
*/
|
|
150
|
+
function Front(props) {
|
|
151
|
+
const { record, data, options, t, words } = props;
|
|
152
|
+
const products = items(data.products);
|
|
153
|
+
const firstPage = (data.products?.page ?? 1) === 1;
|
|
154
|
+
const intro = record?.intro !== undefined && record?.intro !== null
|
|
155
|
+
? _jsx("div", { className: "sf-prose sf:max-w-lg sf:text-lg sf:text-muted", children: _jsx(RichText, { doc: record.intro }) })
|
|
156
|
+
: _jsx("p", { className: "sf:max-w-lg sf:text-lg sf:text-muted", children: options.tagline || t("storefront.heroIntro") });
|
|
157
|
+
return (_jsxs("main", { children: [firstPage && (_jsxs("section", { className: cx(container, "sf:grid sf:items-center sf:gap-10 sf:pt-10 sf:pb-14 sf:lg:grid-cols-[1.1fr_1fr] sf:lg:pt-16"), children: [_jsxs("div", { className: "sf:flex sf:flex-col sf:items-start sf:gap-6", children: [_jsx("p", { className: "sf:rounded-full sf:bg-accent/10 sf:px-4 sf:py-1.5 sf:text-sm sf:font-medium sf:text-accent", children: t("storefront.kicker") }), _jsx("h1", { className: "sf:max-w-[12ch] sf:text-5xl sf:leading-[1.02] sf:font-semibold sf:tracking-tight sf:text-balance sf:text-ink sf:sm:text-6xl sf:xl:text-7xl", children: text(record?.title) || t("storefront.heroTitle") }), intro, options.search && _jsx(ProductSearch, { id: "sf-search", words: forClient(words), currency: currencyOf(data) })] }), products[0] && _jsx(Spotlight, { product: products[0], props: props })] })), _jsxs("section", { "aria-labelledby": "sf-products", className: cx(container, !firstPage && "sf:pt-12"), children: [_jsx(CategoryChips, { props: props, current: record ? "all" : null }), _jsx(SectionHeading, { id: "sf-products", title: firstPage ? t("storefront.newArrivals") : t("storefront.pageOf", { page: data.products?.page ?? 1 }), aside: data.products?.totalItems ? t("storefront.products", { count: data.products.totalItems }) : undefined }), _jsx(ProductGrid, { products: products, props: props, empty: t("storefront.noProducts") }), _jsx(ProductPager, { props: props, list: data.products })] })] }));
|
|
158
|
+
}
|
|
159
|
+
function Category(props) {
|
|
160
|
+
const { record, data, t } = props;
|
|
161
|
+
if (!record)
|
|
162
|
+
return null;
|
|
163
|
+
return (_jsxs("main", { children: [_jsxs("header", { className: cx(container, "sf:flex sf:flex-col sf:items-start sf:gap-4 sf:pt-10 sf:pb-10 sf:lg:pt-14"), children: [_jsxs(BackLink, { href: shopHref(props), className: "sf:inline-flex sf:items-center sf:gap-1 sf:text-sm sf:font-medium sf:text-muted sf:no-underline sf:hover:text-ink", children: [_jsx(ChevronLeft, { className: "sf:size-4 sf:rtl:-scale-x-100" }), t("storefront.back")] }), _jsx("h1", { className: "sf:text-5xl sf:font-semibold sf:tracking-tight sf:text-ink sf:sm:text-6xl", children: text(record.name) }), text(record.description) && _jsx("p", { className: "sf:max-w-2xl sf:text-lg sf:text-muted", children: text(record.description) })] }), _jsxs("section", { "aria-label": text(record.name), className: container, children: [_jsx(CategoryChips, { props: props, current: record.id }), (data.products?.totalItems ?? 0) > 0 && _jsx("p", { className: "sf:mb-6 sf:text-sm sf:text-muted", children: t("storefront.products", { count: data.products.totalItems }) }), _jsx(ProductGrid, { products: items(data.products), props: props, empty: t("storefront.emptyCategory") }), _jsx(ProductPager, { props: props, list: data.products })] })] }));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A product: its pictures on a stage, and beside them a panel with the price, options and two
|
|
167
|
+
* ways to buy. Below, its description and products like it.
|
|
168
|
+
*/
|
|
169
|
+
function Product(props) {
|
|
170
|
+
const { record, data, fileUrl, fileText, stream, t, words } = props;
|
|
171
|
+
if (!record)
|
|
172
|
+
return null;
|
|
173
|
+
const currency = currencyOf(data);
|
|
174
|
+
const categories = byId(data.categories);
|
|
175
|
+
const category = categories.get(ids(record.categories)[0] ?? -1);
|
|
176
|
+
const images = fileIds(record.images).map((id) => ({ src: fileUrl(id, "800x0"), thumb: fileUrl(id, "100x100"), alt: fileText(id).alt }));
|
|
177
|
+
const variants = items(data.variants).map((variant) => ({ id: variant.id, title: text(variant.title), price: num(variant.price), stock: num(variant.stock) }));
|
|
178
|
+
const more = (items(data.related).length ? items(data.related) : items(data.latest)).filter((product) => product.id !== record.id).slice(0, 4);
|
|
179
|
+
const description = Array.isArray(record.description) && record.description.length > 0;
|
|
180
|
+
return (_jsxs("main", { className: cx(container, "sf:pt-6 sf:lg:pt-10"), children: [_jsxs("div", { className: "sf:mb-6 sf:flex sf:items-center sf:justify-between sf:gap-4", children: [_jsxs("nav", { "aria-label": t("storefront.back"), className: "sf:flex sf:min-w-0 sf:items-center sf:gap-3", children: [_jsxs(BackLink, { href: shopHref(props), card: record.id, className: iconButton, children: [_jsx(ChevronLeft, { className: "sf:size-5 sf:rtl:-scale-x-100" }), _jsx("span", { className: "sf:sr-only", children: t("storefront.back") })] }), category && hrefOf(category, props) && _jsx("a", { href: hrefOf(category, props), className: "sf:hidden sf:truncate sf:text-sm sf:font-medium sf:text-muted sf:no-underline sf:hover:text-ink sf:sm:inline", children: text(category.name) })] }), _jsx(ShareButton, { title: text(record.title), words: forClient(words), className: iconButton })] }), _jsxs("div", { className: "sf:grid sf:items-start sf:gap-8 sf:lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)] sf:lg:gap-14", children: [_jsx(ProductGallery, { images: images, transitionName: productTransition(record.id), words: forClient(words) }), _jsxs("div", { className: "sf:flex sf:flex-col sf:gap-7 sf:rounded-card sf:border sf:border-line sf:bg-page sf:p-6 sf:shadow-card sf:sm:p-10 sf:lg:sticky sf:lg:top-28", children: [_jsx("span", { "aria-hidden": "true", className: "sf:mx-auto sf:-mt-2 sf:h-1 sf:w-12 sf:rounded-full sf:bg-line sf:lg:hidden" }), _jsxs("div", { className: "sf:flex sf:flex-col sf:gap-2", children: [(category || formatLabel(record, t)) && (_jsxs("p", { className: "sf:flex sf:flex-wrap sf:items-center sf:gap-2 sf:text-sm sf:font-medium", children: [category && _jsx("span", { className: "sf:text-accent", children: text(category.name) }), formatLabel(record, t) && _jsx("span", { className: "sf:rounded-full sf:bg-surface sf:px-3 sf:py-0.5 sf:text-ink", children: formatLabel(record, t) })] })), _jsx("h1", { className: "sf:text-3xl sf:font-semibold sf:tracking-tight sf:text-balance sf:text-ink sf:sm:text-4xl", children: text(record.title) }), text(record.summary) && _jsx("p", { className: "sf:text-muted", children: text(record.summary) })] }), _jsx(BuyBox, { product: record.id, price: num(record.price), compareAt: num(record.compareAtPrice), stock: num(record.stock), variants: variants, currency: currency, words: forClient(words) }), _jsx(MembershipPanel, { props: props }), text(record.sku) && _jsx("p", { className: "sf:border-t sf:border-line sf:pt-5 sf:text-xs sf:text-muted", children: t("shop.sku", { sku: text(record.sku) }) })] })] }), description && (_jsxs("section", { "aria-labelledby": "sf-details", className: "sf:mt-20 sf:grid sf:gap-6 sf:border-t sf:border-line sf:pt-12 sf:lg:grid-cols-[16rem_minmax(0,1fr)] sf:lg:gap-14", children: [_jsx("h2", { id: "sf-details", className: "sf:text-2xl sf:font-semibold sf:tracking-tight sf:text-ink", children: t("storefront.details") }), _jsx("div", { className: "sf-prose sf:max-w-measure", children: _jsx(StreamField, { blocks: record.description, ...stream }) })] })), more.length > 0 && (_jsxs("section", { "aria-labelledby": "sf-more", className: "sf:mt-20", children: [_jsx(SectionHeading, { id: "sf-more", title: t("storefront.youMayLike") }), _jsx(ProductGrid, { products: more, props: props, empty: "" })] }))] }));
|
|
181
|
+
}
|
|
182
|
+
const plansOf = (data) => items(data.plans).map((plan) => ({
|
|
183
|
+
name: text(plan.name),
|
|
184
|
+
title: text(plan.title) || text(plan.name),
|
|
185
|
+
description: text(plan.description),
|
|
186
|
+
amount: num(plan.amount),
|
|
187
|
+
annualAmount: num(plan.annualAmount),
|
|
188
|
+
currency: text(plan.currency) || currencyOf(data),
|
|
189
|
+
featured: plan.featured === true,
|
|
190
|
+
includes: ids(plan.includes),
|
|
191
|
+
}));
|
|
192
|
+
/** A member's downloads: each library file is fetched through the files API, which checks the same rule again. */
|
|
193
|
+
function Downloads({ files, props }) {
|
|
194
|
+
return (_jsx("ul", { className: "sf:flex sf:flex-wrap sf:gap-2", children: files.map((file) => {
|
|
195
|
+
const id = text(file.file);
|
|
196
|
+
return id ? (_jsx("li", { children: _jsxs("a", { href: props.fileUrl(id), download: true, className: "sf-press sf:inline-flex sf:h-10 sf:items-center sf:gap-2 sf:rounded-full sf:bg-accent sf:px-4 sf:text-sm sf:font-semibold sf:text-on-accent sf:no-underline", children: [_jsx(Download, { className: "sf:size-4" }), props.t("storefront.download", { label: text(file.label) || props.t("storefront.edition") })] }) }, file.id)) : null;
|
|
197
|
+
}) }));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* On a product in a membership: a member gets its digital edition here, and everyone else sees
|
|
201
|
+
* which membership opens it, from what price, and a way to the library to join.
|
|
202
|
+
*/
|
|
203
|
+
function MembershipPanel({ props }) {
|
|
204
|
+
const { record, data, t } = props;
|
|
205
|
+
const access = ids(record?.membership);
|
|
206
|
+
if (!record || !access.length)
|
|
207
|
+
return null;
|
|
208
|
+
const files = items(data.files);
|
|
209
|
+
const names = items(data.access).filter((item) => access.includes(item.id)).map((item) => text(item.name)).filter(Boolean);
|
|
210
|
+
const plans = plansOf(data).filter((plan) => plan.includes.some((id) => access.includes(id)) && plan.amount !== null);
|
|
211
|
+
const cheapest = plans.sort((a, b) => (a.amount ?? 0) - (b.amount ?? 0))[0];
|
|
212
|
+
return (_jsxs("section", { "aria-label": t("storefront.library"), className: "sf:flex sf:flex-col sf:gap-3 sf:rounded-3xl sf:bg-accent/10 sf:p-5", children: [_jsxs("p", { className: "sf:flex sf:items-center sf:gap-2 sf:font-semibold sf:text-ink", children: [_jsx(BookOpen, { className: "sf:size-5 sf:text-accent" }), files.length ? t("storefront.memberRead") : t("storefront.includedIn", { name: names[0] ?? t("storefront.library") })] }), files.length ? _jsx(Downloads, { files: files, props: props }) : (_jsxs("p", { className: "sf:flex sf:flex-wrap sf:items-center sf:gap-x-3 sf:gap-y-1 sf:text-sm sf:text-muted", children: [cheapest && _jsx("span", { children: t("storefront.fromPrice", { price: money(props.formatNumber, cheapest.amount, cheapest.currency) }) }), _jsx("a", { href: inLanguage(props, "/library"), className: "sf:font-semibold sf:text-accent sf:underline sf:underline-offset-4", children: t("storefront.join") })] }))] }));
|
|
213
|
+
}
|
|
214
|
+
/** One membership to choose, with its price and the provider's checkout behind Subscribe. */
|
|
215
|
+
function PlanCard({ plan, props, member }) {
|
|
216
|
+
const { t, words } = props;
|
|
217
|
+
return (_jsxs("li", { className: cx("sf:flex sf:flex-col sf:gap-4 sf:rounded-card sf:border sf:p-7", plan.featured ? "sf:border-accent sf:bg-accent/5 sf:shadow-card" : "sf:border-line sf:bg-page"), children: [_jsxs("div", { className: "sf:flex sf:flex-col sf:gap-1", children: [_jsx("h3", { className: "sf:text-xl sf:font-semibold sf:text-ink", children: plan.title }), plan.description && _jsx("p", { className: "sf:text-muted", children: plan.description })] }), plan.amount !== null && (_jsxs("p", { className: "sf:flex sf:flex-wrap sf:items-baseline sf:gap-x-2 sf:text-ink", children: [_jsx("span", { className: "sf:text-4xl sf:font-semibold sf:tracking-tight sf:tabular-nums", children: money(props.formatNumber, plan.amount, plan.currency) }), _jsx("span", { className: "sf:text-muted", children: t("storefront.perMonth") }), plan.annualAmount !== null && _jsx("span", { className: "sf:basis-full sf:text-sm sf:text-muted", children: t("storefront.perYear", { price: money(props.formatNumber, plan.annualAmount, plan.currency) }) })] })), _jsx("div", { className: "sf-plan-action sf:mt-auto", children: member ? _jsx(BillingButton, { words: words ? pickWords(words, "payments") : undefined }) : _jsx(SubscribeButton, { plan: plan.name, label: t("storefront.join"), words: words ? pickWords(words, "payments") : undefined }) })] }));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The members' library: the memberships to join, then every product in one. A member's own
|
|
221
|
+
* editions show their downloads, read through the rule as them. The rest show a lock.
|
|
222
|
+
*/
|
|
223
|
+
function Library(props) {
|
|
224
|
+
const { record, data, t } = props;
|
|
225
|
+
const books = items(data.books);
|
|
226
|
+
const files = items(data.files);
|
|
227
|
+
const member = files.length > 0;
|
|
228
|
+
const plans = plansOf(data);
|
|
229
|
+
const categories = byId(data.categories);
|
|
230
|
+
const filesOf = (product) => files.filter((file) => file.product === product);
|
|
231
|
+
return (_jsxs("main", { className: cx(container, "sf:pt-10 sf:lg:pt-14"), children: [_jsx(PageHeading, { title: text(record?.title) || t("storefront.library"), record: record }), member && _jsxs("p", { className: "sf:mb-8 sf:inline-flex sf:items-center sf:gap-2 sf:rounded-full sf:bg-accent/10 sf:px-4 sf:py-2 sf:text-sm sf:font-medium sf:text-accent", children: [_jsx(BookOpen, { className: "sf:size-4" }), t("storefront.youAreMember")] }), plans.length > 0 && (_jsxs("section", { "aria-labelledby": "sf-plans", className: "sf:mb-16", children: [_jsx(SectionHeading, { id: "sf-plans", title: t("storefront.memberships") }), _jsx("ul", { className: "sf:grid sf:gap-5 sf:md:grid-cols-2 sf:xl:grid-cols-3", children: plans.map((plan) => _jsx(PlanCard, { plan: plan, props: props, member: member }, plan.name)) })] })), _jsxs("section", { "aria-labelledby": "sf-library-books", children: [_jsx(SectionHeading, { id: "sf-library-books", title: t("storefront.inTheLibrary"), aside: books.length ? t("storefront.products", { count: books.length }) : undefined }), books.length ? (_jsx("ul", { className: "sf:grid sf:grid-cols-2 sf:gap-x-4 sf:gap-y-10 sf:sm:gap-x-6 sf:md:grid-cols-3 sf:xl:grid-cols-4", children: books.map((book, index) => {
|
|
232
|
+
const open = filesOf(book.id);
|
|
233
|
+
return (_jsxs("li", { className: "sf:flex sf:flex-col sf:gap-3", children: [_jsx(ProductCard, { product: book, categories: categories, props: props, eager: index < 4 }), _jsx("div", { className: "sf:px-2", children: open.length ? _jsx(Downloads, { files: open, props: props }) : _jsxs("p", { className: "sf:inline-flex sf:items-center sf:gap-1.5 sf:text-sm sf:text-muted", children: [_jsx(Lock, { className: "sf:size-4" }), t("storefront.membersOnly")] }) })] }, book.id));
|
|
234
|
+
}) })) : _jsx("p", { className: "sf:text-muted", children: t("storefront.libraryEmpty") })] })] }));
|
|
235
|
+
}
|
|
236
|
+
function PageHeading({ title, record, back }) {
|
|
237
|
+
return (_jsxs("header", { className: "sf:mb-10 sf:flex sf:flex-col sf:items-start sf:gap-4", children: [back, _jsx("h1", { className: "sf:text-4xl sf:font-semibold sf:tracking-tight sf:text-ink sf:sm:text-5xl", children: title }), record?.intro !== undefined && record?.intro !== null && _jsx("div", { className: "sf-prose sf:max-w-2xl sf:text-muted", children: _jsx(RichText, { doc: record.intro }) })] }));
|
|
238
|
+
}
|
|
239
|
+
/** The cart is the shop plugin's, laid out in two columns by theme.css: lines, then where it goes and the total. */
|
|
240
|
+
function CartPage(props) {
|
|
241
|
+
const { record, t, words } = props;
|
|
242
|
+
return (_jsxs("main", { className: cx(container, "sf:pt-10 sf:lg:pt-14"), children: [_jsx(PageHeading, { title: text(record?.title) || t("shop.yourCart"), record: record, back: _jsxs(BackLink, { href: shopHref(props), className: "sf:inline-flex sf:items-center sf:gap-1 sf:text-sm sf:font-medium sf:text-muted sf:no-underline sf:hover:text-ink", children: [_jsx(ChevronLeft, { className: "sf:size-4 sf:rtl:-scale-x-100" }), t("storefront.back")] }) }), _jsx("div", { className: "sf-cart", children: _jsx(ShopCart, { words: words ? pickWords(words, "shop") : undefined }) })] }));
|
|
243
|
+
}
|
|
244
|
+
/** The signed-in customer's orders, read as them, as the shop plugin lists them. */
|
|
245
|
+
function OrdersPage(props) {
|
|
246
|
+
const { record, data, fileUrl, t, words } = props;
|
|
247
|
+
return (_jsxs("main", { className: cx(container, "sf:max-w-4xl sf:pt-10 sf:lg:pt-14"), children: [_jsx(PageHeading, { title: text(record?.title) || t("shop.yourOrders"), record: record }), _jsxs("div", { className: "sf-orders", children: [_jsx(OrderReturn, { words: words ? pickWords(words, "shop") : undefined }), _jsx(OrderList, { orders: items(data.orders), fileUrl: fileUrl, words: words })] })] }));
|
|
248
|
+
}
|
|
249
|
+
/** Any other page, such as About. */
|
|
250
|
+
function Page({ record, stream }) {
|
|
251
|
+
if (!record)
|
|
252
|
+
return null;
|
|
253
|
+
return (_jsx("main", { className: cx(container, "sf:max-w-3xl sf:pt-12 sf:lg:pt-16"), children: _jsxs("article", { children: [_jsx("h1", { className: "sf:mb-8 sf:text-4xl sf:font-semibold sf:tracking-tight sf:text-ink sf:sm:text-5xl", children: text(record.title) || text(record.name) }), _jsx("div", { className: "sf-prose", children: _jsx(StreamField, { blocks: record.body, ...stream }) })] }) }));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Categories have a name rather than a title. Only fills what the CMS's defaults (seo_title,
|
|
257
|
+
* title, seo_description, summary) would leave empty.
|
|
258
|
+
*/
|
|
259
|
+
function metadata({ record }) {
|
|
260
|
+
if (!record)
|
|
261
|
+
return {};
|
|
262
|
+
return {
|
|
263
|
+
title: !text(record.seo_title) && !text(record.title) ? text(record.name) || undefined : undefined,
|
|
264
|
+
description: !text(record.seo_description) && !text(record.summary) ? text(record.description) || undefined : undefined,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export default defineThemeComponents({
|
|
268
|
+
// The shop's blocks (product grids, add to cart) come from the plugin and are restyled in theme.css.
|
|
269
|
+
templates: { home: Front, "shop-store": Front, "shop-categories": Category, "shop-products": Product, library: Library, "shop-cart": CartPage, "shop-account": OrdersPage, default: Page },
|
|
270
|
+
layouts: { default: Layout },
|
|
271
|
+
metadata,
|
|
272
|
+
fontClassName: font.variable,
|
|
273
|
+
messages,
|
|
274
|
+
});
|
package/schema.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"collections": [
|
|
4
|
+
{
|
|
5
|
+
"slug": "site-menu",
|
|
6
|
+
"name": "Menu",
|
|
7
|
+
"description": "Links shown at the top of every page.",
|
|
8
|
+
"type": "singleton",
|
|
9
|
+
"urlPattern": null,
|
|
10
|
+
"rules": {
|
|
11
|
+
"listRule": "",
|
|
12
|
+
"viewRule": "",
|
|
13
|
+
"createRule": null,
|
|
14
|
+
"updateRule": null,
|
|
15
|
+
"deleteRule": null
|
|
16
|
+
},
|
|
17
|
+
"fields": [
|
|
18
|
+
{
|
|
19
|
+
"name": "items",
|
|
20
|
+
"type": "stream",
|
|
21
|
+
"config": {
|
|
22
|
+
"allowedBlocks": [
|
|
23
|
+
"menu_item"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"slug": "shop-products",
|
|
31
|
+
"name": "Products",
|
|
32
|
+
"type": "base",
|
|
33
|
+
"urlPattern": "/shop/:slug",
|
|
34
|
+
"rules": {
|
|
35
|
+
"listRule": "status = \"published\"",
|
|
36
|
+
"viewRule": "status = \"published\"",
|
|
37
|
+
"createRule": null,
|
|
38
|
+
"updateRule": null,
|
|
39
|
+
"deleteRule": null
|
|
40
|
+
},
|
|
41
|
+
"fields": [
|
|
42
|
+
{
|
|
43
|
+
"name": "format",
|
|
44
|
+
"type": "radio",
|
|
45
|
+
"config": {
|
|
46
|
+
"options": [
|
|
47
|
+
{ "label": "Physical", "value": "physical" },
|
|
48
|
+
{ "label": "Digital", "value": "digital" },
|
|
49
|
+
{ "label": "Physical and digital", "value": "both" }
|
|
50
|
+
],
|
|
51
|
+
"description": "The badge the storefront shows. What is posted still follows Shipping, and what buyers download follows Download."
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "membership",
|
|
56
|
+
"type": "reference",
|
|
57
|
+
"config": {
|
|
58
|
+
"collection": "payments-access",
|
|
59
|
+
"displayField": "name",
|
|
60
|
+
"allowMultiple": true,
|
|
61
|
+
"description": "Memberships whose members read its digital edition in the library for free. Add the file under Library files."
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"slug": "library",
|
|
68
|
+
"name": "Library page",
|
|
69
|
+
"description": "The members' library: digital editions members read for free, and the memberships that open them.",
|
|
70
|
+
"type": "singleton",
|
|
71
|
+
"urlPattern": "/library",
|
|
72
|
+
"rules": {
|
|
73
|
+
"listRule": "",
|
|
74
|
+
"viewRule": "",
|
|
75
|
+
"createRule": null,
|
|
76
|
+
"updateRule": null,
|
|
77
|
+
"deleteRule": null
|
|
78
|
+
},
|
|
79
|
+
"fields": [
|
|
80
|
+
{ "name": "title", "type": "text", "config": { "required": true, "maxLength": 120 } },
|
|
81
|
+
{ "name": "intro", "type": "rich_text", "config": {} }
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"slug": "library-files",
|
|
86
|
+
"name": "Library files",
|
|
87
|
+
"description": "Digital editions for members. Only people whose membership includes one of a file's Included in can see it or download it. A file in no membership is shown to nobody.",
|
|
88
|
+
"type": "base",
|
|
89
|
+
"urlPattern": null,
|
|
90
|
+
"rules": {
|
|
91
|
+
"listRule": "status = \"published\" && included:length > 0 && included ?= @request.auth.payments_access",
|
|
92
|
+
"viewRule": "status = \"published\" && included:length > 0 && included ?= @request.auth.payments_access",
|
|
93
|
+
"createRule": null,
|
|
94
|
+
"updateRule": null,
|
|
95
|
+
"deleteRule": null
|
|
96
|
+
},
|
|
97
|
+
"fields": [
|
|
98
|
+
{ "name": "product", "type": "reference", "config": { "collection": "shop-products", "displayField": "title", "required": true } },
|
|
99
|
+
{ "name": "label", "type": "text", "config": { "maxLength": 40, "description": "What the download is, such as EPUB or PDF." } },
|
|
100
|
+
{ "name": "file", "type": "file", "config": { "required": true } },
|
|
101
|
+
{ "name": "included", "type": "reference", "config": { "collection": "payments-access", "displayField": "name", "allowMultiple": true, "required": true, "label": "Included in" } }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"blocks": []
|
|
106
|
+
}
|