Skip to content

Commit

Permalink
Add option to config that removes the See All Results link in the sea…
Browse files Browse the repository at this point in the history
…rch results.
  • Loading branch information
WayneFerrao committed Jan 23, 2025
1 parent f64b972 commit e6cd33c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
searchContextByPaths,
hideSearchBarWithNoSearchContext,
useAllContextsWithNoSearchContext,
removeSeeAllResults,
} from "../../utils/proxiedGenerated";
import LoadingRing from "../LoadingRing/LoadingRing";
import { normalizeContextByPath } from "../../utils/normalizeContextByPath";
Expand Down Expand Up @@ -280,7 +281,9 @@ export default function SearchBar({
const a = searchFooterLinkElement({ query, isEmpty });
const div = document.createElement("div");
div.className = styles.hitFooter;
div.appendChild(a);
if(removeSeeAllResults === false){
div.appendChild(a);
}
return div;
},
},
Expand Down
1 change: 1 addition & 0 deletions docusaurus-search-local/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare module "*/generated.js" {
export const explicitSearchResultPath: boolean;
export const searchBarShortcut: boolean;
export const searchBarShortcutHint: boolean;
export const removeSeeAllResults: boolean;
export const searchBarPosition: "left" | "right";
export const docsPluginIdForPreferredVersion: string;
export const indexDocs: boolean;
Expand Down
7 changes: 7 additions & 0 deletions docusaurus-search-local/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,11 @@ export interface PluginOptions {
* @default false
*/
forceIgnoreNoIndex?: boolean;

/**
* Whether to remove the see all results button.
*
* @default false
*/
removeSeeAllResults?: boolean;
}
8 changes: 8 additions & 0 deletions docusaurus-search-local/src/server/utils/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function generate(config: ProcessedPluginOptions, dir: string): string {
searchContextByPaths,
hideSearchBarWithNoSearchContext,
useAllContextsWithNoSearchContext,
removeSeeAllResults,
} = config;
const indexHash = getIndexHash(config);
const contents: string[] = [];
Expand All @@ -28,6 +29,13 @@ export function generate(config: ProcessedPluginOptions, dir: string): string {
removeDefaultStemmer
)};`
);

contents.push(
`export const removeSeeAllResults = ${JSON.stringify(
removeSeeAllResults
)};`
);

if (highlightSearchTermsOnTargetPage) {
contents.push(
`export { default as Mark } from ${JSON.stringify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const schema = Joi.object<PluginOptions>({
removeDefaultStopWordFilter: Joi.boolean().default(false),
removeDefaultStemmer: Joi.boolean().default(false),
highlightSearchTermsOnTargetPage: Joi.boolean().default(false),
removeSeeAllResults:Joi.boolean().default(false),
searchResultLimits: Joi.number().default(8),
searchResultContextMaxLength: Joi.number().default(50),
explicitSearchResultPath: Joi.boolean().default(false),
Expand Down

0 comments on commit e6cd33c

Please sign in to comment.