Skip to content

Commit

Permalink
dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Jun 17, 2024
1 parent bb7b65b commit bdd8141
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
3 changes: 3 additions & 0 deletions content/training/project-config/new-project.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
+++
title = "New Project"
weight = 0

[extra]
dependencies = ["/training/rust/starter/"]
+++
3 changes: 3 additions & 0 deletions content/training/rust/benchmark.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
+++
title = "benchmarks"
weight = 3

[extra]
dependencies = ["/training/rust/tests/"]
+++
5 changes: 4 additions & 1 deletion content/training/rust/next.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
+++
title = "next"
weight = 1
+++

[extra]
dependencies = ["/training/rust/starter/"]
+++
3 changes: 3 additions & 0 deletions content/training/rust/tests.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
+++
title = "tests"
weight = 2

[extra]
dependencies = ["/training/rust/next/"]
+++
18 changes: 5 additions & 13 deletions graph-ui/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,13 @@ import ReactFlow, {
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' },
];
// import { content, dependencies } from "../generated/nodes";

import generated from '../generated/nodes';

const NestedFlow = () => {
const [nodes, setNodes, onNodesChange] = useNodesState(content);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
const [nodes, setNodes, onNodesChange] = useNodesState(generated.content);
const [edges, setEdges, onEdgesChange] = useEdgesState(generated.dependencies);

const onConnect = useCallback((connection: Edge | Connection) => {
setEdges((eds) => addEdge(connection, eds));
Expand Down
31 changes: 29 additions & 2 deletions templates/training/main.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from 'reactflow';
import { Node, Edge } from 'reactflow';

const content: Node[] = [
{% for subsection in section.subsections -%}
Expand Down Expand Up @@ -26,4 +26,31 @@
{% endfor -%}
];

export default content;

const dependencies: Edge[] = [
{% for subsection in section.subsections -%}
{% set subsection = get_section(path=subsection) -%}
{% set parent_index = loop.index -%}
{% for page in subsection.pages -%}
{% set page_index = loop.index -%}
{% set page_id = parent_index ~ "-" ~ page_index -%}
{% if page.extra.dependencies -%}
{% for dependency in page.extra.dependencies -%}
{% for subsection in section.subsections -%}
{% set subsection = get_section(path=subsection) -%}
{% set parent_index = loop.index -%}
{% for page in subsection.pages -%}
{% set page_index = loop.index -%}
{% if dependency == page.path -%}
{% set dependency_id = parent_index ~ "-" ~ page_index -%}
{ id: '{{page_id}}-{{dependency_id}}', target: '{{page_id}}', source: '{{dependency_id}}' },
{% endif -%}
{% endfor -%}
{% endfor -%}
{% endfor -%}
{% endif -%}
{% endfor -%}
{% endfor -%}
];

export default { content, dependencies };

0 comments on commit bdd8141

Please sign in to comment.