19 lines
543 B
JavaScript
19 lines
543 B
JavaScript
window.hubl.getRoute = (type, returnFirst = false) => {
|
|
let availables = components.filter(c=>c.type==type||c.uniq==type);
|
|
availables.map(c => {
|
|
if(c.extensions) {
|
|
c.extensions.forEach(e => availables.push(e.type));
|
|
}
|
|
});
|
|
if(availables.length > 1) {
|
|
if(returnFirst) {
|
|
return availables[0].route;
|
|
} else {
|
|
return availables[availables.length-1].route;
|
|
}
|
|
} else if(availables.length < 1) {
|
|
console.error(`No component found for route ${type}`);
|
|
} else {
|
|
return availables[0].route;
|
|
}
|
|
} |