Skip to content

Commit

Permalink
Rename global search constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cdedreuille committed Jul 11, 2024
1 parent 6b3f9cc commit d11d3ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
6 changes: 3 additions & 3 deletions apps/frontpage/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { notFound, redirect } from 'next/navigation';
import Link from 'next/link';
import type { TreeProps } from '@repo/utils';
import { GLOBAL_SEARCH_META_KEYS, GLOBAL_SEARCH_IMPORTANCE } from '@repo/ui';
import { globalSearchMetaKeys, globalSearchImportance } from '@repo/ui';
import { latestVersion, cn } from '@repo/utils';
import { getVersion } from '../../../lib/get-version';
import { getPageData } from '../../../lib/get-page';
Expand All @@ -27,8 +27,8 @@ export async function generateMetadata({
description:
"Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and documentation. It's open source and free.",
other: {
[GLOBAL_SEARCH_META_KEYS.VERSION]: activeVersion.id,
[GLOBAL_SEARCH_META_KEYS.IMPORTANCE]: GLOBAL_SEARCH_IMPORTANCE.DOCS,
[globalSearchMetaKeys.version]: activeVersion.id,
[globalSearchMetaKeys.importance]: globalSearchImportance.docs,
},
};
}
Expand Down
10 changes: 5 additions & 5 deletions apps/frontpage/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Metadata } from 'next';
import { Nunito_Sans as nunitoSans } from 'next/font/google';
import {
GLOBAL_SEARCH_META_KEYS,
GLOBAL_SEARCH_AGNOSTIC,
GLOBAL_SEARCH_IMPORTANCE,
globalSearchMetaKeys,
globalSearchAgnostic,
globalSearchImportance,
} from '@repo/ui';
import { cn } from '@repo/utils';
import { Providers } from './providers';
Expand Down Expand Up @@ -32,8 +32,8 @@ export const metadata: Metadata = {
},
other: {
// Set the docsearch index facets defaults
[GLOBAL_SEARCH_META_KEYS.VERSION]: GLOBAL_SEARCH_AGNOSTIC,
[GLOBAL_SEARCH_META_KEYS.IMPORTANCE]: GLOBAL_SEARCH_IMPORTANCE.AGNOSTIC,
[globalSearchMetaKeys.version]: globalSearchAgnostic,
[globalSearchMetaKeys.importance]: globalSearchImportance.agnostic,
},
verification: {
google: 'HCBwa2qa52ztaOfGjt3FQGzTUCM3kT8IOjTSY6diI88',
Expand Down
14 changes: 7 additions & 7 deletions packages/ui/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const GLOBAL_SEARCH_META_KEYS = {
VERSION: 'docsearch:version',
IMPORTANCE: 'docsearch:importance',
export const globalSearchMetaKeys = {
version: 'docsearch:version',
importance: 'docsearch:importance',
};

export const GLOBAL_SEARCH_AGNOSTIC = 'agnostic';
export const globalSearchAgnostic = 'agnostic';

export const GLOBAL_SEARCH_IMPORTANCE = {
DOCS: 0,
AGNOSTIC: 1,
export const globalSearchImportance = {
docs: 0,
agnostic: 1,
};
7 changes: 2 additions & 5 deletions packages/ui/src/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DocSearch } from '@docsearch/react';
import { cn, getVersion } from '@repo/utils';
import { useSelectedLayoutSegment } from 'next/navigation';
import type { HeaderProps } from '../header';
import { GLOBAL_SEARCH_AGNOSTIC } from '../constants';
import { globalSearchAgnostic } from '../constants';

interface SearchProps extends Pick<HeaderProps, 'algoliaApiKey' | 'variant'> {
className?: string;
Expand Down Expand Up @@ -113,10 +113,7 @@ export const Search: FC<SearchProps> = ({
* between the containing values
*/
[`tags:docs`, `tags:recipes`],
[
`version:${activeVersion.id}`,
`version:${GLOBAL_SEARCH_AGNOSTIC}`,
],
[`version:${activeVersion.id}`, `version:${globalSearchAgnostic}`],
],
}}
translations={{
Expand Down

0 comments on commit d11d3ad

Please sign in to comment.