mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
🐛 Fixed search failing for posts without excerpt
- the excerpt was `null` in some cases when post didn't have any excerpt, causing search to fail
This commit is contained in:
parent
a1fab8c7f7
commit
9fc0cd7e29
1 changed files with 3 additions and 1 deletions
|
@ -259,7 +259,7 @@ function getMatchIndexes({text, highlight}) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const matchRegex = new RegExp(`${highlightRegexText}`, 'ig');
|
const matchRegex = new RegExp(`${highlightRegexText}`, 'ig');
|
||||||
let matches = text.matchAll(matchRegex);
|
let matches = text?.matchAll(matchRegex);
|
||||||
const indexes = [];
|
const indexes = [];
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
indexes.push({
|
indexes.push({
|
||||||
|
@ -307,6 +307,8 @@ function getHighlightParts({text, highlight}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function HighlightedSection({text = '', highlight = '', isExcerpt}) {
|
function HighlightedSection({text = '', highlight = '', isExcerpt}) {
|
||||||
|
text = text || '';
|
||||||
|
highlight = highlight || '';
|
||||||
let {parts, highlightIndexes} = getHighlightParts({text, highlight});
|
let {parts, highlightIndexes} = getHighlightParts({text, highlight});
|
||||||
if (isExcerpt && highlightIndexes?.[0]) {
|
if (isExcerpt && highlightIndexes?.[0]) {
|
||||||
const startIdx = highlightIndexes?.[0]?.startIdx;
|
const startIdx = highlightIndexes?.[0]?.startIdx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue