@eldrajs/theme-cli 0.2.2 → 0.2.3
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/package.json +3 -3
- package/template/.eldra/previews.json +35 -35
- package/template/app/plugins/chunk-reload.client.ts +29 -0
- package/template/app/plugins/eldra-storefront.ts +5 -0
- package/template/app/storefront/gateway.ts +34 -11
- package/template/app/storefront/sharedRead.ts +34 -0
- package/template/app/storefront/structuredData.ts +17 -0
- package/template/app/utils/chunkReload.ts +11 -0
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +146 -94
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +116 -2
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +125 -541
- package/template/blocks/navigation/__tests__/Block.spec.ts +172 -73
- package/template/blocks/navigation/parts/MenuLink.vue +15 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/test/chunkReload.spec.ts +20 -0
- package/template/test/imageFraming.browser.spec.ts +125 -0
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/collection.spec.ts +1 -1
- package/template/test/pages/home.spec.ts +1 -1
- package/template/test/pages/product.spec.ts +1 -1
- package/template/test/prerenderRefresh.browser.spec.ts +8 -13
- package/template/test/storefront/gateway.spec.ts +6 -0
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -1
- package/template/test/storefront/sharedRead.spec.ts +43 -0
- package/template/test/storefront/structuredData.spec.ts +31 -0
- package/template/blocks/navigation/useMegaMenuKeys.ts +0 -276
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/theme-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "CLI for Eldra themes: init from the starter, scaffold blocks, validate, generate types, deploy a static build to Eldra.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"citty": "^0.1.6",
|
|
44
44
|
"tar": "^7.4.3",
|
|
45
|
-
"@eldrajs/theme-core": "^0.3.
|
|
46
|
-
"@eldrajs/vite-plugin-theme": "^0.3.
|
|
45
|
+
"@eldrajs/theme-core": "^0.3.2",
|
|
46
|
+
"@eldrajs/vite-plugin-theme": "^0.3.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"execa": "^9.5.2"
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
"announcement-bar": "
|
|
3
|
-
"article": "
|
|
4
|
-
"article-list": "
|
|
5
|
-
"breadcrumbs": "
|
|
6
|
-
"cart": "
|
|
7
|
-
"collection-grid": "
|
|
8
|
-
"collection-header": "
|
|
9
|
-
"contact": "
|
|
10
|
-
"cta": "
|
|
11
|
-
"faq": "
|
|
12
|
-
"feature-grid": "
|
|
13
|
-
"footer": "
|
|
14
|
-
"form": "
|
|
15
|
-
"gallery": "
|
|
16
|
-
"hero": "
|
|
17
|
-
"image": "
|
|
18
|
-
"logo-cloud": "
|
|
19
|
-
"navigation": "
|
|
20
|
-
"newsletter": "
|
|
21
|
-
"order-status": "
|
|
22
|
-
"pricing-table": "
|
|
23
|
-
"product-carousel": "
|
|
24
|
-
"product-detail": "
|
|
25
|
-
"quote": "
|
|
26
|
-
"rich-text": "
|
|
27
|
-
"search": "
|
|
28
|
-
"split-content": "
|
|
29
|
-
"stats": "
|
|
30
|
-
"tabs": "
|
|
31
|
-
"team": "
|
|
32
|
-
"testimonials": "
|
|
33
|
-
"timeline": "
|
|
34
|
-
"trust-strip": "
|
|
35
|
-
"video-embed": "
|
|
36
|
-
"wishlist": "
|
|
2
|
+
"announcement-bar": "8a689cf55c908f2049731c24d89007f12b303b686c331d11e3fef18263f43fee",
|
|
3
|
+
"article": "e3de7c95a5aa30507e551e37ccbec0c28067c500c7623dc8b77902b59893d828",
|
|
4
|
+
"article-list": "673c37d8c8019aa15facba9459a523aa9c89dc183ef27fa7b512a0a3574db377",
|
|
5
|
+
"breadcrumbs": "3b4f9c9144592a1d83b07f7bcecc7efdf875e789643412625335903e4f06c0c2",
|
|
6
|
+
"cart": "4dee720ac08788d623e814bbc02fe4e8f63e9471770ce445d189c7621421a639",
|
|
7
|
+
"collection-grid": "b1e016552881b4325eff64ec69a1232b3349fadfa136f7f8f1113a487c07848a",
|
|
8
|
+
"collection-header": "1eabde9b00ef3566cedab4566d021ff5c0bad20e69aafbed5b57a7788c0eb34f",
|
|
9
|
+
"contact": "061036ca4bd571a058230c54fff612686dfdc6465b59e28991b4c313c001fd3c",
|
|
10
|
+
"cta": "ace9143e94d3a8136ab06daf4875c493c5dff738a6a91d4e0486440aa2d65a21",
|
|
11
|
+
"faq": "b67c46e039e67ba5c3ee1a6050ff0c15d647b80d8e801516a89532f3e461f6b7",
|
|
12
|
+
"feature-grid": "44fb41a30935185fe2e00b0028b7b9fa46c98e71d20c9bd92d0a440513e44163",
|
|
13
|
+
"footer": "70c6b557b65a9e50db7d7345a40d516b82a1762251d1bd572b12dd3eebdf29e1",
|
|
14
|
+
"form": "0afb1e35077d8e9e43350f9e6e78192326c98d4b29ffe0c9caf916a9cdd36569",
|
|
15
|
+
"gallery": "a2c652a4ca579c581196fac0a698916b76cca52232df6e873f7bf80941353446",
|
|
16
|
+
"hero": "b9c98af851deb55a2747880d0da555b91e354081adad68dce84672d28178f774",
|
|
17
|
+
"image": "3fe172e731e1ff31f998155ba9cce82fb159b496a850f372af80941bd6dc660b",
|
|
18
|
+
"logo-cloud": "f5818878f713c885148161e90fa7d006aae35578fd893b9da511652dc29b88f9",
|
|
19
|
+
"navigation": "67b29fcfb822d5572ecd74c203070f92ec387e96607c137e662b953fcda73580",
|
|
20
|
+
"newsletter": "77d5c21da977426e037f38627c87b3a7ebbe4afec94936480d342642ac6d1d02",
|
|
21
|
+
"order-status": "0f7f858848ab13a4437c4c5e709ef4e232fe64dd2e868ebb8c5d79dc0a8728e8",
|
|
22
|
+
"pricing-table": "9c1a947af841e97cc87ff600edf3c53c7a54a9065a4bd72a42121e7b8bc2f715",
|
|
23
|
+
"product-carousel": "67379d314525e362d91c97e765cd2f6c60a58ab71ef993279a35a2d413f053ff",
|
|
24
|
+
"product-detail": "11b47a73b8ea60c2b73577b276da10a8fab5ca148070be7f4fe23ab390fca106",
|
|
25
|
+
"quote": "0a3aebe57b2b5d4128b3a8479b7fdb28951b182e576fae3d063e7b544d40dc5d",
|
|
26
|
+
"rich-text": "fe0eac23870282628672872bd8b57050415e2925b317390bf1a378670a628ea1",
|
|
27
|
+
"search": "418b02e1f70bd654670206a14bb8bbdc6da3f4b5e9871a637cd995fb9273cff3",
|
|
28
|
+
"split-content": "76a2ae7167ba86c15d1853bf391fa02f510822d348ac3d0a0b5ccfbc1f1b4f6c",
|
|
29
|
+
"stats": "42e663f6e51a95489797620f03423c739f6a6a602b79449b7a7bb992cf3cc1b1",
|
|
30
|
+
"tabs": "e8149e00646111ee090acf2fcc35cc4f55f3ccc3bfdbca0c692b9dd9dca0af52",
|
|
31
|
+
"team": "4351405de230c1b44ae354b24adc8effd403b97a3d65156a7f3cff0e28644e06",
|
|
32
|
+
"testimonials": "e4732b33affc438566c4c06bc06a35ab92d008c42e07390936bf42b830d3636c",
|
|
33
|
+
"timeline": "3e311d49e2d167e64899af12ca5677203ceb56159ef1a92bf390f8442057b65f",
|
|
34
|
+
"trust-strip": "4635537d093f5da1fc7f9bab83d4a43861280fc49d1546014102affc2355b675",
|
|
35
|
+
"video-embed": "e8065f78c5a1b51c2703b5cf70108f7d41100aa46dc78fc64f9232e138d7d832",
|
|
36
|
+
"wishlist": "b2b67468462794e4e28d6c72c31ad29ddb0730c7531f61f8773c9cbab0d8676c"
|
|
37
37
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from 'nuxt/app';
|
|
2
|
+
import { isChunkError, shouldReload } from '../utils/chunkReload';
|
|
3
|
+
|
|
4
|
+
const KEY = 'eldra:chunk-reload-at';
|
|
5
|
+
|
|
6
|
+
// A deploy renames every `_nuxt` chunk, so a tab or cached page from the old build asks for files that are gone and its lazy blocks never render.
|
|
7
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
8
|
+
function reloadOnce(): void {
|
|
9
|
+
let last: number | null = null;
|
|
10
|
+
try {
|
|
11
|
+
const stored = window.sessionStorage.getItem(KEY);
|
|
12
|
+
last = stored === null ? null : Number(stored);
|
|
13
|
+
if (!shouldReload(Date.now(), last)) return;
|
|
14
|
+
window.sessionStorage.setItem(KEY, String(Date.now()));
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
window.location.reload();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
window.addEventListener('vite:preloadError', (event) => {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
reloadOnce();
|
|
24
|
+
});
|
|
25
|
+
nuxtApp.hook('app:chunkError', reloadOnce);
|
|
26
|
+
nuxtApp.hook('vue:error', (error) => {
|
|
27
|
+
if (isChunkError(error)) reloadOnce();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type StorefrontPrerenderHandle,
|
|
14
14
|
type StorefrontRuntime,
|
|
15
15
|
} from '../storefront/gateway';
|
|
16
|
+
import { createSharedRead } from '../storefront/sharedRead';
|
|
16
17
|
import { withAnalytics } from '../storefront/analytics';
|
|
17
18
|
import { createVolatileRefresher } from '../storefront/refresh';
|
|
18
19
|
import {
|
|
@@ -178,6 +179,8 @@ export default defineNuxtPlugin({
|
|
|
178
179
|
formsEndpoint?: string;
|
|
179
180
|
};
|
|
180
181
|
|
|
182
|
+
// Build-wide reads (the category tree) are shared across the routes of a prerender (WS-406).
|
|
183
|
+
const shared = createSharedRead(publicConfig.eldra);
|
|
181
184
|
const client = createEldraClient({
|
|
182
185
|
apiBaseUrl: publicConfig.eldra?.gatewayUrl || undefined,
|
|
183
186
|
orgId: publicConfig.eldra?.orgId || undefined,
|
|
@@ -265,6 +268,8 @@ export default defineNuxtPlugin({
|
|
|
265
268
|
|
|
266
269
|
source = createGatewayStorefront(client, {
|
|
267
270
|
route,
|
|
271
|
+
// Build-wide reads (the category tree) are made once per prerender, not once per route.
|
|
272
|
+
shared,
|
|
268
273
|
// What the store sells in, as the platform published it — the module read it once during the
|
|
269
274
|
// build (`@eldrajs/theme-nuxt`), so a prerendered page already has it. `app/plugins/
|
|
270
275
|
// eldra-ui-messages.ts` provides the currency half to `@eldrajs/ui`; this puts the whole
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
import { fromMinorUnits, roundMoney, toMinorUnits } from './money';
|
|
18
18
|
import { chunkIds, collectVolatileTargets } from './volatile';
|
|
19
19
|
import { canonicalAvailabilityValues, OPTION_SOURCE_PREFIX } from './facets';
|
|
20
|
+
|
|
21
|
+
const TOGGLE_SOURCE_PREFIX = 'toggle:';
|
|
20
22
|
import { optionDisplayType, storefrontOptionKind } from './options';
|
|
21
23
|
import {
|
|
22
24
|
buildCategoryIndex,
|
|
@@ -1297,7 +1299,7 @@ const GATEWAY_UNSORTABLE: readonly string[] = ['best-selling'];
|
|
|
1297
1299
|
* - **`category` is a slug in the URL and a uuid in the request.** The block's values are the facet
|
|
1298
1300
|
* terms' slugs (a filtered view has to stay linkable and readable), while `categoryId` takes
|
|
1299
1301
|
* catalog ids, so the slugs are resolved through the store's own category list — see
|
|
1300
|
-
* `
|
|
1302
|
+
* `readCategoryRows`.
|
|
1301
1303
|
* - **`availability` is one value, not a set.** Both boxes ticked is every product, which is no
|
|
1302
1304
|
* filter at all, so nothing is sent; one box is sent as the platform's own
|
|
1303
1305
|
* `in_stock`/`out_of_stock` spelling, which `canonicalAvailabilityValues` also folds the retired
|
|
@@ -1319,6 +1321,8 @@ interface CatalogFilterQuery {
|
|
|
1319
1321
|
collectionId?: string[];
|
|
1320
1322
|
availability?: string;
|
|
1321
1323
|
option?: string[];
|
|
1324
|
+
/** `onSale=true`, the one boolean parameter the platform has today (`facets.toggles[]`'s `on_sale`). */
|
|
1325
|
+
onSale?: true;
|
|
1322
1326
|
}
|
|
1323
1327
|
|
|
1324
1328
|
/**
|
|
@@ -1396,9 +1400,8 @@ function priceParam(raw: string | undefined, currency: string | undefined): numb
|
|
|
1396
1400
|
* URL and the active-filter row all say is applied is a lie, so that one fails the collection read,
|
|
1397
1401
|
* which the block already draws as an error over the last good page.
|
|
1398
1402
|
*/
|
|
1399
|
-
async function
|
|
1400
|
-
|
|
1401
|
-
return buildCategoryIndex(rows);
|
|
1403
|
+
async function readCategoryRows(client: EldraClient): Promise<RawCategory[] | null> {
|
|
1404
|
+
return (await client.catalog.listCategories({})) as unknown as RawCategory[] | null;
|
|
1402
1405
|
}
|
|
1403
1406
|
|
|
1404
1407
|
/**
|
|
@@ -1466,6 +1469,11 @@ async function catalogFilterQuery(
|
|
|
1466
1469
|
if (known.length === 1) query.availability = known[0];
|
|
1467
1470
|
continue;
|
|
1468
1471
|
}
|
|
1472
|
+
if (source.startsWith(TOGGLE_SOURCE_PREFIX)) {
|
|
1473
|
+
// A toggle is a yes/no switch; only the one the platform has a parameter for (onSale) is sent.
|
|
1474
|
+
if (source.slice(TOGGLE_SOURCE_PREFIX.length) === 'on_sale') query.onSale = true;
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1469
1477
|
if (source === 'category') {
|
|
1470
1478
|
const { idBySlug } = await categoriesOnce();
|
|
1471
1479
|
const matched = selected
|
|
@@ -1895,6 +1903,14 @@ async function detailSnapshots(
|
|
|
1895
1903
|
|
|
1896
1904
|
export interface GatewayStorefrontOptions {
|
|
1897
1905
|
route: StorefrontRoute;
|
|
1906
|
+
/**
|
|
1907
|
+
* Shares a build-wide read between the storefronts of a prerender (WS-406): `nuxi generate`
|
|
1908
|
+
* creates one storefront per route, so a read that never changes during a build (the category
|
|
1909
|
+
* tree) would otherwise go out once per route. The app layer binds it to the site and passes
|
|
1910
|
+
* `@eldrajs/theme-nuxt/prerender`'s `memoizeForPrerender`, which runs `load` every time outside a
|
|
1911
|
+
* prerender. Omitted — Storybook, a spec — every storefront reads for itself.
|
|
1912
|
+
*/
|
|
1913
|
+
shared?: <T>(name: string, load: () => Promise<T>, locale: string | undefined) => Promise<T>;
|
|
1898
1914
|
/**
|
|
1899
1915
|
* Overrides where form submissions go (`forms.submit`); see `postToFormsEndpoint`. Form
|
|
1900
1916
|
* definitions still come from the platform. Also the endpoint `catalog.notifyBackInStock` posts to.
|
|
@@ -1992,11 +2008,11 @@ export function createGatewayStorefront(
|
|
|
1992
2008
|
/**
|
|
1993
2009
|
* The store's category tree, read at most once for the life of this storefront and only when
|
|
1994
2010
|
* something actually needs it: a category filter to resolve, a product page's breadcrumb trail, or
|
|
1995
|
-
* a category facet the platform could not place its own terms in (`
|
|
2011
|
+
* a category facet the platform could not place its own terms in (`readCategoryRows`).
|
|
1996
2012
|
*
|
|
1997
2013
|
* The in-flight read is what is cached, so a product page and a grid asking at once share one
|
|
1998
2014
|
* request; a failure drops the cache so the next read tries again rather than inheriting the first
|
|
1999
|
-
* one's error. Which callers swallow that failure and which let it through is on `
|
|
2015
|
+
* one's error. Which callers swallow that failure and which let it through is on `readCategoryRows`.
|
|
2000
2016
|
*
|
|
2001
2017
|
* It is read on the **server** during a prerender, inside the same `useAsyncData` the product or
|
|
2002
2018
|
* collection read runs under, so a generated product page carries its trail in the page payload
|
|
@@ -2004,10 +2020,17 @@ export function createGatewayStorefront(
|
|
|
2004
2020
|
*/
|
|
2005
2021
|
let categories: Promise<CategoryIndex> | null = null;
|
|
2006
2022
|
const categoriesOnce = (): Promise<CategoryIndex> => {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2023
|
+
// The rows, not the index, are what a build shares: the same list `@eldrajs/theme-nuxt` reads
|
|
2024
|
+
// for link targets, under the same memo name and key, so a build reads it once per locale.
|
|
2025
|
+
const read = (): Promise<RawCategory[] | null> => readCategoryRows(client);
|
|
2026
|
+
categories ??= (
|
|
2027
|
+
options.shared === undefined ? read() : options.shared('categories', read, locale?.())
|
|
2028
|
+
)
|
|
2029
|
+
.then((rows) => buildCategoryIndex(rows))
|
|
2030
|
+
.catch((caught: unknown) => {
|
|
2031
|
+
categories = null;
|
|
2032
|
+
throw caught;
|
|
2033
|
+
});
|
|
2011
2034
|
return categories;
|
|
2012
2035
|
};
|
|
2013
2036
|
|
|
@@ -2139,7 +2162,7 @@ export function createGatewayStorefront(
|
|
|
2139
2162
|
// add a serial round trip to every product page. The tree's failure is swallowed here — a
|
|
2140
2163
|
// product page without a category crumb is a product page, while a product page that 500s
|
|
2141
2164
|
// because the category list was unreachable is not — which is the opposite of what the
|
|
2142
|
-
// `category` *filter* does with the same read (`
|
|
2165
|
+
// `category` *filter* does with the same read (`readCategoryRows`).
|
|
2143
2166
|
const [stock, tree] = await Promise.all([
|
|
2144
2167
|
readStock(client, raw, signal),
|
|
2145
2168
|
categoriesOnce().catch(() => null),
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CATEGORIES_MEMO_NAME,
|
|
3
|
+
memoizeForPrerender,
|
|
4
|
+
prerenderMemoScope,
|
|
5
|
+
} from '@eldrajs/theme-nuxt/prerender';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How the storefront shares build-wide reads (WS-406). No Nuxt global is touched: the plugin passes
|
|
9
|
+
* the public runtime config.
|
|
10
|
+
*
|
|
11
|
+
* Reads are keyed gateway + organisation + locale, the same key `@eldrajs/theme-nuxt` uses for its
|
|
12
|
+
* own reads, so a list both ask for (the categories) is read once per build.
|
|
13
|
+
*/
|
|
14
|
+
export interface StorefrontSharedConfig {
|
|
15
|
+
gatewayUrl?: string;
|
|
16
|
+
orgId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type SharedRead = <T>(
|
|
20
|
+
name: string,
|
|
21
|
+
load: () => Promise<T>,
|
|
22
|
+
locale: string | undefined
|
|
23
|
+
) => Promise<T>;
|
|
24
|
+
|
|
25
|
+
export { CATEGORIES_MEMO_NAME };
|
|
26
|
+
|
|
27
|
+
export function createSharedRead(
|
|
28
|
+
config: StorefrontSharedConfig | undefined,
|
|
29
|
+
memoize: typeof memoizeForPrerender = memoizeForPrerender
|
|
30
|
+
): SharedRead {
|
|
31
|
+
const gatewayUrl = config?.gatewayUrl ?? '';
|
|
32
|
+
return (name, load, locale) =>
|
|
33
|
+
memoize(prerenderMemoScope(gatewayUrl, config?.orgId, locale), name, load);
|
|
34
|
+
}
|
|
@@ -58,6 +58,15 @@ export interface PageLdParts {
|
|
|
58
58
|
logoUrl: string | null;
|
|
59
59
|
sameAs: readonly string[];
|
|
60
60
|
contact: { email: string | null; telephone: string | null };
|
|
61
|
+
/** The registered company (`useSiteProfile().legal`), or `null`. */
|
|
62
|
+
legal: {
|
|
63
|
+
name: string | null;
|
|
64
|
+
kennitala: string;
|
|
65
|
+
streetAddress: string | null;
|
|
66
|
+
postalCode: string | null;
|
|
67
|
+
city: string | null;
|
|
68
|
+
countryCode: string | null;
|
|
69
|
+
} | null;
|
|
61
70
|
};
|
|
62
71
|
/** The site's search page path (`/search`, unprefixed: it follows the home URL), or `null` when
|
|
63
72
|
* the site has none. */
|
|
@@ -109,6 +118,14 @@ export function pageStructuredData(parts: PageLdParts): StructuredDataEntry[] {
|
|
|
109
118
|
logo: parts.profile.logoUrl,
|
|
110
119
|
sameAs: parts.profile.sameAs,
|
|
111
120
|
contact: parts.profile.contact,
|
|
121
|
+
legalName: parts.profile.legal?.name,
|
|
122
|
+
taxID: parts.profile.legal?.kennitala,
|
|
123
|
+
address: parts.profile.legal && {
|
|
124
|
+
streetAddress: parts.profile.legal.streetAddress,
|
|
125
|
+
postalCode: parts.profile.legal.postalCode,
|
|
126
|
+
addressLocality: parts.profile.legal.city,
|
|
127
|
+
addressCountry: parts.profile.legal.countryCode,
|
|
128
|
+
},
|
|
112
129
|
}),
|
|
113
130
|
},
|
|
114
131
|
{
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const CHUNK_ERROR =
|
|
2
|
+
/dynamically imported module|importing a module script failed|error loading dynamically imported module/i;
|
|
3
|
+
|
|
4
|
+
export function isChunkError(error: unknown): boolean {
|
|
5
|
+
return CHUNK_ERROR.test(error instanceof Error ? error.message : String(error));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** One reload per window of `windowMs`, so a chunk that stays missing cannot reload the page forever. */
|
|
9
|
+
export function shouldReload(now: number, lastReloadAt: number | null, windowMs = 30_000): boolean {
|
|
10
|
+
return lastReloadAt === null || now - lastReloadAt > windowMs;
|
|
11
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|