pull/526/head
Cory LaViska 2021-09-08 07:25:07 -04:00
rodzic 2d4a699790
commit aca5c8af73
2 zmienionych plików z 20 dodań i 21 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
<div class="splash-start">
<img class="splash-logo" src="/assets/images/wordmark.svg" alt="Shoelace">
# A forward-thinking library of web components.
# <span hidden>Shoelace:</span> A forward-thinking library of web components.
- Works with all frameworks 🧩
- Works with CDNs 🚛

Wyświetl plik

@ -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