mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
support sort layout
This commit is contained in:
parent
672fc3716a
commit
82c69ff68d
@ -177,6 +177,21 @@ function Home({ initialSettings }) {
|
||||
|
||||
const servicesAndBookmarks = [...services.map(sg => sg.services).flat(), ...bookmarks.map(bg => bg.bookmarks).flat()]
|
||||
|
||||
// sort layout
|
||||
const layouts = Object.keys(initialSettings.layout);
|
||||
let sortedServices = [];
|
||||
const copiedServices = services.slice();
|
||||
layouts.forEach((currentServer) => {
|
||||
if (initialSettings.layout[currentServer]?.sort) {
|
||||
const idx = copiedServices.findIndex((service) => service.name === currentServer);
|
||||
sortedServices.push(...copiedServices.splice(idx, 1));
|
||||
}
|
||||
});
|
||||
|
||||
if (copiedServices.length) {
|
||||
sortedServices = sortedServices.concat(copiedServices);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (settings.language) {
|
||||
i18n.changeLanguage(settings.language);
|
||||
@ -263,9 +278,9 @@ function Home({ initialSettings }) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{services && (
|
||||
{sortedServices && (
|
||||
<div className="flex flex-wrap p-4 sm:p-8 sm:pt-4 items-start pb-2">
|
||||
{services.map((group) => (
|
||||
{sortedServices.map((group) => (
|
||||
<ServicesGroup key={group.name} services={group} layout={initialSettings.layout?.[group.name]} />
|
||||
))}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user