mirror of
https://github.com/discourse/discourse-header-submenus.git
synced 2025-05-07 08:58:51 +00:00
prettier
This commit is contained in:
parent
6dbd02a9c3
commit
f94d936622
@ -1,5 +1,5 @@
|
||||
// Used instead of dasherize for backwards compatibility with stable
|
||||
const getClassName = text => {
|
||||
const getClassName = (text) => {
|
||||
return text.toLowerCase().replace(/\s/g, "-");
|
||||
};
|
||||
|
||||
@ -7,22 +7,21 @@ export default {
|
||||
setupComponent() {
|
||||
try {
|
||||
const splitMenuItems = settings.Menu_items.split("|").filter(Boolean);
|
||||
const splitSubmenuItems = settings.Submenu_items.split("|").filter(
|
||||
Boolean
|
||||
);
|
||||
const splitSubmenuItems =
|
||||
settings.Submenu_items.split("|").filter(Boolean);
|
||||
|
||||
const menuItemsArray = [];
|
||||
const SubmenuItemsArray = [];
|
||||
|
||||
splitSubmenuItems.forEach(item => {
|
||||
const fragments = item.split(",").map(fragment => fragment.trim());
|
||||
splitSubmenuItems.forEach((item) => {
|
||||
const fragments = item.split(",").map((fragment) => fragment.trim());
|
||||
const parent = fragments[0].toLowerCase();
|
||||
const text = fragments[1];
|
||||
|
||||
if (text.toLowerCase() === "divider") {
|
||||
const divider = {
|
||||
parent,
|
||||
divider: true
|
||||
divider: true,
|
||||
};
|
||||
return SubmenuItemsArray.push(divider);
|
||||
}
|
||||
@ -43,13 +42,13 @@ export default {
|
||||
icon,
|
||||
href,
|
||||
target,
|
||||
title
|
||||
title,
|
||||
};
|
||||
SubmenuItemsArray.push(submenuItem);
|
||||
});
|
||||
|
||||
splitMenuItems.forEach(item => {
|
||||
const fragments = item.split(",").map(fragment => fragment.trim());
|
||||
splitMenuItems.forEach((item) => {
|
||||
const fragments = item.split(",").map((fragment) => fragment.trim());
|
||||
const parentFor = fragments[0].toLowerCase();
|
||||
const text = fragments[0];
|
||||
const className = getClassName(text);
|
||||
@ -60,7 +59,7 @@ export default {
|
||||
const title = fragments[2];
|
||||
const view = fragments[3];
|
||||
const childItems = SubmenuItemsArray.filter(
|
||||
link => link.parent === parentFor
|
||||
(link) => link.parent === parentFor
|
||||
);
|
||||
|
||||
const menuItem = {
|
||||
@ -69,7 +68,7 @@ export default {
|
||||
icon,
|
||||
title,
|
||||
view,
|
||||
childItems
|
||||
childItems,
|
||||
};
|
||||
menuItemsArray.push(menuItem);
|
||||
});
|
||||
@ -78,7 +77,7 @@ export default {
|
||||
|
||||
this.setProperties({
|
||||
menuItems: menuItemsArray,
|
||||
showCaret
|
||||
showCaret,
|
||||
});
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
@ -87,5 +86,5 @@ export default {
|
||||
"There's an issue in the Header Submenus Component. Check if your settings are entered correctly"
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user