diff --git a/build.sh b/build.sh
index cdcfa33..7b48263 100755
--- a/build.sh
+++ b/build.sh
@@ -1,8 +1,8 @@
#!/bin/bash
zola build
-mkdir graph-ui/pages || true
-cp public/training/index.html graph-ui/pages/index.tsx
+mkdir graph-ui/generated || true
+cp public/training/index.html graph-ui/generated/nodes.ts
cd graph-ui
npm run build
cd ..
diff --git a/graph-ui/.gitignore b/graph-ui/.gitignore
index fb58e72..a738514 100644
--- a/graph-ui/.gitignore
+++ b/graph-ui/.gitignore
@@ -37,4 +37,4 @@ yarn-error.log*
next-env.d.ts
# page are generated
-pages/*.tsx
+generated/
diff --git a/graph-ui/pages/index.tsx b/graph-ui/pages/index.tsx
new file mode 100644
index 0000000..d3c280c
--- /dev/null
+++ b/graph-ui/pages/index.tsx
@@ -0,0 +1,60 @@
+import Image from "next/image";
+import { Inter } from "next/font/google";
+import 'reactflow/dist/style.css';
+
+const inter = Inter({ subsets: ["latin"] });
+
+const proOptions = { hideAttribution: true };
+
+
+
+export default function Home() {
+ return (
+ < div style={{ height: '100vh', width: '100vw' }}>
+
+
+ );
+}
+
+
+import { useCallback } from 'react';
+import ReactFlow, {
+ addEdge,
+ Background,
+ useNodesState,
+ useEdgesState,
+ MiniMap,
+ Controls,
+ Node,
+ Edge,
+ Connection,
+} from 'reactflow';
+import 'reactflow/dist/style.css';
+import content from "../generated/nodes";
+
+const initialEdges: Edge[] = [
+ // { id: 'e1-2', source: '1', target: '2', animated: true },
+ // { id: 'e1-3', source: '1', target: '3' },
+ // { id: 'e2a-4a', source: '2a', target: '4a' },
+ // { id: 'e3-4b', source: '3', target: '4b' },
+ // { id: 'e4a-4b1', source: '4a', target: '4b1' },
+ // { id: 'e4a-4b2', source: '4a', target: '4b2' },
+ // { id: 'e4b1-4b2', source: '4b1', target: '4b2' },
+];
+
+const NestedFlow = () => {
+ const [nodes, setNodes, onNodesChange] = useNodesState(content);
+ const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
+
+ const onConnect = useCallback((connection: Edge | Connection) => {
+ setEdges((eds) => addEdge(connection, eds));
+ }, []);
+
+ return (
+
+
+
+
+ );
+};
diff --git a/templates/training/main.html b/templates/training/main.html
index d7aa731..8f272c4 100644
--- a/templates/training/main.html
+++ b/templates/training/main.html
@@ -1,44 +1,10 @@
-import Image from "next/image";
-import { Inter } from "next/font/google";
-import 'reactflow/dist/style.css';
+import { Node } from 'reactflow';
-const inter = Inter({ subsets: ["latin"] });
-
-const proOptions = { hideAttribution: true };
-
-{% raw %}
-
-export default function Home() {
-return (
-
- < div style={{ height: '100vh' , width: '100vw' } }>
-
-
-
-);
-}
-{% endraw %}
-
-import { useCallback } from 'react';
-import ReactFlow, {
-addEdge,
-Background,
-useNodesState,
-useEdgesState,
-MiniMap,
-Controls,
-Node,
-Edge,
-Connection,
-} from 'reactflow';
-import 'reactflow/dist/style.css';
-
-const initialNodes: Node[] = [
-
-{% for subsection in section.subsections %}
-{% set subsection = get_section(path=subsection) %}
-{% set parent_index = loop.index %}
-{% set container_height = subsection.pages | length * 50 %}
+const content: Node[] = [
+{% for subsection in section.subsections -%}
+{% set subsection = get_section(path=subsection) -%}
+{% set parent_index = loop.index -%}
+{% set container_height = subsection.pages | length * 50 -%}
{
id: '{{parent_index}}',
data: { label: '{{subsection.title}}' },
@@ -46,41 +12,15 @@
className: 'light',
style: { backgroundColor: 'rgba(255, 0, 0, 0.2)', width: 200, height: {{ container_height + 50 }}},
},
-{% for page in subsection.pages %}
-
+{% for page in subsection.pages -%}
{
id: '{{parent_index}}-{{loop.index}}',
data: { label: '{{page.title}}' },
position: { x: 20, y: {{loop.index0 * 50 + 50}} },
parentId: '{{parent_index}}',
},
-{% endfor %}
-{% endfor %}
-];
-
-const initialEdges: Edge[] = [
-// { id: 'e1-2', source: '1', target: '2', animated: true },
-// { id: 'e1-3', source: '1', target: '3' },
-// { id: 'e2a-4a', source: '2a', target: '4a' },
-// { id: 'e3-4b', source: '3', target: '4b' },
-// { id: 'e4a-4b1', source: '4a', target: '4b1' },
-// { id: 'e4a-4b2', source: '4a', target: '4b2' },
-// { id: 'e4b1-4b2', source: '4b1', target: '4b2' },
+{% endfor -%}
+{% endfor -%}
];
-const NestedFlow = () => {
-const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
-const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
-
-const onConnect = useCallback((connection: Edge | Connection) => {
-setEdges((eds) => addEdge(connection, eds));
-}, []);
-
-return (
-
-
-
-
-);
-};
\ No newline at end of file
+export default content;
\ No newline at end of file