@revenexx/cover 0.21.2 → 0.22.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.
Files changed (98) hide show
  1. package/app/api/categories.ts +1 -0
  2. package/app/api/offers.ts +1 -0
  3. package/app/app.config.ts +18 -0
  4. package/app/components/OgImage/CoverPage.takumi.vue +37 -0
  5. package/app/components/RevenexxForm.vue +21 -6
  6. package/app/components/account/approvals/AccountPendingApprovals.vue +19 -1
  7. package/app/components/account/approvals/AccountPendingOrderDetail.vue +3 -0
  8. package/app/components/account/carts/AccountCartsTable.vue +11 -1
  9. package/app/components/account/orderlists/AccountOrderListDetail.vue +32 -3
  10. package/app/components/account/organization/AccountOrganization.vue +1 -1
  11. package/app/components/auth/AuthForgotPasswordPanel.vue +7 -2
  12. package/app/components/auth/AuthLoginPanel.vue +23 -8
  13. package/app/components/auth/AuthRegisterTeaser.vue +1 -1
  14. package/app/components/cart/position/CartPosition.vue +11 -4
  15. package/app/components/cart/quickadd/CartQuickAdd.vue +4 -2
  16. package/app/components/cart/recommend/CartRecommendCard.vue +1 -0
  17. package/app/components/cart/switcher/CartSwitcher.vue +1 -0
  18. package/app/components/cart/view/CartListHeader.vue +5 -0
  19. package/app/components/cart/view/CartSummaryPanel.vue +7 -2
  20. package/app/components/cart/view/CartView.vue +4 -2
  21. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +3 -0
  22. package/app/components/checkout/onepage/CheckoutGate.vue +4 -2
  23. package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +2 -1
  24. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +1 -1
  25. package/app/components/layout/header/LocaleSwitcher.vue +7 -9
  26. package/app/components/product/detail/ProductDetailAddToCart.vue +17 -11
  27. package/app/components/product/detail/ProductDetailImageGallery.vue +101 -8
  28. package/app/components/product/detail/ProductDetailVariantRow.vue +84 -4
  29. package/app/components/product/detail/ProductDetailVariants.vue +75 -11
  30. package/app/components/product/detail/ProductDetailView.vue +64 -69
  31. package/app/components/ui/forms/FormKitDatePicker.vue +8 -2
  32. package/app/composables/useAuthStore.ts +21 -4
  33. package/app/composables/useCategories.ts +24 -0
  34. package/app/composables/useCategoryAnswer.ts +30 -0
  35. package/app/composables/useCategorySeo.ts +62 -0
  36. package/app/composables/useCheckoutOnePage.ts +15 -4
  37. package/app/composables/useDefaultUiLanguage.ts +14 -0
  38. package/app/composables/useOgImageReady.ts +16 -0
  39. package/app/composables/useProductAnswer.ts +121 -0
  40. package/app/composables/useProductLocales.ts +21 -10
  41. package/app/composables/useProductSeo.ts +145 -0
  42. package/app/composables/useRouteSubject.ts +23 -3
  43. package/app/composables/useSeoContext.ts +164 -0
  44. package/app/composables/useSeoHead.ts +189 -0
  45. package/app/composables/useSeoRules.ts +23 -0
  46. package/app/formkit.config.ts +1 -1
  47. package/app/interfaces/seo.ts +48 -0
  48. package/app/layouts/default.vue +2 -8
  49. package/app/layouts/focus.vue +3 -1
  50. package/app/payments/psp/novalnet.ts +25 -3
  51. package/app/payments/psp/novalnetStyle.ts +186 -0
  52. package/app/shared/categoryTree.ts +7 -0
  53. package/app/shared/locale.ts +8 -0
  54. package/app/shared/productLocales.ts +62 -1
  55. package/app/shared/requestedDate.ts +49 -0
  56. package/app/shared/seoRules.ts +297 -0
  57. package/app/shared/structuredData.ts +104 -0
  58. package/i18n/locales/de/account.json +4 -0
  59. package/i18n/locales/de/checkout.json +1 -0
  60. package/i18n/locales/de/common.json +6 -0
  61. package/i18n/locales/de/pages.json +109 -0
  62. package/i18n/locales/en/account.json +4 -0
  63. package/i18n/locales/en/checkout.json +1 -0
  64. package/i18n/locales/en/common.json +6 -0
  65. package/i18n/locales/en/pages.json +109 -0
  66. package/nuxt.config.ts +140 -1
  67. package/package.json +10 -3
  68. package/server/api/auth/otp.post.ts +4 -8
  69. package/server/api/auth/otp.put.ts +20 -11
  70. package/server/api/categories/[slug]/exists.get.ts +28 -0
  71. package/server/api/offers/guest.get.ts +53 -0
  72. package/server/api/orders/index.post.ts +18 -12
  73. package/server/api/payment/methods.post.ts +2 -33
  74. package/server/api/product/[id]/locales.get.ts +9 -3
  75. package/server/data/product-detail.json +0 -20
  76. package/server/dev/errorHandler.ts +9 -5
  77. package/server/dev/typesense/autoSeed.ts +63 -0
  78. package/server/dev/typesense/seed.ts +4 -43
  79. package/server/dev/typesense/seedProducts.ts +87 -0
  80. package/server/interfaces/category.ts +5 -0
  81. package/server/interfaces/product.ts +13 -6
  82. package/server/middleware/missing-media.ts +2 -2
  83. package/server/plugins/previewHostNoindex.ts +21 -0
  84. package/server/plugins/seoSiteConfig.ts +62 -0
  85. package/server/routes/robots.txt.ts +21 -0
  86. package/server/services/ApiCategoryService.ts +6 -0
  87. package/server/services/ApiProductService.ts +2 -2
  88. package/server/services/LocalFileCategoryService.ts +6 -0
  89. package/server/utils/liveCatalog.ts +83 -18
  90. package/server/utils/livePrices.ts +12 -3
  91. package/server/utils/locale.ts +3 -8
  92. package/server/utils/offerService.ts +8 -3
  93. package/server/utils/paymentOptions.ts +49 -0
  94. package/server/utils/promotionsService.ts +25 -0
  95. package/server/utils/revenexxSdk.ts +7 -1
  96. package/server/utils/seoRequestHost.ts +21 -0
  97. package/server/utils/storefrontMessages.ts +5 -5
  98. package/server/utils/storefrontSeoRules.ts +298 -0
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The requested delivery date a storefront fills in by itself.
3
+ *
4
+ * A merchant whose ERP plans every order by its delivery date cannot take an
5
+ * order without one (`checkout.requestedDateRequired`). The buyer may still
6
+ * choose a later day; when they choose none, the order carries the first day
7
+ * the merchant can deliver: today plus `checkout.earliestDeliveryDays`, moved
8
+ * to the next Monday when that lands on a weekend — the calendar offers no
9
+ * weekend either.
10
+ *
11
+ * Dates are calendar days as ISO "YYYY-MM-DD" strings, the shape the date
12
+ * picker and the orders app both use.
13
+ */
14
+
15
+ /** Today's calendar date in `timeZone`, as "YYYY-MM-DD". */
16
+ export function calendarToday(timeZone?: string, now: Date = new Date()): string {
17
+ // en-CA formats a date as YYYY-MM-DD.
18
+ return new Intl.DateTimeFormat("en-CA", {
19
+ timeZone,
20
+ year: "numeric",
21
+ month: "2-digit",
22
+ day: "2-digit",
23
+ }).format(now);
24
+ }
25
+
26
+ /** The first working day `leadDays` or more after `todayIso`. */
27
+ export function earliestRequestedDate(leadDays: number, todayIso: string): string {
28
+ const [y, m, d] = todayIso.split("-").map(Number);
29
+ const date = new Date(Date.UTC(y!, m! - 1, d!));
30
+ date.setUTCDate(date.getUTCDate() + Math.max(0, Math.floor(Number.isFinite(leadDays) ? leadDays : 0)));
31
+ const weekday = date.getUTCDay();
32
+ if (weekday === 6) {
33
+ date.setUTCDate(date.getUTCDate() + 2);
34
+ }
35
+ else if (weekday === 0) {
36
+ date.setUTCDate(date.getUTCDate() + 1);
37
+ }
38
+ return date.toISOString().slice(0, 10);
39
+ }
40
+
41
+ /**
42
+ * The date an order goes out with when the storefront requires one: the
43
+ * buyer's own, unless it is missing, malformed or earlier than the merchant
44
+ * can deliver — then the earliest possible day.
45
+ */
46
+ export function requiredRequestedDate(given: unknown, earliestIso: string): string {
47
+ const value = typeof given === "string" ? given.trim() : "";
48
+ return /^\d{4}-\d{2}-\d{2}$/.test(value) && value >= earliestIso ? value : earliestIso;
49
+ }
@@ -0,0 +1,297 @@
1
+ import type { SeoRules } from "../interfaces/seo";
2
+ import { localeLanguage } from "./locale";
3
+ import type { LocaleHeadLink, LocaleHeadMeta } from "./productLocales";
4
+
5
+ /**
6
+ * The seo service's defaults for a domain nobody configured — the same values
7
+ * its bundle carries then. The storefront falls back to these when the rules
8
+ * cannot be read, so a page never waits on SEO and never renders without it.
9
+ */
10
+ const DEFAULT_STRIP_PARAMS: readonly string[] = ["utm_*", "gclid", "fbclid", "msclkid", "sort", "order"];
11
+
12
+ export function defaultSeoRules(host: string): SeoRules {
13
+ return {
14
+ schema: 1,
15
+ host,
16
+ site_name: host,
17
+ canonical: { host: null, cross_domain_page_types: ["product", "category"], strip_params: DEFAULT_STRIP_PARAMS },
18
+ hreflang: { x_default: null, locales: null },
19
+ max_length: { title: 60, description: 160 },
20
+ page_types: {
21
+ home: { title: "{site}", description: null, robots: "index,follow" },
22
+ product: { title: "{name} | {site}", description: "{description}", robots: "index,follow" },
23
+ category: { title: "{name} | {site}", description: "{description}", robots: "index,follow" },
24
+ page: { title: "{name} | {site}", description: "{description}", robots: "index,follow" },
25
+ search: { robots: "noindex,follow" },
26
+ cart: { robots: "noindex,nofollow" },
27
+ checkout: { robots: "noindex,nofollow" },
28
+ "checkout-confirmation": { robots: "noindex,nofollow" },
29
+ login: { robots: "noindex,nofollow" },
30
+ register: { robots: "noindex,nofollow" },
31
+ "forgot-password": { robots: "noindex,nofollow" },
32
+ "reset-password": { robots: "noindex,nofollow" },
33
+ account: { robots: "noindex,nofollow" },
34
+ preview: { robots: "noindex,nofollow" },
35
+ },
36
+ organisation: null,
37
+ structured_data: { prices: true },
38
+ removed_products: "category",
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Hosts the theme editor and previews render on (`<tenant>.theme.rvnxx.site`).
44
+ * Never indexable, whatever the rules of the tenant's domains say.
45
+ */
46
+ export function isPreviewHost(host: string): boolean {
47
+ return host.toLowerCase().endsWith(".theme.rvnxx.site");
48
+ }
49
+
50
+ /** Whether a query parameter is one the canonical leaves out (`utm_*` matches by prefix). */
51
+ function isStrippedParam(name: string, stripParams: readonly string[]): boolean {
52
+ const lower = name.toLowerCase();
53
+ return stripParams.some(rule => rule.endsWith("*")
54
+ ? lower.startsWith(rule.slice(0, -1).toLowerCase())
55
+ : lower === rule.toLowerCase());
56
+ }
57
+
58
+ /**
59
+ * The only query parameters a canonical carries, each with the values it
60
+ * carries them with. Any other parameter (a tracking id the rules do not know,
61
+ * a session id, one made up) would make each URL its own canonical and write
62
+ * foreign values into `canonical` and `og:url`; facets and searches name the
63
+ * clean listing instead. `page` only from 2: page 1 is the listing itself,
64
+ * and `?page=abc` no page at all.
65
+ */
66
+ const CANONICAL_PARAMS: ReadonlyMap<string, (value: string) => boolean> = new Map([
67
+ ["page", value => /^[1-9]\d*$/.test(value) && value !== "1"],
68
+ ]);
69
+
70
+ /**
71
+ * `path` (or an href) on `origin`, never on another host: `new URL(path, base)`
72
+ * would read a protocol-relative `//other.example/x` as that host.
73
+ */
74
+ function onOrigin(path: string, origin: string): URL {
75
+ return path.startsWith("/") ? new URL(`${origin}${path}`) : new URL(path, origin);
76
+ }
77
+
78
+ /**
79
+ * The canonical URL of a page: the site's origin (or the main domain for a
80
+ * page type that canonicalises across domains), the path as served, and of
81
+ * the query only `page`, from 2 on, so every page of a listing is its own
82
+ * canonical; `page=1` and a page that is no page number at all name the
83
+ * listing itself. A parameter the rules strip is left out even then.
84
+ */
85
+ export function seoCanonicalUrl(options: {
86
+ readonly origin: string;
87
+ readonly path: string;
88
+ readonly query: Readonly<Record<string, unknown>>;
89
+ readonly rules: SeoRules;
90
+ readonly pageType?: string;
91
+ }): string {
92
+ const { rules, pageType } = options;
93
+ const crossDomain = rules.canonical.host && pageType && rules.canonical.cross_domain_page_types.includes(pageType);
94
+ const url = onOrigin(options.path, crossDomain ? `https://${rules.canonical.host}` : options.origin);
95
+ const kept = Object.entries(options.query)
96
+ .filter(([name]) => CANONICAL_PARAMS.has(name) && !isStrippedParam(name, rules.canonical.strip_params))
97
+ .sort(([a], [b]) => a.localeCompare(b));
98
+ for (const [name, value] of kept) {
99
+ // One value per parameter: `?page=2&page=3` is not two pages.
100
+ const carried = (Array.isArray(value) ? value : [value])
101
+ .map(item => (item === null || item === undefined ? "" : String(item)))
102
+ .find(item => CANONICAL_PARAMS.get(name)?.(item));
103
+ if (carried !== undefined) {
104
+ url.searchParams.set(name, carried);
105
+ }
106
+ }
107
+ return url.href;
108
+ }
109
+
110
+ /**
111
+ * An x-default link from another hreflang link. i18n keys its head links by
112
+ * `id` or, under strict SEO, `key`; whichever the source carries becomes
113
+ * i18n's x-default key, so the copy never replaces the alternate it came from.
114
+ */
115
+ function xDefaultEntry<L extends LocaleHeadLink>(source: L, href: string): L {
116
+ const entry: L = { ...source, hreflang: "x-default", href };
117
+ for (const attribute of ["id", "key"] as const) {
118
+ if (attribute in entry) {
119
+ (entry as LocaleHeadLink)[attribute] = "i18n-xd";
120
+ }
121
+ }
122
+ return entry;
123
+ }
124
+
125
+ /**
126
+ * `useLocaleHead({ seo: true })` with the domain's rules applied.
127
+ *
128
+ * @nuxtjs/i18n writes every URL without a host (it has no per-request
129
+ * `baseUrl`), and search engines ignore relative hreflang links. So:
130
+ *
131
+ * - alternates become absolute on the request's origin;
132
+ * - with `hreflang.locales` set, only those languages are linked (matched by
133
+ * language subtag, as i18n writes both `de` and `de-DE`);
134
+ * - with `hreflang.x_default` set, `x-default` points at that language's URL,
135
+ * and is dropped when that language is not linked;
136
+ * - the canonical and `og:url` go: the page's canonical follows the rules
137
+ * (seoCanonicalUrl), and nuxt-seo-utils derives `og:url` from it.
138
+ */
139
+ export function applySeoRulesToLocaleHead<L extends LocaleHeadLink, M extends LocaleHeadMeta>(
140
+ head: { link?: L[]; meta?: M[] },
141
+ options: { readonly origin: string; readonly rules: SeoRules },
142
+ ): { link: L[]; meta: M[] } {
143
+ const { locales, x_default: xDefault } = options.rules.hreflang;
144
+ const languages = locales ? new Set(locales.map(localeLanguage)) : null;
145
+ const linked = (code: string): boolean => !languages || languages.has(localeLanguage(code));
146
+ const absolute = (href: string | undefined): string | undefined =>
147
+ href === undefined ? undefined : onOrigin(href, options.origin).href;
148
+
149
+ const alternates = (head.link ?? [])
150
+ .filter(entry => entry.rel === "alternate" && entry.hreflang && entry.hreflang !== "x-default")
151
+ .filter(entry => linked(entry.hreflang as string))
152
+ .map(entry => ({ ...entry, href: absolute(entry.href) }));
153
+
154
+ // i18n's own x-default is gone where the default language has no page
155
+ // (filterLocaleHeadAlternates, PE-859); the rules' x-default then grows out
156
+ // of the alternate it points at, under i18n's x-default identity.
157
+ const defaultLink = (head.link ?? []).find(entry => entry.rel === "alternate" && entry.hreflang === "x-default");
158
+ const xDefaultTarget = xDefault
159
+ ? alternates.find(entry => localeLanguage(entry.hreflang as string) === localeLanguage(xDefault))
160
+ : undefined;
161
+ const defaultHref = xDefault ? xDefaultTarget?.href : absolute(defaultLink?.href);
162
+ const keptHrefs = new Set(alternates.map(entry => entry.href));
163
+ const xDefaultBase = defaultLink ?? xDefaultTarget;
164
+ const xDefaultLink = xDefaultBase && defaultHref && keptHrefs.has(defaultHref)
165
+ ? [xDefaultEntry(xDefaultBase, defaultHref)]
166
+ : [];
167
+
168
+ const others = (head.link ?? []).filter(entry => entry.rel !== "alternate" && entry.rel !== "canonical");
169
+
170
+ return {
171
+ link: [...others, ...xDefaultLink, ...alternates],
172
+ meta: (head.meta ?? []).filter(entry => entry.property !== "og:url"
173
+ && (entry.property !== "og:locale:alternate" || !entry.content || linked(entry.content))),
174
+ };
175
+ }
176
+
177
+ /**
178
+ * The regional hreflang alternates in the region the shop's market speaks
179
+ * each language in: i18n writes its own config's codes (`de-DE`, `en-US`),
180
+ * so a Swiss market gets `de-CH` instead, the same locale `<html lang>`
181
+ * names (PE-1237). `marketLocale` answers the market's locale for a code's
182
+ * language, or null while the markets carry none; the i18n code then stands.
183
+ * The bare language alternates (`de`) and `x-default` stay as they are, and
184
+ * an alternate whose new code is already linked goes.
185
+ */
186
+ export function marketHreflangAlternates<L extends LocaleHeadLink>(
187
+ links: readonly L[],
188
+ marketLocale: (code: string) => string | null,
189
+ ): L[] {
190
+ const linked = new Set<string>();
191
+ return links
192
+ .map((entry) => {
193
+ const code = entry.rel === "alternate" ? entry.hreflang : undefined;
194
+ if (!code || code === "x-default" || !code.includes("-")) {
195
+ return entry;
196
+ }
197
+ const market = marketLocale(code);
198
+ return market ? { ...entry, hreflang: market } : entry;
199
+ })
200
+ .filter((entry) => {
201
+ if (entry.rel !== "alternate" || !entry.hreflang) {
202
+ return true;
203
+ }
204
+ const code = entry.hreflang.toLowerCase();
205
+ if (linked.has(code)) {
206
+ return false;
207
+ }
208
+ linked.add(code);
209
+ return true;
210
+ });
211
+ }
212
+
213
+ /** What a page's title and description patterns are filled from. */
214
+ export interface SeoPatternValues {
215
+ readonly name?: string;
216
+ readonly category?: string;
217
+ readonly brand?: string;
218
+ readonly parent?: string;
219
+ readonly description?: string;
220
+ }
221
+
222
+ /**
223
+ * A title or description pattern of the rules (`{name} | {site}`) filled in
224
+ * and cut at its maximum length. A placeholder without a value is left empty
225
+ * and a separator left dangling at either end goes with it; the service
226
+ * refuses unknown placeholders, so none reach here.
227
+ */
228
+ export function fillSeoPattern(pattern: string, values: SeoPatternValues & { readonly site: string }, maxLength: number): string {
229
+ const filled = pattern
230
+ .replace(/\{(\w+)\}/g, (_, key: string) => (values as Record<string, string | undefined>)[key]?.trim() ?? "")
231
+ .replace(/^\s*[|–—-]\s*|\s*[|–—-]\s*$/g, "")
232
+ .replace(/\s{2,}/g, " ")
233
+ .trim();
234
+ return filled.length > maxLength ? `${filled.slice(0, maxLength - 1).trimEnd()}…` : filled;
235
+ }
236
+
237
+ /**
238
+ * A page's title from its type's pattern, or undefined where the page's own
239
+ * title stands instead: the type has no pattern, the subject the pattern names
240
+ * (`{name}`) is not known yet, or the pattern is the bare `{site}` (the home
241
+ * page's default) and the page brings a title of its own — the shop's curated
242
+ * home title, or the one the home page's author stored. A pattern a tenant
243
+ * wrote for the home page (`{site} – Werkzeug online`) is used as written.
244
+ */
245
+ export function seoPatternTitle(
246
+ pattern: string | undefined,
247
+ values: SeoPatternValues & { readonly site: string },
248
+ maxLength: number,
249
+ ownTitle?: string,
250
+ ): string | undefined {
251
+ const ownTitleStands = pattern?.includes("{name}")
252
+ ? !values.name
253
+ : pattern?.trim() === "{site}" && Boolean(ownTitle);
254
+ if (!pattern || ownTitleStands) {
255
+ return undefined;
256
+ }
257
+ return fillSeoPattern(pattern, values, maxLength) || undefined;
258
+ }
259
+
260
+ /** The directives of a robots rule, lower-cased, with `none` and `all` spelled out. */
261
+ function robotsDirectives(rule: string): string[] {
262
+ return rule.split(",").map(d => d.trim().toLowerCase()).filter(Boolean)
263
+ .flatMap(d => (d === "none" ? ["noindex", "nofollow"] : d === "all" ? ["index", "follow"] : [d]));
264
+ }
265
+
266
+ /** Whether a robots rule lets the page into the index. */
267
+ export function isIndexableRobotsRule(rule: string): boolean {
268
+ return !robotsDirectives(rule).includes("noindex");
269
+ }
270
+
271
+ /**
272
+ * The robots directive for a page: its type's rule from the rules, turned to
273
+ * `noindex` when this URL must not be indexed although its type may be (a
274
+ * filtered listing, an empty category, a missing product), and to `nofollow`
275
+ * when its links must not be followed either (a preview). Any other directive
276
+ * of the rule (`noarchive`, `max-image-preview:large`, …) is kept.
277
+ */
278
+ export function seoRobotsRule(typeRule: string, flags: { readonly noindex?: boolean; readonly nofollow?: boolean } = {}): string {
279
+ const directives = robotsDirectives(typeRule);
280
+ const index = flags.noindex || directives.includes("noindex") ? "noindex" : "index";
281
+ const follow = flags.nofollow || directives.includes("nofollow") ? "nofollow" : "follow";
282
+ const others = directives.filter(d => !["index", "noindex", "follow", "nofollow"].includes(d));
283
+ return [index, follow, ...others].join(", ");
284
+ }
285
+
286
+ /**
287
+ * Whether a listing URL is filtered, searched within or priced — anything the
288
+ * clean listing is not, apart from paging and the parameters the canonical
289
+ * strips anyway. Such a URL is a near-duplicate of its listing and stays out
290
+ * of the index until filter pages can be released (phase 3).
291
+ */
292
+ export function hasListingFilters(query: Readonly<Record<string, unknown>>, rules: SeoRules): boolean {
293
+ return Object.entries(query).some(([name, value]) =>
294
+ value !== undefined && value !== null && value !== ""
295
+ && name !== "page"
296
+ && !isStrippedParam(name, rules.canonical.strip_params));
297
+ }
@@ -0,0 +1,104 @@
1
+ import type { Offer } from "../composables/useOffers";
2
+ import { getBaseUnitPrice, getPriceWithOptionalTax } from "../composables/useProducts";
3
+ import type { ProductDetailAttribute } from "../interfaces/product-detail";
4
+
5
+ /**
6
+ * The parts of a product's Schema.org data that follow shop rules rather than
7
+ * the catalogue (PE-1103). Pure, so the rules are tested without a page.
8
+ */
9
+
10
+ /** What a guest's offer says: the tier map and whether the item can be ordered. */
11
+ export type GuestOfferInput = Readonly<Pick<Offer, "prices" | "isOutOfStock">>;
12
+
13
+ // A type, not an interface: nuxt-schema-org's Offer has an index signature,
14
+ // which only a type literal satisfies.
15
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
16
+ export type StructuredOffer = {
17
+ price: string;
18
+ priceCurrency: string;
19
+ availability: "InStock" | "OutOfStock";
20
+ priceSpecification: {
21
+ "@type": "UnitPriceSpecification";
22
+ "price": string;
23
+ "priceCurrency": string;
24
+ "valueAddedTaxIncluded": boolean;
25
+ };
26
+ };
27
+
28
+ /**
29
+ * The `offers` of a product, or undefined for none (K4, PE-1047): a price only
30
+ * from the guest's offer, net or gross as the page shows it, in the currency it
31
+ * shows. No price (on request, refused to strangers, too slow) or the domain's
32
+ * opt-out gives no offer at all, never an offer without a price.
33
+ */
34
+ export function structuredOffer(input: {
35
+ readonly offer: GuestOfferInput | null | undefined;
36
+ /** The domain's rules allow prices in the structured data (`structured_data.prices`). */
37
+ readonly pricesAllowed: boolean;
38
+ readonly currency: string;
39
+ readonly taxRate: number;
40
+ readonly taxIncludedPrices: boolean;
41
+ }): StructuredOffer | undefined {
42
+ if (!input.pricesAllowed || !input.offer || !input.currency) {
43
+ return undefined;
44
+ }
45
+ // The price of one unit at the smallest quantity, as the product page shows it.
46
+ const unitPrice = getBaseUnitPrice([...input.offer.prices]);
47
+ if (unitPrice === null || unitPrice <= 0) {
48
+ return undefined;
49
+ }
50
+ const price = getPriceWithOptionalTax(unitPrice, input.taxRate, input.taxIncludedPrices).toFixed(2);
51
+ return {
52
+ price,
53
+ priceCurrency: input.currency,
54
+ availability: input.offer.isOutOfStock ? "OutOfStock" : "InStock",
55
+ priceSpecification: {
56
+ "@type": "UnitPriceSpecification",
57
+ "price": price,
58
+ "priceCurrency": input.currency,
59
+ "valueAddedTaxIncluded": input.taxIncludedPrices,
60
+ },
61
+ };
62
+ }
63
+
64
+ /** The product's specifications as Schema.org `additionalProperty`, empty ones left out. */
65
+ export function structuredProperties(attributes: readonly ProductDetailAttribute[]): { "@type": "PropertyValue"; name: string; value: string }[] {
66
+ return attributes
67
+ .filter(attribute => attribute.name?.trim() && attribute.value?.trim())
68
+ .map(attribute => ({ "@type": "PropertyValue", "name": attribute.name.trim(), "value": attribute.value.trim() }));
69
+ }
70
+
71
+ /** One entry of an accordion: its label and its HTML content. */
72
+ export interface FaqItemInput {
73
+ readonly label?: unknown;
74
+ readonly content?: unknown;
75
+ }
76
+
77
+ /**
78
+ * The questions of an accordion marked as FAQ (PE-1327), for `defineQuestion`:
79
+ * the label as the question, the content as the answer. Google reads a small
80
+ * set of HTML tags in an answer (`p`, `a`, lists, emphasis), so the content
81
+ * stays as authored. An entry without a question or without answer text (an
82
+ * empty paragraph counts as none) is left out.
83
+ */
84
+ export function faqQuestions(items: readonly FaqItemInput[]): { name: string; acceptedAnswer: string }[] {
85
+ return items.flatMap((item) => {
86
+ const name = typeof item.label === "string" ? item.label.trim() : "";
87
+ const answer = typeof item.content === "string" ? item.content.trim() : "";
88
+ return name && plainText(answer) ? [{ name, acceptedAnswer: answer }] : [];
89
+ });
90
+ }
91
+
92
+ /**
93
+ * Authored HTML as plain text, for meta tags and for telling an empty answer
94
+ * from a real one: tags become spaces, so do non-breaking spaces however the
95
+ * editor wrote them (`&nbsp;`, `&#160;`, `&#xA0;`, the character itself), and
96
+ * whitespace collapses.
97
+ */
98
+ export function plainText(html: string): string {
99
+ return html
100
+ .replace(/<[^>]*>/g, " ")
101
+ .replace(/&(?:nbsp|#160|#x0*a0);/gi, " ")
102
+ .replace(/\s+/g, " ")
103
+ .trim();
104
+ }
@@ -537,6 +537,10 @@
537
537
  "title": "Keine Bestelllisten",
538
538
  "description": "Legen Sie Ihre erste Bestellliste über „Hinzufügen“ an."
539
539
  },
540
+ "noPositions": {
541
+ "title": "Noch keine Positionen",
542
+ "description": "Artikel kommen von der Produktseite oder aus dem Warenkorb auf diese Liste — über „Auf Bestellliste“."
543
+ },
540
544
  "saveTo": {
541
545
  "button": "Auf Bestellliste",
542
546
  "onLists": "Auf {count} Liste | Auf {count} Listen",
@@ -194,6 +194,7 @@
194
194
  "requestedDateInvalid": "Bitte geben Sie ein gültiges Datum ein.",
195
195
  "submitError": "Bestellung fehlgeschlagen. Bitte versuchen Sie es erneut.",
196
196
  "orderNumberRequired": "Bitte geben Sie Ihre Bestellnummer an.",
197
+ "requestedDateRequired": "Bitte wählen Sie einen Wunschtermin.",
197
198
  "requestedDatePast": "Der Wunschtermin darf nicht in der Vergangenheit liegen.",
198
199
  "requestedDateTooFar": "Der Wunschtermin darf maximal {days} Tage in der Zukunft liegen.",
199
200
  "requestedDateWeekend": "Bitte wählen Sie einen Werktag als Wunschtermin.",
@@ -129,5 +129,11 @@
129
129
  "privacy": "Datenschutz",
130
130
  "terms": "AGB",
131
131
  "cookies": "Cookie-Richtlinie"
132
+ },
133
+ "seo": {
134
+ "ogImage": {
135
+ "product": "Produkt",
136
+ "category": "Kategorie"
137
+ }
132
138
  }
133
139
  }
@@ -0,0 +1,109 @@
1
+ {
2
+ "pages": {
3
+ "search": {
4
+ "title": "Suche"
5
+ },
6
+ "cart": {
7
+ "title": "@:cart.page.title"
8
+ },
9
+ "checkout": {
10
+ "title": "@:onepage.title"
11
+ },
12
+ "checkout-confirmation": {
13
+ "title": "@:cart.page.steps.success"
14
+ },
15
+ "login": {
16
+ "title": "@:auth.login.submit"
17
+ },
18
+ "login-link": {
19
+ "title": "@:auth.magicLink.title"
20
+ },
21
+ "callback": {
22
+ "title": "@:forms.callback.title"
23
+ },
24
+ "register": {
25
+ "title": "@:auth.register.title"
26
+ },
27
+ "forgot-password": {
28
+ "title": "@:auth.forgotPassword.title"
29
+ },
30
+ "reset-password": {
31
+ "title": "@:auth.resetPassword.title"
32
+ },
33
+ "contact": {
34
+ "title": "@:forms.contact.title"
35
+ },
36
+ "price-request": {
37
+ "title": "@:forms.priceRequest.title"
38
+ },
39
+ "account": {
40
+ "title": "@:header.account"
41
+ },
42
+ "account-section": {
43
+ "title": "@:header.account"
44
+ },
45
+ "account-addresses": {
46
+ "title": "@:addresses.title"
47
+ },
48
+ "account-approvals": {
49
+ "title": "@:governance.approvals.title"
50
+ },
51
+ "account-approvals-orders-number": {
52
+ "title": "@:governance.approvals.title"
53
+ },
54
+ "account-carts": {
55
+ "title": "@:cart.multi.page.title"
56
+ },
57
+ "account-cost-centers": {
58
+ "title": "@:governance.costCenters.title"
59
+ },
60
+ "account-cost-centers-id": {
61
+ "title": "@:governance.costCenters.title"
62
+ },
63
+ "account-direct-order": {
64
+ "title": "@:directOrder.title"
65
+ },
66
+ "account-order-lists": {
67
+ "title": "@:orderLists.title"
68
+ },
69
+ "account-order-lists-id": {
70
+ "title": "@:orderLists.title"
71
+ },
72
+ "account-orders": {
73
+ "title": "@:orders.title"
74
+ },
75
+ "account-orders-id": {
76
+ "title": "@:orders.title"
77
+ },
78
+ "account-organization": {
79
+ "title": "@:organization.title"
80
+ },
81
+ "account-preferences": {
82
+ "title": "@:preferences.title"
83
+ },
84
+ "account-profile": {
85
+ "title": "@:profile.title"
86
+ },
87
+ "account-quotes": {
88
+ "title": "@:quotes.title"
89
+ },
90
+ "account-quotes-id": {
91
+ "title": "@:quotes.title"
92
+ },
93
+ "account-requisitions": {
94
+ "title": "@:governance.requisitions.title"
95
+ },
96
+ "account-requisitions-id": {
97
+ "title": "@:governance.requisitions.title"
98
+ },
99
+ "account-team": {
100
+ "title": "@:team.title"
101
+ },
102
+ "account-workflows": {
103
+ "title": "@:governance.workflows.title"
104
+ },
105
+ "account-workflows-id": {
106
+ "title": "@:governance.workflows.title"
107
+ }
108
+ }
109
+ }
@@ -537,6 +537,10 @@
537
537
  "title": "No order lists",
538
538
  "description": "Create your first order list via “Add”."
539
539
  },
540
+ "noPositions": {
541
+ "title": "No positions yet",
542
+ "description": "Add articles from a product page or from the cart — via “Add to order list”."
543
+ },
540
544
  "saveTo": {
541
545
  "button": "Add to order list",
542
546
  "onLists": "On {count} list | On {count} lists",
@@ -194,6 +194,7 @@
194
194
  "requestedDateInvalid": "Please enter a valid date.",
195
195
  "submitError": "Failed to place order. Please try again.",
196
196
  "orderNumberRequired": "Please provide your order number.",
197
+ "requestedDateRequired": "Please pick a requested delivery date.",
197
198
  "requestedDatePast": "The requested date must not be in the past.",
198
199
  "requestedDateTooFar": "The requested date may be at most {days} days ahead.",
199
200
  "requestedDateWeekend": "Please pick a working day as the requested date.",
@@ -129,5 +129,11 @@
129
129
  "privacy": "Privacy policy",
130
130
  "terms": "Terms of service",
131
131
  "cookies": "Cookie policy"
132
+ },
133
+ "seo": {
134
+ "ogImage": {
135
+ "product": "Product",
136
+ "category": "Category"
137
+ }
132
138
  }
133
139
  }