@lexibase/rdx-core 1.0.0-beta.2 → 1.0.0-beta.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.
@@ -22,6 +22,16 @@ function text(value, field, allowEmpty = false) {
22
22
  }
23
23
  return value;
24
24
  }
25
+ function component(value, field) {
26
+ if (typeof value !== "function" && !(record(value) && [
27
+ /* @__PURE__ */ Symbol.for("react.memo"),
28
+ /* @__PURE__ */ Symbol.for("react.forward_ref"),
29
+ /* @__PURE__ */ Symbol.for("react.lazy")
30
+ ].includes(value.$$typeof)))
31
+ throw new RdxConfigError(
32
+ `${field} must be a React component, not JSX or a file path.`
33
+ );
34
+ }
25
35
  function keys(value, allowed, field) {
26
36
  for (const key of Object.keys(value)) {
27
37
  if (!allowed.includes(key))
@@ -43,7 +53,16 @@ function resolveConfig(input) {
43
53
  const config = object(input, "default export");
44
54
  keys(
45
55
  config,
46
- ["title", "description", "lang", "docsDir", "theme", "navbar", "plugins"],
56
+ [
57
+ "title",
58
+ "description",
59
+ "lang",
60
+ "docsDir",
61
+ "theme",
62
+ "navbar",
63
+ "plugins",
64
+ "homepage"
65
+ ],
47
66
  ""
48
67
  );
49
68
  text(config.title, "title");
@@ -51,6 +70,41 @@ function resolveConfig(input) {
51
70
  text(config.description, "description", true);
52
71
  if (config.lang !== void 0) text(config.lang, "lang");
53
72
  if (config.docsDir !== void 0) text(config.docsDir, "docsDir");
73
+ if (config.homepage !== void 0) {
74
+ const homepage = object(config.homepage, "homepage");
75
+ keys(
76
+ homepage,
77
+ ["enabled", "component", "title", "description", "buttons"],
78
+ "homepage."
79
+ );
80
+ if (homepage.component !== void 0)
81
+ component(homepage.component, "homepage.component");
82
+ if (homepage.enabled !== void 0 && typeof homepage.enabled !== "boolean")
83
+ throw new RdxConfigError("homepage.enabled must be a boolean.");
84
+ if (homepage.title !== void 0) text(homepage.title, "homepage.title");
85
+ if (homepage.description !== void 0)
86
+ text(homepage.description, "homepage.description", true);
87
+ if (homepage.buttons !== void 0) {
88
+ if (!Array.isArray(homepage.buttons))
89
+ throw new RdxConfigError("homepage.buttons must be an array.");
90
+ for (const [index, value] of homepage.buttons.entries()) {
91
+ const field = `homepage.buttons[${index}]`;
92
+ const button = object(value, field);
93
+ keys(button, ["label", "href"], `${field}.`);
94
+ text(button.label, `${field}.label`);
95
+ const href = text(button.href, `${field}.href`);
96
+ if (/[\s\\]/.test(href) || !/^\/(?!\/)/.test(href) && !/^https?:\/\//i.test(href))
97
+ throw new RdxConfigError(
98
+ `${field}.href must be a root-relative path or http(s) URL.`
99
+ );
100
+ try {
101
+ new URL(href, "https://rdx.local");
102
+ } catch {
103
+ throw new RdxConfigError(`${field}.href must be a valid URL.`);
104
+ }
105
+ }
106
+ }
107
+ }
54
108
  if (config.theme !== void 0) {
55
109
  const theme = object(config.theme, "theme");
56
110
  keys(theme, ["defaultTheme"], "theme.");
@@ -62,11 +116,16 @@ function resolveConfig(input) {
62
116
  }
63
117
  if (config.navbar !== void 0) {
64
118
  const navbar = object(config.navbar, "navbar");
65
- keys(navbar, ["title", "actions"], "navbar.");
119
+ keys(navbar, ["title", "logo", "actions"], "navbar.");
120
+ if (navbar.logo !== void 0) component(navbar.logo, "navbar.logo");
66
121
  if (navbar.title !== void 0) text(navbar.title, "navbar.title", true);
67
122
  if (navbar.actions !== void 0) {
68
123
  const actions = object(navbar.actions, "navbar.actions");
69
- keys(actions, ["github"], "navbar.actions.");
124
+ keys(actions, ["github", "showToggleMode"], "navbar.actions.");
125
+ if (actions.showToggleMode !== void 0 && typeof actions.showToggleMode !== "boolean")
126
+ throw new RdxConfigError(
127
+ "navbar.actions.showToggleMode must be a boolean."
128
+ );
70
129
  if (actions.github !== void 0) {
71
130
  const github = object(actions.github, "navbar.actions.github");
72
131
  keys(github, ["visible", "url"], "navbar.actions.github.");
@@ -4,7 +4,7 @@ import {
4
4
  defineConfig,
5
5
  resolveConfig,
6
6
  resolveProjectPath
7
- } from "../chunk-WPEYN7KN.js";
7
+ } from "../chunk-VERHHVED.js";
8
8
  export {
9
9
  RdxConfigError,
10
10
  createRdxProject,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  defineConfig,
5
5
  resolveConfig,
6
6
  resolveProjectPath
7
- } from "./chunk-WPEYN7KN.js";
7
+ } from "./chunk-VERHHVED.js";
8
8
 
9
9
  // src/content/index.ts
10
10
  import fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexibase/rdx-core",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Content indexing and document utilities for RDX documentation projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,13 +34,13 @@
34
34
  "homepage": "https://github.com/lexibase/rdx#readme",
35
35
  "dependencies": {
36
36
  "gray-matter": "^4.0.3",
37
- "@lexibase/rdx-types": "1.0.0-beta.2"
37
+ "@lexibase/rdx-types": "1.0.0-beta.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.15.3",
41
41
  "@types/react": "19.1.0",
42
- "@rdx/eslint-config": "1.0.0",
43
- "@rdx/typescript-config": "1.0.0"
42
+ "@rdx/typescript-config": "1.0.0",
43
+ "@rdx/eslint-config": "1.0.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsup src/index.ts src/config/index.ts --format esm --dts --clean --external @lexibase/rdx-types --external gray-matter",