info-site-generator 1.0.1 → 1.0.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/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "plugins": ["@babel/plugin-syntax-jsx"]
3
+ }
@@ -1,9 +1,9 @@
1
- interface Page {
1
+ interface Page extends React.ReactElement {
2
2
  title: string;
3
3
  shortTitle?: string;
4
4
  linkText?: string;
5
5
  slug: string;
6
- content: string;
6
+ content?: string;
7
7
  description: string;
8
8
  withLink?: boolean;
9
9
  }
@@ -38,3 +38,7 @@ declare module "contentDefaults.json" {
38
38
  const data: SiteData;
39
39
  export default data;
40
40
  }
41
+ declare module "index.js" {
42
+ const SiteGen: Function;
43
+ export default SiteGen;
44
+ }
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import SiteGen from "./src/App.tsx";
1
+ import SiteGen from "./src/App.js";
2
2
 
3
3
  export default SiteGen;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "info-site-generator",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "index.js",
5
5
  "author": "Enderfarmer",
6
6
  "license": "MIT",
@@ -1,26 +1,28 @@
1
1
  import { HashRouter, Routes, Route } from "react-router-dom";
2
- import Home from "./pages/Home.tsx";
3
- import defaults from "./contentDefaults.json";
4
- import { ThemeContext } from "./theme.ts";
5
- import Wrapper from "./components/Wrapper.tsx";
6
- import { SiteData } from "./declarations";
2
+ import Home from "info-site-generator/src/pages/Home.tsx";
3
+ import defaults from "info-site-generator/src/contentDefaults.json";
4
+ import { ThemeContext } from "info-site-generator/src/theme.ts";
5
+ import Wrapper from "info-site-generator/src/components/Wrapper.tsx";
6
+ import { SiteData } from "info-site-generator/declarations";
7
7
  import "./index.css";
8
- import Content from "./pages/Content.tsx";
9
- import PageGen from "./pages/Page.tsx";
10
- import Search from "./pages/Search.tsx";
8
+ import Content from "info-site-generator/src/pages/Content.tsx";
9
+ import PageGen from "info-site-generator/src/pages/Page.tsx";
10
+ import Search from "info-site-generator/src/pages/Search.tsx";
11
+ import React from "react";
11
12
 
12
13
  /**
13
14
  * The info site generator
14
- * @param data {SiteData} The data of the site in SiteData format
15
+ * @param {SiteData} data The data of the site in SiteData format
16
+ * @param {React.ReactNode[]} children The children
15
17
  * @returns A ready app based on the data provided
16
18
  */
17
- function SiteGen({ data }: { data: SiteData }) {
19
+ function SiteGen({ data, children }) {
18
20
  // loop through the possible site data and set defaults
19
21
  let dataSecond = data;
20
- Object.keys(defaults).forEach((key: string) => {
22
+ Object.keys(defaults).forEach((key) => {
21
23
  dataSecond[key] = data[key] || defaults[key];
22
24
  });
23
- let validData: SiteData = dataSecond as unknown as SiteData;
25
+ let validData = dataSecond;
24
26
  validData.pages?.forEach((page) => {
25
27
  page.withLink = page.withLink ?? true;
26
28
  // page.withLink = page.withLink === undefined ? false : page.withLink;
@@ -56,7 +58,7 @@ function SiteGen({ data }: { data: SiteData }) {
56
58
  />
57
59
  }
58
60
  />
59
- {validData.pages?.map((page) => (
61
+ {children.map((page) => (
60
62
  <Route
61
63
  element={
62
64
  <Wrapper
@@ -1,5 +1,5 @@
1
1
  import { oppositeTheme, useCurrentTheme } from "../theme.ts";
2
- import { SiteData, Theme } from "../declarations";
2
+ import { SiteData, Theme } from "../../declarations";
3
3
  import { useState } from "react";
4
4
  import { Link } from "react-router-dom";
5
5
  import "../styles/hamburgers.min.css";
@@ -1,4 +1,4 @@
1
- import { SiteData } from "../declarations";
1
+ import { SiteData } from "../../declarations";
2
2
  import Footer from "./Footer.tsx";
3
3
  import Navbar from "./Navbar.tsx";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { Link } from "react-router-dom";
2
- import { SiteData } from "../declarations";
2
+ import { SiteData } from "../../declarations";
3
3
 
4
4
  export default function Content({ data }: { data: SiteData }) {
5
5
  return (
@@ -1,5 +1,5 @@
1
1
  import { Link } from "react-router-dom";
2
- import { Page, SiteData } from "../declarations";
2
+ import { Page, SiteData } from "../../declarations";
3
3
  import { useState } from "react";
4
4
  import "../styles/Home.css";
5
5
  export default function Home({ data }: { data: SiteData }) {
@@ -1,5 +1,5 @@
1
1
  import ArrowBack from "../components/ArrowBack.tsx";
2
- import { Page } from "../declarations";
2
+ import { Page } from "../../declarations";
3
3
 
4
4
  export default function PageGen({ page }: { page: Page }) {
5
5
  return (
@@ -11,10 +11,7 @@ export default function PageGen({ page }: { page: Page }) {
11
11
  </blockquote>
12
12
  <hr />
13
13
  <br />
14
- <div
15
- className="content"
16
- dangerouslySetInnerHTML={{ __html: page.content }}
17
- ></div>
14
+ {page.content || page}
18
15
  </div>
19
16
  );
20
17
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { Link, useLocation } from "react-router-dom";
3
- import { SiteData } from "../declarations";
3
+ import { SiteData } from "../../declarations";
4
4
 
5
5
  export default function Search({ data }: { data: SiteData }) {
6
6
  const searchParams = new URLSearchParams(useLocation().search);