Appearance
π Array-Based Routing β
WBC-Routes2 leverages the power of arrays to create complex, multi-part content flows in a clean, structured, and scalable way.
Instead of writing multiple components manually, you can describe a route view using an array of elements. Each array item becomes a block in the rendered output: markdown, file, image, component, or logic.
π‘ Why Arrays? β
- Arrays allow for ordered content definition.
- Easier to generate programmatically.
- Ideal for step-by-step flows, tutorials, or multi-block pages.
- Enable dynamic iteration through lists, APIs, or data-driven layouts.
π§± Simple Static Array Example β
js
{
path: "/array/static",
name: "ArrayStatic",
component: WBC,
props: {
item: [
"MD__## Welcome to Static Array Routing",
"<p>This is a static HTML block.</p>",
{
comp: "VAlert",
options: {
type: "success",
html: "β
Success message in a card"
}
},
"./docs/intro.md"
]
}
}π§ Dynamic Markdown with Loops β
You can generate content like lists dynamically using JS in an array.
js
{
path: "/array/markdown-loop",
name: "ArrayMarkdownLoop",
component: WBC,
props: {
item: [
"MD__### Programming Languages",
"~\"<~ul>,<li>,JavaScript,Python,Go,Rust\".split(',')"
]
}
}Rendered Output:
- JavaScript
- Python
- Go
- Rust
π Multilingual Array Structure β
Array entries can adapt to the language of the user by nesting language-specific objects.
js
{
path: "/array/multilang",
name: "ArrayMultilang",
component: WBC,
props: {
item: [
{
en: "MD__# Welcome",
fr: "MD__# Bienvenue",
ar: "MD__# Ω
Ψ±ΨΨ¨Ψ§"
},
{
en: "./docs/intro-en.md",
fr: "./docs/intro-fr.md"
},
{
comp: "div",
options: {
html: {
en: "This is the English message.",
fr: "Ceci est le message en franΓ§ais.",
ar: "ΩΨ°Ω ΩΩ Ψ§ΩΨ±Ψ³Ψ§ΩΨ© Ψ¨Ψ§ΩΩΨΊΨ© Ψ§ΩΨΉΨ±Ψ¨ΩΨ©."
}
}
}
]
}
}π Nested Component Arrays β
WBC allows nesting components inside layout wrappers via array format:
js
{
path: "/array/nested",
name: "ArrayNested",
component: WBC,
props: {
item: [
"<~VContainer|pa-10>",
"<VCard|ma-5 pa-3 blue lighten-4>",
"MD__### Card Content with Markdown",
{
comp: "VBtn",
options: {
html: "Click Me",
color: "primary"
}
},
"~./assets/image.jpg"
]
}
}π Mixing Markdown, JSON, Events, and More β
js
{
path: "/array/advanced",
name: "ArrayAdvanced",
component: WBC,
props: {
item: [
"MD__# Complex View",
"<p>This array holds dynamic and reactive blocks.</p>",
{
comp: "JsonViewer",
options: {
value: { name: "Alice", age: 30, active: true }
}
},
{
comp: "VBtn",
dive: true,
options: {
html: "Toggle",
color: "warning",
on: {
click: (that) => () => {
alert("Dynamic button clicked!");
}
}
}
},
{
comp: "meta",
title: "Advanced Array Routing",
description: "Demonstrates mixing multiple formats in WBC-Routes2"
}
]
}
}π¦ Array from External JS/JSON Source β
Load content arrays dynamically:
js
// file: ./routes/data/arrayContent.js
export default [
"MD__# Dynamic List",
{
comp: "div",
options: {
html: "Hello from imported array"
}
},
"~./assets/img.png"
];js
{
path: "/array/external",
name: "ArrayExternal",
component: WBC,
props: {
item: () => import("./routes/data/arrayContent.js")
}
}π Summary β
Array-based routing unlocks:
- Scalable, modular layout systems
- Dynamically computed routing content
- Language-adaptive content via structured arrays
- Clean separation between structure and logic