From 2376f75f1d85cb33359ee6cab91b50658d688bc8 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 11 Jul 2022 09:13:57 -0400 Subject: [PATCH] remove code blocks from search results --- scripts/make-search.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/make-search.js b/scripts/make-search.js index 4dd472b9..2f71e2a2 100644 --- a/scripts/make-search.js +++ b/scripts/make-search.js @@ -90,7 +90,11 @@ console.log('Generating search index for documentation'); .join(' '); const members = getMembers(content); - this.add({ id: index, t: title, h: headings, m: members, c: content }); + // Remove markdown code fields from search results. This seems to make search results a bit more accurate and + // reduces search.json from ~679 KB to ~455 KB. + const prunedContent = content.replace(/```(.*?)```/gs, ''); + + this.add({ id: index, t: title, h: headings, m: members, c: prunedContent }); map[index] = { title, url }; });