Skip to content

Commit 85b8c2e

Browse files
authored
Merge pull request #1556 from oasisprotocol/lw/exclude-see-also
Exclude "See also" sections from search
2 parents 647c7ea + 60a187e commit 85b8c2e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

docusaurus.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const config: Config = {
100100
{
101101
indexBlog: false,
102102
docsRouteBasePath: '/',
103+
ignoreCssSelectors: '.exclude-from-search',
103104
} satisfies import('@easyops-cn/docusaurus-search-local').PluginOptions,
104105
],
105106
],

src/theme/DocCard/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ function useCategoryItemsPlural() {
3838
function CardContainer({
3939
href,
4040
children,
41+
className,
4142
}: {
4243
href: string;
4344
children: ReactNode;
45+
className?: string;
4446
}): ReactNode {
4547
return (
4648
<Link
4749
href={href}
48-
className={clsx('card padding--lg', styles.cardContainer)}>
50+
className={clsx('card padding--lg', styles.cardContainer, className)}>
4951
{children}
5052
</Link>
5153
);
@@ -57,15 +59,17 @@ function CardLayout({
5759
title,
5860
description,
5961
customProps,
62+
className,
6063
}: {
6164
href: string;
6265
icon: ReactNode;
6366
title: string;
6467
description?: string;
6568
customProps: {[key: string]: unknown} | undefined;
69+
className?: string;
6670
}): ReactNode {
6771
return (
68-
<CardContainer href={href}>
72+
<CardContainer href={href} className={className}>
6973
<Heading
7074
as="h3"
7175
className={clsx('text--truncate', styles.cardTitle)}
@@ -92,7 +96,7 @@ function CardLayout({
9296
);
9397
}
9498

95-
function CardCategory({item}: {item: PropSidebarItemCategory}): ReactNode {
99+
function CardCategory({item, className}: {item: PropSidebarItemCategory, className?: string}): ReactNode {
96100
const href = findFirstSidebarItemLink(item);
97101
const categoryItemsPlural = useCategoryItemsPlural();
98102

@@ -109,11 +113,12 @@ function CardCategory({item}: {item: PropSidebarItemCategory}): ReactNode {
109113
// description={item.description ?? categoryItemsPlural(item.items.length)}
110114
description={item.description}
111115
customProps={item.customProps}
116+
className={className}
112117
/>
113118
);
114119
}
115120

116-
function CardLink({item}: {item: PropSidebarItemLink}): ReactNode {
121+
function CardLink({item, className}: {item: PropSidebarItemLink, className?: string}): ReactNode {
117122
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
118123
const doc = useDocById(item.docId ?? undefined);
119124
return (
@@ -123,16 +128,17 @@ function CardLink({item}: {item: PropSidebarItemLink}): ReactNode {
123128
title={item.label}
124129
description={item.description ?? doc?.description}
125130
customProps={item.customProps}
131+
className={className}
126132
/>
127133
);
128134
}
129135

130136
export default function DocCard({item}: Props): ReactNode {
131137
switch (item.type) {
132138
case 'link':
133-
return <CardLink item={item} />;
139+
return <CardLink item={item} className="exclude-from-search" />;
134140
case 'category':
135-
return <CardCategory item={item} />;
141+
return <CardCategory item={item} className="exclude-from-search" />;
136142
default:
137143
throw new Error(`unknown item type ${JSON.stringify(item)}`);
138144
}

0 commit comments

Comments
 (0)