|
16 | 16 | if (typeof Scorer === "undefined") { |
17 | 17 | var Scorer = { |
18 | 18 | // Implement the following function to further tweak the score for each result |
19 | | - // The function takes a result array [docname, title, anchor, descr, score, filename] |
| 19 | + // The function takes a result array [docname, title, anchor, anchorIsDocumentTitle, descr, score] |
20 | 20 | // and returns the new score. |
21 | 21 | /* |
22 | 22 | score: result => { |
23 | | - const [docname, title, anchor, descr, score, filename] = result |
| 23 | + const [docname, title, anchor, anchorIsDocumentTitle, descr, score] = result |
24 | 24 | return score |
25 | 25 | }, |
26 | 26 | */ |
@@ -64,7 +64,7 @@ const _displayItem = (item, searchTerms, highlightTerms) => { |
64 | 64 | const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; |
65 | 65 | const contentRoot = document.documentElement.dataset.content_root; |
66 | 66 |
|
67 | | - const [docName, title, _isDocumentTitle, anchor, descr, score] = item; |
| 67 | + const [docName, title, anchor, _anchorIsDocumentTitle, descr, score] = item; |
68 | 68 |
|
69 | 69 | let listItem = document.createElement("li"); |
70 | 70 | let requestUrl; |
@@ -309,13 +309,13 @@ const Search = { |
309 | 309 | if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { |
310 | 310 | for (const [file, id] of foundTitles) { |
311 | 311 | let score = Math.round(100 * queryLower.length / title.length) |
312 | | - let isDocumentTitle = titles[file] === title |
| 312 | + let anchorIsDocumentTitle = titles[file] === title |
313 | 313 | let anchor = id ? `#${id}` : "" |
314 | 314 | results.push([ |
315 | 315 | docNames[file], |
316 | | - isDocumentTitle ? title : `${titles[file]} > ${title}`, |
317 | | - isDocumentTitle, |
| 316 | + anchorIsDocumentTitle ? title : `${titles[file]} > ${title}`, |
318 | 317 | anchor, |
| 318 | + anchorIsDocumentTitle, |
319 | 319 | null, |
320 | 320 | score, |
321 | 321 | filenames[file], |
@@ -376,8 +376,10 @@ const Search = { |
376 | 376 | // de-duplicate on file, title, description, and (if not the title section) anchor |
377 | 377 | // we omit the anchor for the title section as otherwise we'll get two entries for the |
378 | 378 | // entire document |
379 | | - let [docname, title, isDocumentTitle, anchor, descr, score, filename] = result; |
380 | | - let resultStr = [docname, title, isDocumentTitle ? '' : anchor, descr].map(v => String(v)).join(','); |
| 379 | + let [docname, title, anchor, anchorIsDocumentTitle, descr, score, filename] = result; |
| 380 | + // Consider a link to the anchor representing the document title equivalent to a link |
| 381 | + // to the document without an anchor |
| 382 | + let resultStr = [docname, title, anchorIsDocumentTitle ? '' : anchor, descr].map(v => String(v)).join(','); |
381 | 383 | if (!seen.has(resultStr)) { |
382 | 384 | acc.push(result); |
383 | 385 | seen.add(resultStr); |
@@ -451,8 +453,8 @@ const Search = { |
451 | 453 | results.push([ |
452 | 454 | docNames[match[0]], |
453 | 455 | fullname, |
454 | | - false, |
455 | 456 | "#" + anchor, |
| 457 | + false, |
456 | 458 | descr, |
457 | 459 | score, |
458 | 460 | filenames[match[0]], |
@@ -563,8 +565,8 @@ const Search = { |
563 | 565 | results.push([ |
564 | 566 | docNames[file], |
565 | 567 | titles[file], |
566 | | - false, |
567 | 568 | "", |
| 569 | + false, |
568 | 570 | null, |
569 | 571 | score, |
570 | 572 | filenames[file], |
|
0 commit comments