@dogsbay/adapter-tigera 0.2.0-beta.153 → 0.2.0-beta.155

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 (2) hide show
  1. package/dist/index.js +27 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -13,6 +13,23 @@ import { splicePartials } from "@dogsbay/format-docusaurus/adapter";
13
13
  import { loadVariables, substituteVariables } from "./variables.js";
14
14
  import { toStructural } from "./structural.js";
15
15
  import { TIGERA_DATA_COMPONENTS } from "./data-components.js";
16
+ /** `PaidProductDocCardLink`'s `url` as the component serves it: `/` added when missing. */
17
+ function paidCardHref(url) {
18
+ if (typeof url !== "string" || !url.trim())
19
+ return undefined;
20
+ const u = url.trim();
21
+ return u.startsWith("/") ? u : `/${u}`;
22
+ }
23
+ /** Tigera's card badge ("Cloud", "Enterprise"); a card has no badge, so its text starts with it. */
24
+ const PAID_PRODUCT_LABELS = { cloud: "Calico Cloud", enterprise: "Calico Enterprise" };
25
+ function paidCardDescription(product, description) {
26
+ // own keys only: `toString` or `__proto__` would read the prototype
27
+ const label = typeof product === "string" && Object.hasOwn(PAID_PRODUCT_LABELS, product) ? PAID_PRODUCT_LABELS[product] : undefined;
28
+ const text = typeof description === "string" ? description.trim() : "";
29
+ if (label && text)
30
+ return `${label} · ${text}`;
31
+ return label ?? (text || undefined);
32
+ }
16
33
  // ── Tigera custom components ────────────────────────────
17
34
  //
18
35
  // Mappings keep output clean instead of leaking raw JSX. Card-like components
@@ -26,12 +43,20 @@ const TIGERA_COMPONENTS = {
26
43
  DocCardLink: {
27
44
  type: "card",
28
45
  container: false,
29
- propsFromAttrs: (a) => ({ docId: a.docId, title: a.title || a.label, href: a.to || a.href }),
46
+ propsFromAttrs: (a) => ({ docId: a.docId, title: a.title || a.label, href: a.to || a.href, description: a.description || undefined }),
30
47
  },
48
+ // A paid feature in another product: its link is `url`, site-root, written without the
49
+ // leading `/` (the component adds it), and its badge names the product. The importer
50
+ // resolves the link like any other: into a product not imported, it is the published page.
31
51
  PaidProductDocCardLink: {
32
52
  type: "card",
33
53
  container: false,
34
- propsFromAttrs: (a) => ({ docId: a.docId, title: a.title || a.label, href: a.to || a.href }),
54
+ propsFromAttrs: (a) => ({
55
+ docId: a.docId,
56
+ title: a.title || a.label,
57
+ href: paidCardHref(a.url) ?? (a.to || a.href),
58
+ description: paidCardDescription(a.paidProductName, a.description),
59
+ }),
35
60
  },
36
61
  DocCardLinkLayout: { type: "cards", container: true },
37
62
  // Conditional rendering — keep the inner content, drop the wrapper.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/adapter-tigera",
3
- "version": "0.2.0-beta.153",
3
+ "version": "0.2.0-beta.155",
4
4
  "description": "Tigera/Calico site adapter for @dogsbay/format-docusaurus — resolves $[variable] substitution and Tigera-specific MDX components.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,8 +11,8 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
- "@dogsbay/corpus": "0.2.0-beta.153",
15
- "@dogsbay/format-docusaurus": "0.2.0-beta.153"
14
+ "@dogsbay/format-docusaurus": "0.2.0-beta.155",
15
+ "@dogsbay/corpus": "0.2.0-beta.155"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.20.1",