info-site-generator 1.1.3 → 1.1.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/lib/App.d.ts CHANGED
@@ -6,7 +6,7 @@ import React from "react";
6
6
  * @returns A ready app based on the data provided
7
7
  */
8
8
  declare function SiteGen({ data_provided, children, }: {
9
- data_provided: UserProvidedSiteData;
10
- children: React.ReactNode;
9
+ data_provided?: UserProvidedSiteData;
10
+ children?: React.ReactNode;
11
11
  }): import("react/jsx-runtime").JSX.Element;
12
12
  export default SiteGen;
package/lib/App.js CHANGED
@@ -29,11 +29,45 @@ function SiteGen(_ref) {
29
29
  data_provided,
30
30
  children
31
31
  } = _ref;
32
+ const childRenderCallback = child => {
33
+ // Check if it's a valid React element (not a string or null)
34
+ if (! /*#__PURE__*/_react.default.isValidElement(child)) {
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouter.Route, {
36
+ path: child.slug,
37
+ element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Wrapper.default, {
38
+ component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Page.default, {
39
+ data: child
40
+ }),
41
+ data: validData
42
+ })
43
+ });
44
+ }
45
+
46
+ // Tell TS this element has props with an 'id'
47
+ const pageElement = child;
48
+ const pageId = pageElement.props.id;
49
+
50
+ // Get the metadata from our data object
51
+ const pageMetadata = validData.pages[pageId];
52
+ if (!pageMetadata) {
53
+ console.warn("No metadata found in data object for page ID: ".concat(pageId));
54
+ return null;
55
+ }
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouter.Route, {
57
+ path: pageMetadata.slug,
58
+ element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Wrapper.default, {
59
+ data: validData,
60
+ component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Page.default, {
61
+ page: pageElement,
62
+ data: pageMetadata
63
+ })
64
+ })
65
+ }, pageId);
66
+ };
32
67
  const validData = _objectSpread(_objectSpread({}, _contentDefaults.default), data_provided);
33
68
  Object.values(validData.pages).forEach(page => {
34
69
  var _page$withLink;
35
70
  page.withLink = (_page$withLink = page.withLink) !== null && _page$withLink !== void 0 ? _page$withLink : true;
36
- // page.withLink = page.withLink === undefined ? false : page.withLink;
37
71
  });
38
72
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_theme.ThemeContext.Provider, {
39
73
  value: localStorage.getItem("theme") || "light",
@@ -63,31 +97,7 @@ function SiteGen(_ref) {
63
97
  data: validData
64
98
  })
65
99
  })
66
- }), _react.default.Children.map(children, child => {
67
- // Check if it's a valid React element (not a string or null)
68
- if (! /*#__PURE__*/_react.default.isValidElement(child)) return null;
69
-
70
- // Tell TS this element has props with an 'id'
71
- const pageElement = child;
72
- const pageId = pageElement.props.id;
73
-
74
- // Get the metadata from our data object
75
- const pageMetadata = validData.pages[pageId];
76
- if (!pageMetadata) {
77
- console.warn("No metadata found in data object for page ID: ".concat(pageId));
78
- return null;
79
- }
80
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouter.Route, {
81
- path: pageMetadata.slug,
82
- element: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Wrapper.default, {
83
- data: validData,
84
- component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Page.default, {
85
- page: pageElement,
86
- data: pageMetadata
87
- })
88
- })
89
- }, pageId);
90
- })]
100
+ }), children ? _react.default.Children.map(children, childRenderCallback) : _contentDefaults.default.pages.map(childRenderCallback)]
91
101
  })
92
102
  })
93
103
  });
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { PageData } from "../../declarations";
3
3
  export default function PageGen({ page, data, }: {
4
- page: React.ReactElement;
4
+ page?: React.ReactElement;
5
5
  data: PageData;
6
6
  }): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "info-site-generator",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "main": "lib/index.js",
5
5
  "author": "Enderfarmer",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "time saving"
17
17
  ],
18
18
  "scripts": {
19
- "prepublishOnly": "echo You sure that you compiled?",
19
+ "prepublishOnly": "npm run build",
20
20
  "build": "npm run build:js && npm run build:types",
21
21
  "build:js": "babel src -d lib --extensions \".ts,.tsx\" --copy-files",
22
22
  "build:types": "tsc"