Skip to content

Commit c37c9da

Browse files
authored
Add more fields to search on
Adding tags, status, and deciders and searchable fields. Also, renamed verbatim to body so that in the search bar the user can easy search the body of the ADR. These searches are now available powered by the luna package. * body: Text from the body * deciders: Tony * tags: database * status: draft
1 parent 8c96148 commit c37c9da

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

packages/web/src/lib/search/Search.ts

+17-9
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,33 @@ export class Search {
6767
adrs.map((adr) => [
6868
adr.slug,
6969
{
70-
title: adr.title || "Untitled",
71-
verbatim: adr.body.enhancedMdx // TODO: remove tags (https://github.com/thomvaill/log4brains/issues/5)
70+
title: adr.title || "Untitled",
71+
body: adr.body.enhancedMdx, // TODO: remove tags (https://github.com/thomvaill/log4brains/issues/5)
72+
status: adr.status || 'draft',
73+
tags: (adr.tags || []).join(" "),
74+
deciders: adr.lastEditAuthor + " " + (adr.deciders || []).join(" ")
7275
}
7376
])
7477
);
7578

7679
const index = lunr((builder) => {
7780
builder.ref("slug");
7881
builder.field("title", { boost: 1000 });
79-
builder.field("verbatim");
82+
builder.field("tags", {boost: 50 });
83+
builder.field("status", {boost: 50 });
84+
builder.field("body");
85+
builder.field("deciders");
8086
// eslint-disable-next-line no-param-reassign
8187
builder.metadataWhitelist = ["position"];
82-
8388
adrsForSearch.forEach((adr, slug) => {
84-
builder.add({
85-
slug,
86-
title: adr.title,
87-
verbatim: adr.verbatim
88-
});
89+
builder.add({
90+
slug,
91+
title: adr.title,
92+
body: adr.body,
93+
status: adr.status,
94+
deciders: adr.deciders,
95+
tags: adr.tags
96+
});
8997
});
9098
});
9199
return new Search(index, adrsForSearch);

0 commit comments

Comments
 (0)