Skip to content

Commit

Permalink
hook up search disabled config
Browse files Browse the repository at this point in the history
  • Loading branch information
chdeskur committed Feb 7, 2025
1 parent c282dca commit 2563a6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/fern-docs/edge-config/src/getEdgeFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EDGE_FLAGS = [
"toc-default-enabled" as const,
"snippet-template-enabled" as const,
"http-snippets-enabled" as const,
"search-disabled" as const,
"inline-feedback-enabled" as const,
"dark-code-enabled" as const,
"disable-proxy" as const,
Expand Down Expand Up @@ -75,6 +76,10 @@ export async function getEdgeFlags(domain: string): Promise<EdgeFlags> {
domain,
config["snippet-template-enabled"]
);
const isSearchDisabled = checkDomainMatchesCustomers(
domain,
config["search-disabled"]
);
const isHttpSnippetsEnabled = checkDomainMatchesCustomers(
domain,
config["http-snippets-enabled"]
Expand Down Expand Up @@ -181,6 +186,7 @@ export async function getEdgeFlags(domain: string): Promise<EdgeFlags> {
isTocDefaultEnabled,
isSnippetTemplatesEnabled:
isSnippetTemplatesEnabled || isDevelopment(domain),
isSearchDisabled,
isHttpSnippetsEnabled,
isInlineFeedbackEnabled,
isDarkCodeEnabled,
Expand Down Expand Up @@ -216,6 +222,7 @@ export async function getEdgeFlags(domain: string): Promise<EdgeFlags> {
isSeoDisabled: !isCustomDomain(domain),
isTocDefaultEnabled: false,
isSnippetTemplatesEnabled: isDevelopment(domain),
isSearchDisabled: false,
isHttpSnippetsEnabled: false,
isInlineFeedbackEnabled: isFern(domain),
isDarkCodeEnabled: false,
Expand Down
4 changes: 3 additions & 1 deletion packages/fern-docs/ui/src/services/useSearchService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */
import type { SearchConfig } from "@fern-docs/search-utils";
import { useEdgeFlags } from "../atoms";
import { useIsLocalPreview } from "../contexts/local-preview";
import { useApiRouteSWR } from "../hooks/useApiRouteSWR";

Expand All @@ -24,8 +25,9 @@ export type SearchService = SearchService.Available | SearchService.Unavailable;

export function useSearchConfig(): SearchConfig {
const isLocalPreview = useIsLocalPreview();
const { isSearchDisabled } = useEdgeFlags();

if (isLocalPreview) {
if (isLocalPreview || isSearchDisabled) {
return { isAvailable: false };
}

Expand Down
2 changes: 2 additions & 0 deletions packages/fern-docs/utils/src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface EdgeFlags {
isSeoDisabled: boolean;
isTocDefaultEnabled: boolean;
isSnippetTemplatesEnabled: boolean;
isSearchDisabled: boolean;
isHttpSnippetsEnabled: boolean;
isInlineFeedbackEnabled: boolean;
isDarkCodeEnabled: boolean;
Expand Down Expand Up @@ -40,6 +41,7 @@ export const DEFAULT_EDGE_FLAGS: EdgeFlags = {
isSeoDisabled: false,
isTocDefaultEnabled: false,
isSnippetTemplatesEnabled: false,
isSearchDisabled: false,
isHttpSnippetsEnabled: false,
isInlineFeedbackEnabled: false,
isDarkCodeEnabled: false,
Expand Down

0 comments on commit 2563a6a

Please sign in to comment.