diff --git a/src/pages/index.jsx b/src/pages/index.jsx index dc794a155..e4cde99d2 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -4,7 +4,7 @@ import Head from "next/head"; import dynamic from "next/dynamic"; import classNames from "classnames"; import { useTranslation } from "next-i18next"; -import { useEffect, useContext, useState } from "react"; +import { useEffect, useContext, useState, useMemo } from "react"; import { BiError } from "react-icons/bi"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; @@ -230,6 +230,66 @@ function Home({ initialSettings }) { } }) + const servicesAndBookmarksGroups = useMemo(() => { + const layoutGroups = settings.layout ? Object.keys(settings.layout).map( + (groupName) => services?.find(g => g.name === groupName) ?? bookmarks?.find(b => b.name === groupName) + ).filter(g => g) : []; + + const serviceGroups = services?.filter(group => settings.layout?.[group.name] === undefined); + const bookmarkGroups = bookmarks.filter(group => settings.layout?.[group.name] === undefined); + + return <> + {layoutGroups.length > 0 &&