docs-util: add support for workflows in markdown theme (#8485)
* add template for workflows * initial changes * added support for parallel steps * added support for when * added merge options * fix merge options * fix to tooltip * clean up * remove redirects * fixes * theme fixes + added merge options * generate hook examples + fixes * changed namespaces * add custom autogenerator * change type of additional data
This commit is contained in:
@@ -15,3 +15,4 @@ export * from "./learning-paths"
|
||||
export * from "./set-obj-value"
|
||||
export * from "./sidebar-attach-href-common-options"
|
||||
export * from "./swr-fetcher"
|
||||
export * from "./workflow-diagram-utils"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { WorkflowSteps, WorkflowStepUi } from "types"
|
||||
|
||||
export const createNodeClusters = (steps: WorkflowSteps) => {
|
||||
const clusters: Record<number, WorkflowStepUi[]> = {}
|
||||
|
||||
steps.forEach((step) => {
|
||||
if (!clusters[step.depth]) {
|
||||
clusters[step.depth] = []
|
||||
}
|
||||
|
||||
if (step.type === "when") {
|
||||
const whenSteps = step.steps.map((whenStep) => ({
|
||||
...whenStep,
|
||||
depth: step.depth,
|
||||
when: step,
|
||||
}))
|
||||
clusters[step.depth].push(...whenSteps)
|
||||
} else {
|
||||
clusters[step.depth].push(step)
|
||||
}
|
||||
})
|
||||
|
||||
return clusters
|
||||
}
|
||||
|
||||
export const getNextCluster = (
|
||||
clusters: Record<number, WorkflowStepUi[]>,
|
||||
depth: number
|
||||
) => {
|
||||
const nextDepth = depth + 1
|
||||
return clusters[nextDepth]
|
||||
}
|
||||
Reference in New Issue
Block a user