Skip to content

Commit

Permalink
fix: Search result is displayed broken #184
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitskvmdam committed Jan 21, 2023
1 parent c1ea0a0 commit b43ddea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 9 additions & 6 deletions static/scripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,19 @@ function onClickSearchItem(event) {

function buildSearchResult(result) {
let output = '';

const removeHTMLTagsRegExp = /(<([^>]+)>)/ig;

for (const res of result) {
const { title, description } = res.item;
const { title = '', description = '' } = res.item;

const link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
const _title = title.replace(removeHTMLTagsRegExp, "");
const _description = description.replace(removeHTMLTagsRegExp, "");

output += `
<a onclick="onClickSearchItem(event)" href="${link}" class="search-result-item">
<div class="search-result-item-title">${title}</div>
<div class="search-result-item-p">${description || 'No description available.'}</div>
<a onclick="onClickSearchItem(event)" href="${_link}" class="search-result-item">
<div class="search-result-item-title">${_title}</div>
<div class="search-result-item-p">${_description || 'No description available.'}</div>
</a>
`;
}
Expand Down
10 changes: 5 additions & 5 deletions static/scripts/search.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b43ddea

Please sign in to comment.