From aca5c8af73eae75fa95710e48de7435da450eb23 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 8 Sep 2021 07:25:07 -0400 Subject: [PATCH] updates --- docs/getting-started/overview.md | 2 +- scripts/make-search.js | 39 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/docs/getting-started/overview.md b/docs/getting-started/overview.md index a55aaafb..93ce93ba 100644 --- a/docs/getting-started/overview.md +++ b/docs/getting-started/overview.md @@ -2,7 +2,7 @@
-# A forward-thinking library of web components. +# A forward-thinking library of web components. - Works with all frameworks 🧩 - Works with CDNs 🚛 diff --git a/scripts/make-search.js b/scripts/make-search.js index 51ba2d98..798516c2 100644 --- a/scripts/make-search.js +++ b/scripts/make-search.js @@ -3,33 +3,32 @@ import path from 'path'; import glob from 'globby'; import lunr from 'lunr'; -function getHeadings(markdown, maxLevel = 6) { - const headings = []; - const lines = markdown.split('\n'); - - lines.map(line => { - if (line.startsWith('#')) { - const level = line.match(/^(#+)/)[0].length; - const content = line.replace(/^#+/, ''); - - if (level <= maxLevel) { - headings.push({ level, content }); - } - } - }); - - return headings; -} - console.log('Generating search index for documentation'); (async () => { - const files = await glob('./docs/**/*.md'); + function getHeadings(markdown, maxLevel = 6) { + const headings = []; + const lines = markdown.split('\n'); + lines.map(line => { + if (line.startsWith('#')) { + const level = line.match(/^(#+)/)[0].length; + const content = line.replace(/^#+/, ''); + + if (level <= maxLevel) { + headings.push({ level, content }); + } + } + }); + + return headings; + } + + const files = await glob('./docs/**/*.md'); const map = {}; const searchIndex = lunr(function () { // The search index uses these field names extensively, so shortening them can save some serious bytes. The initial - // index file went from 468 KB => 401 KB. + // index file went from 468 KB => 401 KB by using single-character names! this.ref('id'); // id this.field('t', { boost: 10 }); // title this.field('h', { boost: 5 }); // headings