Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

feat: add web search engines (#290)

Meier Lukas35ca73274475
diff --git a/packages/spotlight/src/component.tsx b/packages/spotlight/src/component.tsx
index 04ab475b2..6ed210a13 100644
--- a/packages/spotlight/src/component.tsx
+++ b/packages/spotlight/src/component.tsx
@@ -25,8 +25,10 @@ import classes from "./component.module.css";
import { actionsAtomRead, groupsAtomRead } from "./data-store";
import { setSelectedAction, spotlightStore } from "./spotlight-store";
import type { SpotlightActionData } from "./type";
+import { useWebSearchEngines } from "./web-search-engines";
export const Spotlight = () => {
+ useWebSearchEngines();
const [query, setQuery] = useState("");
const [group, setGroup] = useState("all");
const groups = useAtomValue(groupsAtomRead);
@@ -46,7 +48,11 @@ export const Spotlight = () => {
const renderRoot =
item.type === "link"
? (props: Record<string, unknown>) => (
- <Link href={prepareHref(item.href, query)} {...props} />
+ <Link
+ href={prepareHref(item.href, query)}
+ target={item.openInNewTab ? "_blank" : undefined}
+ {...props}
+ />
)
: undefined;
diff --git a/packages/spotlight/src/index.ts b/packages/spotlight/src/index.ts
index e7d5f2bb3..d0e3aa43a 100644
--- a/packages/spotlight/src/index.ts
+++ b/packages/spotlight/src/index.ts
@@ -3,6 +3,7 @@
import { spotlightActions } from "./spotlight-store";
export { Spotlight } from "./component";
+export { useRegisterSpotlightActions } from "./data-store";
+export { openSpotlight };
const openSpotlight = spotlightActions.open;
-export { openSpotlight };
diff --git a/packages/spotlight/src/type.ts b/packages/spotlight/src/type.ts
index 3f769f71b..d8cb6b683 100644
--- a/packages/spotlight/src/type.ts
+++ b/packages/spotlight/src/type.ts
@@ -19,6 +19,7 @@ interface BaseSpotlightAction {
interface SpotlightActionLink extends BaseSpotlightAction {
type: "link";
href: string;
+ openInNewTab?: boolean;
}
type MaybePromise<T> = T | Promise<T>;
diff --git a/packages/spotlight/src/web-search-engines.ts b/packages/spotlight/src/web-search-engines.ts
new file mode 100644
index 000000000..79ade4068
--- /dev/null
+++ b/packages/spotlight/src/web-search-engines.ts
@@ -0,0 +1,63 @@
+import { IconDownload } from "@homarr/ui";
+
+import { useRegisterSpotlightActions } from "./data-store";
+
+export const useWebSearchEngines = () => {
+ useRegisterSpotlightActions("web-search-engines", [
+ {
+ id: "google",
+ title: "Google",
+ description: "Search the web with Google",
+ icon: "https://www.google.com/favicon.ico",
+ href: "https://www.google.com/search?q=%s",
+ group: "web",
+ type: "link",
+ ignoreSearchAndOnlyShowInGroup: true,
+ openInNewTab: true,
+ },
+ {
+ id: "bing",
+ title: "Bing",
+ description: "Search the web with Bing",
+ icon: "https://www.bing.com/favicon.ico",
+ href: "https://www.bing.com/search?q=%s",
+ group: "web",
+ type: "link",
+ ignoreSearchAndOnlyShowInGroup: true,
+ openInNewTab: true,
+ },
+ {
+ id: "duckduckgo",
+ title: "DuckDuckGo",
+ description: "Search the web with DuckDuckGo",
+ icon: "https://duckduckgo.com/favicon.ico",
+ href: "https://duckduckgo.com/?q=%s",
+ group: "web",
+ type: "link",
+ ignoreSearchAndOnlyShowInGroup: true,
+ openInNewTab: true,
+ },
+ {
+ id: "torrent",
+ title: "Torrents",
+ description: "Search for torrents on torrentdownloads.pro",
+ icon: IconDownload,
+ href: "https://www.torrentdownloads.pro/search/?search=%s",
+ group: "web",
+ type: "link",
+ ignoreSearchAndOnlyShowInGroup: true,
+ openInNewTab: true,
+ },
+ {
+ id: "youtube",
+ title: "YouTube",
+ description: "Search for videos on YouTube",
+ icon: "https://www.youtube.com/favicon.ico",
+ href: "https://www.youtube.com/results?search_query=%s",
+ group: "web",
+ type: "link",
+ ignoreSearchAndOnlyShowInGroup: true,
+ openInNewTab: true,
+ },
+ ]);
+};