Skip to content

Commit eea6083

Browse files
committed
improved docs
1 parent 21cbeab commit eea6083

3 files changed

Lines changed: 65 additions & 262 deletions

File tree

docs/_/js/search-ui.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,14 @@
133133
document.head.appendChild(link);
134134
}
135135

136+
function highlightPageTitle (title, terms) {
137+
const positions = getTermPosition(title, terms);
138+
return buildHighlightedText(title, positions, snippetLength)
139+
}
140+
136141
function highlightSectionTitle (sectionTitle, terms) {
137142
if (sectionTitle) {
138-
const text = sectionTitle.title ?? sectionTitle.text;
143+
const text = sectionTitle.text;
139144
const positions = getTermPosition(text, terms);
140145
return buildHighlightedText(text, positions, snippetLength)
141146
}
@@ -151,7 +156,8 @@
151156
return []
152157
}
153158

154-
function highlightText (text, terms) {
159+
function highlightText (doc, terms) {
160+
const text = doc.text;
155161
const positions = getTermPosition(text, terms);
156162
return buildHighlightedText(text, positions, snippetLength)
157163
}
@@ -177,12 +183,9 @@
177183
}
178184
}
179185
return {
180-
pageTitleNodes: highlightText(doc.title, terms.title || []),
186+
pageTitleNodes: highlightPageTitle(doc.title, terms.title || []),
181187
sectionTitleNodes: highlightSectionTitle(sectionTitle, terms.title || []),
182-
pageContentNodes: highlightText(
183-
sectionTitle?.title && sectionTitle.text ? sectionTitle.text : doc.text,
184-
terms.text || []
185-
),
188+
pageContentNodes: highlightText(doc, terms.text || []),
186189
pageKeywordNodes: highlightKeyword(doc, terms.keyword || []),
187190
}
188191
}
@@ -196,12 +199,12 @@
196199
let sectionTitle;
197200
if (ids.length > 1) {
198201
const titleId = ids[1];
199-
sectionTitle = doc.titles.find(function (item) {
202+
sectionTitle = doc.titles.filter(function (item) {
200203
return String(item.id) === titleId
201-
});
204+
})[0];
202205
}
203206
const metadata = item.matchData.metadata;
204-
const highlightingResult = highlightHit(metadata, sectionTitle || doc, doc);
207+
const highlightingResult = highlightHit(metadata, sectionTitle, doc);
205208
const componentVersion = store.componentVersions[`${doc.component}/${doc.version}`];
206209
if (componentVersion !== undefined && currentComponent !== componentVersion) {
207210
const searchResultComponentHeader = document.createElement('div');

docs/search-index.js

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)