@eldrajs/theme-nuxt 0.3.3 → 0.3.4

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 CHANGED
@@ -5,6 +5,12 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - **The site profile carries the registered company.** `readSiteProfile`, `resolveSiteProfile` and
9
+ `useSiteProfile()` gain `legal` (`{name, kennitala, streetAddress, postalCode, city,
10
+ countryCode}` or `null`), from `GET /site/v1/site-profile` since public contract 5.1.0; a
11
+ platform before that reads as `null`. The starter writes it on the home `Organization` as
12
+ `legalName`, `taxID` and `address`.
13
+
8
14
  - **Prerender reads shared lists once per build (WS-406).** `nuxi generate` created a client per
9
15
  route, so the page list, the route-template list and the category list behind link resolution
10
16
  were read once per route (the category list about 136 times in one staging build). During a
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.0"
6
6
  },
7
- "version": "0.3.3",
7
+ "version": "0.3.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
@@ -25,7 +25,7 @@ export declare function useStructuredData(entries: MaybeRefOrGetter<readonly Str
25
25
  enabled?: MaybeRefOrGetter<boolean>;
26
26
  }): void;
27
27
  /**
28
- * The shop's profile for an `Organization` node (name, logo, social links, contact), with the
28
+ * The shop's profile for an `Organization` node (name, logo, social links, contact, legal details), with the
29
29
  * site name and the site icon filling what the merchant left unset, plus the site's origin.
30
30
  * `siteUrl` is `''` when the build does not know it; the page then has no absolute URL to write,
31
31
  * and should write no node that needs one.
@@ -50,6 +50,7 @@ export function useSiteProfile() {
50
50
  email: resolved?.contact?.email || null,
51
51
  telephone: resolved?.contact?.telephone || null
52
52
  },
53
+ legal: resolved?.legal ?? null,
53
54
  siteUrl: seo.siteUrl ?? ""
54
55
  };
55
56
  }
@@ -16,6 +16,19 @@ export interface SiteProfileSetting {
16
16
  email: string | null;
17
17
  telephone: string | null;
18
18
  };
19
+ /** The registered company, or `null` for a sole trader, no legal details, or a platform before 5.1.0. */
20
+ legal: SiteProfileLegal | null;
21
+ }
22
+ /** The registered company behind the site, from the organisation's legal details in Studio. */
23
+ export interface SiteProfileLegal {
24
+ name: string | null;
25
+ /** As people write it, `dddddd-dddd`. */
26
+ kennitala: string;
27
+ streetAddress: string | null;
28
+ postalCode: string | null;
29
+ city: string | null;
30
+ /** ISO 3166-1 alpha-2. */
31
+ countryCode: string | null;
19
32
  }
20
33
  /** What a page's `Organization` is written from: gaps already filled, `name` never empty. */
21
34
  export interface ResolvedSiteProfile {
@@ -26,6 +39,7 @@ export interface ResolvedSiteProfile {
26
39
  email: string | null;
27
40
  telephone: string | null;
28
41
  };
42
+ legal: SiteProfileLegal | null;
29
43
  }
30
44
  /**
31
45
  * The slice of an `@eldrajs/sdk` client this read needs — a whole `EldraClient` satisfies it. The
@@ -42,6 +42,8 @@ function toSiteProfile(value) {
42
42
  const { email, telephone } = contact;
43
43
  if (email !== null && typeof email !== "string") return null;
44
44
  if (telephone !== null && typeof telephone !== "string") return null;
45
+ const legal = toLegal(record.legal);
46
+ if (legal === void 0) return null;
45
47
  return {
46
48
  revision: record.revision,
47
49
  name: name === null ? null : name.trim() || null,
@@ -49,9 +51,26 @@ function toSiteProfile(value) {
49
51
  // A profile link that is not https is dropped, not repaired: a wrong `sameAs` claims an
50
52
  // identity the shop may not hold.
51
53
  sameAs: sameAs.map((url) => url.trim()).filter(isHttpsUrl),
52
- contact: { email: email?.trim() || null, telephone: telephone?.trim() || null }
54
+ contact: { email: email?.trim() || null, telephone: telephone?.trim() || null },
55
+ legal
53
56
  };
54
57
  }
58
+ function toLegal(value) {
59
+ if (value === void 0 || value === null) return null;
60
+ if (typeof value !== "object") return void 0;
61
+ const { kennitala, ...parts } = value;
62
+ if (typeof kennitala !== "string" || kennitala.trim() === "") return void 0;
63
+ const text = (part) => part === void 0 || part === null ? null : typeof part === "string" ? part.trim() || null : void 0;
64
+ const legal = {
65
+ name: text(parts.name),
66
+ kennitala: kennitala.trim(),
67
+ streetAddress: text(parts.streetAddress),
68
+ postalCode: text(parts.postalCode),
69
+ city: text(parts.city),
70
+ countryCode: text(parts.countryCode)
71
+ };
72
+ return Object.values(legal).includes(void 0) ? void 0 : legal;
73
+ }
55
74
  function isHttpsUrl(value) {
56
75
  try {
57
76
  return new URL(value).protocol === "https:";
@@ -64,6 +83,7 @@ export function resolveSiteProfile(setting, defaults) {
64
83
  name: setting?.name ?? defaults.siteName,
65
84
  logoUrl: setting?.logoUrl ?? defaults.iconLogoUrl,
66
85
  sameAs: setting?.sameAs ?? [],
67
- contact: setting?.contact ?? { email: null, telephone: null }
86
+ contact: setting?.contact ?? { email: null, telephone: null },
87
+ legal: setting?.legal ?? null
68
88
  };
69
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-nuxt",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Nuxt module for Eldra themes: wires @eldrajs/vite-plugin-theme, the gateway client, draft overlays and the Studio preview bridge into a Nuxt 4 site.",
5
5
  "keywords": [
6
6
  "cms",
@@ -51,9 +51,9 @@
51
51
  "@nuxt/kit": "^4.0.0",
52
52
  "defu": "^6.1.4",
53
53
  "@eldrajs/sdk": "^0.3.2",
54
- "@eldrajs/theme-core": "^0.3.1",
55
- "@eldrajs/vite-plugin-theme": "^0.3.1",
56
- "@eldrajs/theme-vue": "^0.2.2"
54
+ "@eldrajs/theme-vue": "^0.2.3",
55
+ "@eldrajs/vite-plugin-theme": "^0.3.2",
56
+ "@eldrajs/theme-core": "^0.3.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@nuxt/module-builder": "^0.8.4",