diff --git a/apps/portal/src/app/connect/quickstart/page.mdx b/apps/portal/src/app/wallets/quickstart/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/quickstart/page.mdx
rename to apps/portal/src/app/wallets/quickstart/page.mdx
diff --git a/apps/portal/src/app/connect/sidebar.tsx b/apps/portal/src/app/wallets/sidebar.tsx
similarity index 96%
rename from apps/portal/src/app/connect/sidebar.tsx
rename to apps/portal/src/app/wallets/sidebar.tsx
index f5411ef7ab2..9372845f092 100644
--- a/apps/portal/src/app/connect/sidebar.tsx
+++ b/apps/portal/src/app/wallets/sidebar.tsx
@@ -4,22 +4,18 @@ import { DotNetIcon, ReactIcon, TypeScriptIcon, UnityIcon } from "@/icons";
import { UnrealEngineIcon } from "../../icons/sdks/UnrealEngineIcon";
// TODO: move the following two slugs to walletSlug with updated docs
-const inAppSlug = "/connect/in-app-wallet";
+const inAppSlug = "/wallets/in-app-wallet";
-const walletSlug = "/connect/wallet";
-const aAslug = "/connect/account-abstraction";
-const authSlug = "/connect/auth";
+const walletSlug = "/wallets/wallet";
+const aAslug = "/wallets/account-abstraction";
+const authSlug = "/wallets/auth";
export const sidebar: SideBar = {
links: [
{ separator: true },
{
- href: "/connect",
- name: "Introduction",
- },
- {
- href: "/connect/why-thirdweb",
- name: "Why thirdweb?",
+ href: "/wallets",
+ name: "Overview",
},
{
href: "https://playground.thirdweb.com/",
@@ -325,5 +321,5 @@ export const sidebar: SideBar = {
name: "API References",
},
],
- name: "Connect",
+ name: "Wallets",
};
diff --git a/apps/portal/src/app/connect/sign-in/assets/ConnectEmbed-embedded.png b/apps/portal/src/app/wallets/sign-in/assets/ConnectEmbed-embedded.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/ConnectEmbed-embedded.png
rename to apps/portal/src/app/wallets/sign-in/assets/ConnectEmbed-embedded.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/Wide-dark.png b/apps/portal/src/app/wallets/sign-in/assets/Wide-dark.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/Wide-dark.png
rename to apps/portal/src/app/wallets/sign-in/assets/Wide-dark.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/compact-dark-social.png b/apps/portal/src/app/wallets/sign-in/assets/compact-dark-social.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/compact-dark-social.png
rename to apps/portal/src/app/wallets/sign-in/assets/compact-dark-social.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/compact-dark.png b/apps/portal/src/app/wallets/sign-in/assets/compact-dark.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/compact-dark.png
rename to apps/portal/src/app/wallets/sign-in/assets/compact-dark.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/connect-image-new.svg b/apps/portal/src/app/wallets/sign-in/assets/connect-image-new.svg
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/connect-image-new.svg
rename to apps/portal/src/app/wallets/sign-in/assets/connect-image-new.svg
diff --git a/apps/portal/src/app/connect/sign-in/assets/connect-playground.png b/apps/portal/src/app/wallets/sign-in/assets/connect-playground.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/connect-playground.png
rename to apps/portal/src/app/wallets/sign-in/assets/connect-playground.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/connect-wallet-modal.png b/apps/portal/src/app/wallets/sign-in/assets/connect-wallet-modal.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/connect-wallet-modal.png
rename to apps/portal/src/app/wallets/sign-in/assets/connect-wallet-modal.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/connect.png b/apps/portal/src/app/wallets/sign-in/assets/connect.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/connect.png
rename to apps/portal/src/app/wallets/sign-in/assets/connect.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/custom-modals.png b/apps/portal/src/app/wallets/sign-in/assets/custom-modals.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/custom-modals.png
rename to apps/portal/src/app/wallets/sign-in/assets/custom-modals.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/custom-welcome.png b/apps/portal/src/app/wallets/sign-in/assets/custom-welcome.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/custom-welcome.png
rename to apps/portal/src/app/wallets/sign-in/assets/custom-welcome.png
diff --git a/apps/portal/src/app/connect/sign-in/assets/narrow-wide.png b/apps/portal/src/app/wallets/sign-in/assets/narrow-wide.png
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/assets/narrow-wide.png
rename to apps/portal/src/app/wallets/sign-in/assets/narrow-wide.png
diff --git a/apps/portal/src/app/connect/sign-in/customization/page.mdx b/apps/portal/src/app/wallets/sign-in/customization/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/sign-in/customization/page.mdx
rename to apps/portal/src/app/wallets/sign-in/customization/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/add-partner.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/add-partner.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/add-partner.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/add-partner.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/create-ecosystem-wallet.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/create-ecosystem-wallet.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/create-ecosystem-wallet.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/create-ecosystem-wallet.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-info.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-info.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-info.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-info.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-wallet-permissions.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-wallet-permissions.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-wallet-permissions.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-wallet-permissions.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-wallet.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-wallet.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/ecosystem-wallet.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/ecosystem-wallet.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/full-login-system.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/full-login-system.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/full-login-system.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/full-login-system.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/single-login-option.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/single-login-option.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/single-login-option.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/single-login-option.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/wallet-explorer.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/wallet-explorer.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/wallet-explorer.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/wallet-explorer.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-create.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-create.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-create.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-create.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-guide.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-guide.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-guide.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-guide.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-url.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-url.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-url.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-url.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-wallet.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-wallet.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/walletconnect-wallet.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/walletconnect-wallet.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/assets/xai-connect-wallet-explorer.png b/apps/portal/src/app/wallets/wallet/ecosystem/assets/xai-connect-wallet-explorer.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/assets/xai-connect-wallet-explorer.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/assets/xai-connect-wallet-explorer.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/faq/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/faq/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/faq/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/faq/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/integrating-partners/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/integrating-partners/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/integrating-partners/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/integrating-partners/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/permissions/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/permissions/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/permissions/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/permissions/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/portal/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/portal/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/portal/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/portal/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/register-walletconnect/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/register-walletconnect/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/register-walletconnect/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/register-walletconnect/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/add-partner.png b/apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/add-partner.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/add-partner.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/add-partner.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/ecosystem-info.png b/apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/ecosystem-info.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/ecosystem-info.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/ecosystem-info.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/ecosystem-wallet-permissions.png b/apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/ecosystem-wallet-permissions.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/set-up/assets/ecosystem-wallet-permissions.png
rename to apps/portal/src/app/wallets/wallet/ecosystem/set-up/assets/ecosystem-wallet-permissions.png
diff --git a/apps/portal/src/app/connect/wallet/ecosystem/set-up/page.mdx b/apps/portal/src/app/wallets/wallet/ecosystem/set-up/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/ecosystem/set-up/page.mdx
rename to apps/portal/src/app/wallets/wallet/ecosystem/set-up/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/faq/page.mdx b/apps/portal/src/app/wallets/wallet/faq/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/faq/page.mdx
rename to apps/portal/src/app/wallets/wallet/faq/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/get-started/page.mdx b/apps/portal/src/app/wallets/wallet/get-started/page.mdx
similarity index 99%
rename from apps/portal/src/app/connect/wallet/get-started/page.mdx
rename to apps/portal/src/app/wallets/wallet/get-started/page.mdx
index d2ce951a6f6..c89b111ee52 100644
--- a/apps/portal/src/app/connect/wallet/get-started/page.mdx
+++ b/apps/portal/src/app/wallets/wallet/get-started/page.mdx
@@ -581,7 +581,7 @@ To connect with other auth strategies, use external wallets, or sponsor gas for
- [Sponsor Gas](/connect/account-abstraction/overview)
- [Implement Sign In with Ethereum](/connect/auth)
- [External Wallets](/connect/wallet/sign-in-methods/external-wallets)
-- [Onramp and Payments](/connect/pay/overview)
+- [Onramp and Payments](/payments)
## Explore Full SDK Documentation
diff --git a/apps/portal/src/app/connect/wallet/get-users/page.mdx b/apps/portal/src/app/wallets/wallet/get-users/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/get-users/page.mdx
rename to apps/portal/src/app/wallets/wallet/get-users/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/in-app-wallet/faq/page.mdx b/apps/portal/src/app/wallets/wallet/in-app-wallet/faq/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/in-app-wallet/faq/page.mdx
rename to apps/portal/src/app/wallets/wallet/in-app-wallet/faq/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/migrate-to-thirdweb/page.mdx b/apps/portal/src/app/wallets/wallet/migrate-to-thirdweb/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/migrate-to-thirdweb/page.mdx
rename to apps/portal/src/app/wallets/wallet/migrate-to-thirdweb/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/overview/assets/custom-modals.png b/apps/portal/src/app/wallets/wallet/overview/assets/custom-modals.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/overview/assets/custom-modals.png
rename to apps/portal/src/app/wallets/wallet/overview/assets/custom-modals.png
diff --git a/apps/portal/src/app/connect/wallet/overview/assets/ecosystem-wallet.png b/apps/portal/src/app/wallets/wallet/overview/assets/ecosystem-wallet.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/overview/assets/ecosystem-wallet.png
rename to apps/portal/src/app/wallets/wallet/overview/assets/ecosystem-wallet.png
diff --git a/apps/portal/src/app/connect/wallet/overview/page.mdx b/apps/portal/src/app/wallets/wallet/overview/page.mdx
similarity index 99%
rename from apps/portal/src/app/connect/wallet/overview/page.mdx
rename to apps/portal/src/app/wallets/wallet/overview/page.mdx
index 29d5aabcabd..3ff5fb7929c 100644
--- a/apps/portal/src/app/connect/wallet/overview/page.mdx
+++ b/apps/portal/src/app/wallets/wallet/overview/page.mdx
@@ -94,7 +94,7 @@ A flexible sign-up flow that accommodates different preferences is critical when
diff --git a/apps/portal/src/app/connect/wallet/pregenerate-wallets/page.mdx b/apps/portal/src/app/wallets/wallet/pregenerate-wallets/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/pregenerate-wallets/page.mdx
rename to apps/portal/src/app/wallets/wallet/pregenerate-wallets/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/security/assets/app-scoped.svg b/apps/portal/src/app/wallets/wallet/security/assets/app-scoped.svg
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/assets/app-scoped.svg
rename to apps/portal/src/app/wallets/wallet/security/assets/app-scoped.svg
diff --git a/apps/portal/src/app/connect/wallet/security/assets/ecosystem-scoped.svg b/apps/portal/src/app/wallets/wallet/security/assets/ecosystem-scoped.svg
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/assets/ecosystem-scoped.svg
rename to apps/portal/src/app/wallets/wallet/security/assets/ecosystem-scoped.svg
diff --git a/apps/portal/src/app/connect/wallet/security/assets/embed-creation.svg b/apps/portal/src/app/wallets/wallet/security/assets/embed-creation.svg
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/assets/embed-creation.svg
rename to apps/portal/src/app/wallets/wallet/security/assets/embed-creation.svg
diff --git a/apps/portal/src/app/connect/wallet/security/assets/enclave-wallet-creation.png b/apps/portal/src/app/wallets/wallet/security/assets/enclave-wallet-creation.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/assets/enclave-wallet-creation.png
rename to apps/portal/src/app/wallets/wallet/security/assets/enclave-wallet-creation.png
diff --git a/apps/portal/src/app/connect/wallet/security/legacy/page.mdx b/apps/portal/src/app/wallets/wallet/security/legacy/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/legacy/page.mdx
rename to apps/portal/src/app/wallets/wallet/security/legacy/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/security/page.mdx b/apps/portal/src/app/wallets/wallet/security/page.mdx
similarity index 100%
rename from apps/portal/src/app/connect/wallet/security/page.mdx
rename to apps/portal/src/app/wallets/wallet/security/page.mdx
diff --git a/apps/portal/src/app/connect/wallet/sign-in-methods/assets/social-config.png b/apps/portal/src/app/wallets/wallet/sign-in-methods/assets/social-config.png
similarity index 100%
rename from apps/portal/src/app/connect/wallet/sign-in-methods/assets/social-config.png
rename to apps/portal/src/app/wallets/wallet/sign-in-methods/assets/social-config.png
diff --git a/apps/portal/src/app/connect/wallet/sign-in-methods/configure/page.mdx b/apps/portal/src/app/wallets/wallet/sign-in-methods/configure/page.mdx
similarity index 96%
rename from apps/portal/src/app/connect/wallet/sign-in-methods/configure/page.mdx
rename to apps/portal/src/app/wallets/wallet/sign-in-methods/configure/page.mdx
index 1e18ef7b408..dc97af7ceef 100644
--- a/apps/portal/src/app/connect/wallet/sign-in-methods/configure/page.mdx
+++ b/apps/portal/src/app/wallets/wallet/sign-in-methods/configure/page.mdx
@@ -64,7 +64,7 @@ If you already have an auth system, you can use thirdweb to attach wallets to yo
void }) {
- const [input, setInput] = useState("");
- const debouncedInput = useDebounce(input, 500);
-
- const [selectedTags, setSelectedTags] = useState<{
- [T in Tag]?: boolean;
- }>({});
-
- const [enabledTags, setEnabledTags] = useState([]);
- const scrollableElement = useRef(null);
-
- const searchQuery = useQuery({
- enabled: debouncedInput.length > 0,
- placeholderData: keepPreviousData,
- queryFn: async () => {
- const res = await fetch(`/api/search?q=${encodeURI(debouncedInput)}`);
- const { results } = (await res.json()) as SearchResult;
-
- const tagsSet: Set = new Set([]);
-
- if (results.length > 0) {
- tagsSet.add("All");
- setSelectedTags({
- All: true,
- });
- }
-
- for (const r of results) {
- const tags = getTagsFromHref(r.pageHref);
- if (tags) {
- for (const tag of tags) {
- tagsSet.add(tag);
- }
- }
- }
-
- const tags = Array.from(tagsSet);
- setEnabledTags(tags);
-
- scrollableElement.current?.scrollTo({
- top: 0,
- });
-
- return results;
- },
- queryKey: ["search-index", debouncedInput],
- });
-
- const data = searchQuery.data;
- const noResults =
- debouncedInput && searchQuery.isFetched && data && data.length === 0;
-
- const handleLinkClick = () => {
- props.closeModal();
- };
-
- return (
-
- {/* Search */}
-
- {searchQuery.isFetching ? (
-
- ) : (
-
- )}
-
- {
- setInput(e.target.value);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" && e.target instanceof HTMLInputElement) {
- e.target.blur();
- }
- }}
- placeholder="Search docs"
- />
-
-
-
-
- {/* tags */}
- {enabledTags && enabledTags.length > 0 && (
-
- {enabledTags.map((tag) => (
-
- ))}
-
- )}
-
- {/* links */}
- {data && data.length > 0 && (
-
- {data.map((result) => {
- const tags = getTagsFromHref(result.pageHref);
-
- if (
- !selectedTags.All &&
- tags &&
- !tags.find((t) => selectedTags[t] === true)
- )
- return null;
-
- if (!tags && !selectedTags.All) {
- return null;
- }
-
- const sections = result.sections
- ?.filter((d) => d.content.length > 50)
- .slice(0, 2);
-
- return (
-
-
-
- {sections && sections.length > 0 && (
-
- {sections.map((sectionData) => {
- return (
-
- );
- })}
-
- )}
-
- );
- })}
-
- )}
-
- {/* No Results */}
- {noResults && (
-
- )}
-
- {!debouncedInput && (!data || data.length === 0) && (
-
- )}
-
-
-
- );
+ const [input, setInput] = useState("");
+ const debouncedInput = useDebounce(input, 500);
+
+ const [selectedTags, setSelectedTags] = useState<{
+ [T in Tag]?: boolean;
+ }>({});
+
+ const [enabledTags, setEnabledTags] = useState([]);
+ const scrollableElement = useRef(null);
+
+ const searchQuery = useQuery({
+ enabled: debouncedInput.length > 0,
+ placeholderData: keepPreviousData,
+ queryFn: async () => {
+ const res = await fetch(`/api/search?q=${encodeURI(debouncedInput)}`);
+ const { results } = (await res.json()) as SearchResult;
+
+ const tagsSet: Set = new Set([]);
+
+ if (results.length > 0) {
+ tagsSet.add("All");
+ setSelectedTags({
+ All: true,
+ });
+ }
+
+ for (const r of results) {
+ const tags = getTagsFromHref(r.pageHref);
+ if (tags) {
+ for (const tag of tags) {
+ tagsSet.add(tag);
+ }
+ }
+ }
+
+ const tags = Array.from(tagsSet);
+ setEnabledTags(tags);
+
+ scrollableElement.current?.scrollTo({
+ top: 0,
+ });
+
+ return results;
+ },
+ queryKey: ["search-index", debouncedInput],
+ });
+
+ const data = searchQuery.data;
+ const noResults =
+ debouncedInput && searchQuery.isFetched && data && data.length === 0;
+
+ const handleLinkClick = () => {
+ props.closeModal();
+ };
+
+ return (
+
+ {/* Search */}
+
+ {searchQuery.isFetching ? (
+
+ ) : (
+
+ )}
+
+ {
+ setInput(e.target.value);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && e.target instanceof HTMLInputElement) {
+ e.target.blur();
+ }
+ }}
+ placeholder="Search docs"
+ />
+
+
+
+
+ {/* tags */}
+ {enabledTags && enabledTags.length > 0 && (
+
+ {enabledTags.map((tag) => (
+
+ ))}
+
+ )}
+
+ {/* links */}
+ {data && data.length > 0 && (
+
+ {data.map((result) => {
+ const tags = getTagsFromHref(result.pageHref);
+
+ if (
+ !selectedTags.All &&
+ tags &&
+ !tags.find((t) => selectedTags[t] === true)
+ )
+ return null;
+
+ if (!tags && !selectedTags.All) {
+ return null;
+ }
+
+ const sections = result.sections
+ ?.filter((d) => d.content.length > 50)
+ .slice(0, 2);
+
+ return (
+
+
+
+ {sections && sections.length > 0 && (
+
+ {sections.map((sectionData) => {
+ return (
+
+ );
+ })}
+
+ )}
+
+ );
+ })}
+
+ )}
+
+ {/* No Results */}
+ {noResults && (
+
+ )}
+
+ {!debouncedInput && (!data || data.length === 0) && (
+
+ )}
+
+
+
+ );
}
function NoSearchLinks(props: { onClick?: () => void }) {
- return (
-
- {suggestedLinks.map((link) => {
- return (
-
- );
- })}
-
- );
+ return (
+
+ {suggestedLinks.map((link) => {
+ return (
+
+ );
+ })}
+
+ );
}
function useDebounce(value: string, delay: number) {
- const [debouncedValue, setDebouncedValue] = useState(value);
+ const [debouncedValue, setDebouncedValue] = useState(value);
- useEffect(() => {
- const handler = setTimeout(() => {
- setDebouncedValue(value);
- }, delay);
+ useEffect(() => {
+ const handler = setTimeout(() => {
+ setDebouncedValue(value);
+ }, delay);
- return () => {
- clearTimeout(handler);
- };
- }, [value, delay]);
+ return () => {
+ clearTimeout(handler);
+ };
+ }, [value, delay]);
- return debouncedValue;
+ return debouncedValue;
}
const queryClient = new QueryClient();
export function DocSearch(props: { variant: "icon" | "search" }) {
- const [open, setOpen] = useState(false);
-
- const forDesktop = props.variant === "search";
- useEffect(() => {
- if (!forDesktop) {
- return;
- }
- // when cmd+k on MacOS or ctrl+k on Windows is pressed, open the search modal
- const handleKeyDown = (e: KeyboardEvent) => {
- if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
- e.preventDefault();
- setOpen((v) => !v);
- }
- };
-
- document.body.addEventListener("keydown", handleKeyDown);
- return () => {
- document.body.removeEventListener("keydown", handleKeyDown);
- };
- }, [forDesktop]);
-
- // when escape is pressed, close the search modal
- useEffect(() => {
- if (!forDesktop) {
- return;
- }
- const handleKeyDown = (e: KeyboardEvent) => {
- if (e.key === "Escape") {
- setOpen(false);
- }
- };
-
- document.body.addEventListener("keydown", handleKeyDown);
- return () => {
- document.body.removeEventListener("keydown", handleKeyDown);
- };
- }, [forDesktop]);
-
- return (
-
-
-
- );
+ const [open, setOpen] = useState(false);
+
+ const forDesktop = props.variant === "search";
+ useEffect(() => {
+ if (!forDesktop) {
+ return;
+ }
+ // when cmd+k on MacOS or ctrl+k on Windows is pressed, open the search modal
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ setOpen((v) => !v);
+ }
+ };
+
+ document.body.addEventListener("keydown", handleKeyDown);
+ return () => {
+ document.body.removeEventListener("keydown", handleKeyDown);
+ };
+ }, [forDesktop]);
+
+ // when escape is pressed, close the search modal
+ useEffect(() => {
+ if (!forDesktop) {
+ return;
+ }
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === "Escape") {
+ setOpen(false);
+ }
+ };
+
+ document.body.addEventListener("keydown", handleKeyDown);
+ return () => {
+ document.body.removeEventListener("keydown", handleKeyDown);
+ };
+ }, [forDesktop]);
+
+ return (
+
+
+
+ );
}
function getTagsFromHref(href: string): Tag[] | undefined {
- if (href.includes("/react-native/v0")) {
- if (href.includes("/references")) {
- return ["Reference", "React Native"];
- }
- return ["React Native"];
- }
- if (href.includes("/react/v4")) {
- if (href.includes("/references")) {
- return ["Reference", "React"];
- }
- return ["React"];
- }
- if (href.includes("/typescript/v4")) {
- if (href.includes("/references")) {
- return ["Reference", "TypeScript"];
- }
- return ["TypeScript"];
- }
- if (href.includes("/wallet-sdk/v2")) {
- if (href.includes("/references")) {
- return ["Reference", "Wallet SDK"];
- }
- return ["Wallet SDK"];
- }
- if (href.includes("/unity")) {
- return ["Unity"];
- }
- if (href.includes("/typescript/v5")) {
- if (href.includes("/references")) {
- return ["Reference", "TypeScript"];
- }
- return ["TypeScript"];
- }
- if (href.includes("/react/v5")) {
- return ["React"];
- }
- if (href.includes("/connect")) {
- return ["Connect"];
- }
- if (href.includes("/engine")) {
- return ["Engine"];
- }
- if (href.includes("/infrastructure")) {
- return ["Infra"];
- }
- if (href.includes("/solidity")) {
- return ["Solidity"];
- }
- if (href.includes("/contracts")) {
- return ["Contracts"];
- }
- if (href.includes("/payments")) {
- return ["Payments"];
- }
- if (href.includes("/glossary")) {
- return ["Glossary"];
- }
+ if (href.includes("/react-native/v0")) {
+ if (href.includes("/references")) {
+ return ["Reference", "React Native"];
+ }
+ return ["React Native"];
+ }
+ if (href.includes("/react/v4")) {
+ if (href.includes("/references")) {
+ return ["Reference", "React"];
+ }
+ return ["React"];
+ }
+ if (href.includes("/typescript/v4")) {
+ if (href.includes("/references")) {
+ return ["Reference", "TypeScript"];
+ }
+ return ["TypeScript"];
+ }
+ if (href.includes("/wallet-sdk/v2")) {
+ if (href.includes("/references")) {
+ return ["Reference", "Wallet SDK"];
+ }
+ return ["Wallet SDK"];
+ }
+ if (href.includes("/unity")) {
+ return ["Unity"];
+ }
+ if (href.includes("/typescript/v5")) {
+ if (href.includes("/references")) {
+ return ["Reference", "TypeScript"];
+ }
+ return ["TypeScript"];
+ }
+ if (href.includes("/react/v5")) {
+ return ["React"];
+ }
+ if (href.includes("/wallets")) {
+ return ["Connect"];
+ }
+ if (href.includes("/engine")) {
+ return ["Engine"];
+ }
+ if (href.includes("/infrastructure")) {
+ return ["Infra"];
+ }
+ if (href.includes("/solidity")) {
+ return ["Solidity"];
+ }
+ if (href.includes("/contracts")) {
+ return ["Contracts"];
+ }
+ if (href.includes("/payments")) {
+ return ["Payments"];
+ }
+ if (href.includes("/glossary")) {
+ return ["Glossary"];
+ }
}
function SearchResultItem(props: {
- href: string;
- title: string;
- content?: string;
- tags?: Tag[];
- type: "page" | "section";
- onClick?: () => void;
+ href: string;
+ title: string;
+ content?: string;
+ tags?: Tag[];
+ type: "page" | "section";
+ onClick?: () => void;
}) {
- return (
-
-
- {props.title && (
-
-
- {props.type === "page" && (
-
- )}
-
- {props.title}
-
-
- {props.tags && (
-
- {props.tags.map((tag) => {
- return (
-
- {tag}
-
- );
- })}
-
- )}
-
- )}
- {props.content &&
{props.content}
}
-
-
- );
+ return (
+
+
+ {props.title && (
+
+
+ {props.type === "page" && (
+
+ )}
+
+ {props.title}
+
+
+ {props.tags && (
+
+ {props.tags.map((tag) => {
+ return (
+
+ {tag}
+
+ );
+ })}
+
+ )}
+
+ )}
+ {props.content &&
{props.content}
}
+
+
+ );
}