mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Merge branch 'main' into openmeteo-widget
This commit is contained in:
@@ -21,6 +21,7 @@ import { SettingsContext } from "utils/contexts/settings";
|
||||
import { bookmarksResponse, servicesResponse, widgetsResponse } from "utils/config/api-response";
|
||||
import ErrorBoundary from "components/errorboundry";
|
||||
import themes from "utils/styles/themes";
|
||||
import QuickLaunch from "components/quicklaunch";
|
||||
|
||||
const ThemeToggle = dynamic(() => import("components/toggles/theme"), {
|
||||
ssr: false,
|
||||
@@ -173,6 +174,8 @@ function Home({ initialSettings }) {
|
||||
const { data: services } = useSWR("/api/services");
|
||||
const { data: bookmarks } = useSWR("/api/bookmarks");
|
||||
const { data: widgets } = useSWR("/api/widgets");
|
||||
|
||||
const servicesAndBookmarks = [...services.map(sg => sg.services).flat(), ...bookmarks.map(bg => bg.bookmarks).flat()]
|
||||
|
||||
useEffect(() => {
|
||||
if (settings.language) {
|
||||
@@ -188,6 +191,28 @@ function Home({ initialSettings }) {
|
||||
}
|
||||
}, [i18n, settings, color, setColor, theme, setTheme]);
|
||||
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [searchString, setSearchString] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
function handleKeyDown(e) {
|
||||
if (e.target.tagName === "BODY") {
|
||||
if (String.fromCharCode(e.keyCode).match(/(\w|\s)/g) && !(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
|
||||
setSearching(true);
|
||||
} else if (e.key === "Escape") {
|
||||
setSearchString("");
|
||||
setSearching(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
return function cleanup() {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@@ -211,6 +236,14 @@ function Home({ initialSettings }) {
|
||||
headerStyles[initialSettings.headerStyle || "underlined"]
|
||||
)}
|
||||
>
|
||||
<QuickLaunch
|
||||
servicesAndBookmarks={servicesAndBookmarks}
|
||||
searchString={searchString}
|
||||
setSearchString={setSearchString}
|
||||
isOpen={searching}
|
||||
close={setSearching}
|
||||
searchDescriptions={settings.quicklook?.searchDescriptions}
|
||||
/>
|
||||
{widgets && (
|
||||
<>
|
||||
{widgets
|
||||
|
||||
Reference in New Issue
Block a user