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 +3 -0
- package/{src/declarations.d.ts → declarations.d.ts} +6 -2
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/{App.tsx → App.js} +15 -13
- package/src/components/Navbar.tsx +1 -1
- package/src/components/Wrapper.tsx +1 -1
- package/src/pages/Content.tsx +1 -1
- package/src/pages/Home.tsx +1 -1
- package/src/pages/Page.tsx +2 -5
- package/src/pages/Search.tsx +1 -1
package/.babelrc
ADDED
|
@@ -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
|
|
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
package/package.json
CHANGED
package/src/{App.tsx → App.js}
RENAMED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { HashRouter, Routes, Route } from "react-router-dom";
|
|
2
|
-
import Home from "
|
|
3
|
-
import defaults from "
|
|
4
|
-
import { ThemeContext } from "
|
|
5
|
-
import Wrapper from "
|
|
6
|
-
import { SiteData } from "
|
|
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 "
|
|
9
|
-
import PageGen from "
|
|
10
|
-
import Search from "
|
|
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
|
|
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
|
|
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
|
|
22
|
+
Object.keys(defaults).forEach((key) => {
|
|
21
23
|
dataSecond[key] = data[key] || defaults[key];
|
|
22
24
|
});
|
|
23
|
-
let validData
|
|
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
|
-
{
|
|
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 "
|
|
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";
|
package/src/pages/Content.tsx
CHANGED
package/src/pages/Home.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Link } from "react-router-dom";
|
|
2
|
-
import { Page, SiteData } from "
|
|
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 }) {
|
package/src/pages/Page.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ArrowBack from "../components/ArrowBack.tsx";
|
|
2
|
-
import { Page } from "
|
|
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
|
-
|
|
15
|
-
className="content"
|
|
16
|
-
dangerouslySetInnerHTML={{ __html: page.content }}
|
|
17
|
-
></div>
|
|
14
|
+
{page.content || page}
|
|
18
15
|
</div>
|
|
19
16
|
);
|
|
20
17
|
}
|
package/src/pages/Search.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { Link, useLocation } from "react-router-dom";
|
|
3
|
-
import { SiteData } from "
|
|
3
|
+
import { SiteData } from "../../declarations";
|
|
4
4
|
|
|
5
5
|
export default function Search({ data }: { data: SiteData }) {
|
|
6
6
|
const searchParams = new URLSearchParams(useLocation().search);
|