+
+ );
+}
diff --git a/pages/search.tsx b/pages/search.tsx
new file mode 100644
index 0000000..4126896
--- /dev/null
+++ b/pages/search.tsx
@@ -0,0 +1,59 @@
+// Copyright (C) 2022-present Daniel31x13
+// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
+// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License along with this program. If not, see .
+
+import LinkList from "@/components/LinkList";
+import Dashboard from "@/layouts/Dashboard";
+import useLinkStore from "@/store/links";
+import useSearchSettingsStore from "@/store/search";
+import { ExtendedLink } from "@/types/global";
+import { faSearch } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useEffect, useState } from "react";
+
+export default function Links() {
+ const { links } = useLinkStore();
+
+ const [filteredLinks, setFilteredLinks] = useState([]);
+
+ const { searchSettings } = useSearchSettingsStore();
+
+ useEffect(() => {
+ const { name, url, title, collection, tags } = searchSettings.filter;
+
+ const filter = links.filter((link) => {
+ const query = searchSettings.query.toLowerCase();
+
+ if (
+ (name && link.name.toLowerCase().includes(query)) ||
+ (url && link.url.toLowerCase().includes(query)) ||
+ (title && link.title.toLowerCase().includes(query)) ||
+ (collection && link.collection.name.toLowerCase().includes(query)) ||
+ (tags &&
+ link.tags.some((tag) => tag.name.toLowerCase().includes(query)))
+ )
+ return true;
+ });
+
+ setFilteredLinks(filter);
+ }, [searchSettings]);
+
+ return (
+
+
+
+ );
+}
diff --git a/store/search.ts b/store/search.ts
new file mode 100644
index 0000000..62ef8b5
--- /dev/null
+++ b/store/search.ts
@@ -0,0 +1,47 @@
+// Copyright (C) 2022-present Daniel31x13
+// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
+// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License along with this program. If not, see .
+
+import { SearchSettings } from "@/types/global";
+import { create } from "zustand";
+
+type SearchSettingsState = {
+ searchSettings: SearchSettings;
+ setSearchSettings: (searchSettings: SearchSettings) => void;
+ toggleCheckbox: (name: keyof SearchSettings["filter"]) => void;
+ setSearchQuery: (query: string) => void;
+};
+
+const useSearchSettingsStore = create((set) => ({
+ searchSettings: {
+ query: "",
+ filter: {
+ name: true,
+ url: true,
+ title: true,
+ collection: true,
+ tags: true,
+ },
+ },
+ setSearchSettings: (searchSettings) => set({ searchSettings }),
+ toggleCheckbox: (name) =>
+ set((state) => ({
+ searchSettings: {
+ ...state.searchSettings,
+ filter: {
+ ...state.searchSettings.filter,
+ [name]: !state.searchSettings.filter[name],
+ },
+ },
+ })),
+ setSearchQuery: (query) =>
+ set((state) => ({
+ searchSettings: {
+ ...state.searchSettings,
+ query,
+ },
+ })),
+}));
+
+export default useSearchSettingsStore;
diff --git a/types/global.ts b/types/global.ts
index 5da7f89..c9ec1ac 100644
--- a/types/global.ts
+++ b/types/global.ts
@@ -46,3 +46,14 @@ export interface ExtendedCollection extends Collection {
};
}[];
}
+
+export type SearchSettings = {
+ query: string;
+ filter: {
+ name: boolean;
+ url: boolean;
+ title: boolean;
+ collection: boolean;
+ tags: boolean;
+ };
+};