Update search result rendering for Organization (#19740)

This commit is contained in:
Mac Siri 2023-07-12 11:53:08 -04:00 committed by GitHub
parent 30500805ae
commit e98b00b45f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View file

@ -416,9 +416,9 @@ function updateItemSummaryHtml(item) {
}
var itemUsername = usernames[0].textContent + number
if (item.open) {
itemSummaryContent.innerHTML = "";
itemSummaryContent.textContent = "";
} else {
itemSummaryContent.innerHTML = itemUsername;
itemSummaryContent.textContent = itemUsername;
}
}

View file

@ -49,18 +49,15 @@ function buildArticleHTML(article, currentUserId = null) {
}
if (article && article.class_name === 'Organization') {
return `<article class="crayons-story">
const html = `
<article class="crayons-story">
<div class="crayons-story__body flex items-start gap-2">
<a href="${article.slug}" class="crayons-podcast-episode__cover">
<img src="${article.profile_image.url}" alt="${
article.name
}" loading="lazy" />
<img src="${article.profile_image.url}" alt="" loading="lazy" />
</a>
<div>
<h3 class="crayons-subtitle-2 lh-tight py-1">
<a href="${article.slug}" class="c-link">
${article.name}
</a>
<a href="${article.slug}" class="c-link"> ${article.name} </a>
</h3>
<p class="crayons-story__slug-segment">@${article.slug}</p>
${
@ -70,14 +67,23 @@ function buildArticleHTML(article, currentUserId = null) {
}
</div>
<div class="print-hidden" style="margin-left: auto">
<button class="crayons-btn follow-action-button whitespace-nowrap follow-user w-100" data-info='{"id": "${
article.id
}", "className": "Organization", "style": "full", "name": "${
article.name
}"}'>Follow</button>
<button class="crayons-btn follow-action-button whitespace-nowrap follow-user w-100" data-info=''>Follow</button>
</div>
</div>
</article>`;
</article>
`;
const parser = new DOMParser();
const parsedDocument = parser.parseFromString(html, 'text/html');
parsedDocument.querySelector('img').alt = article.name;
parsedDocument.querySelector('button').dataset.info = JSON.stringify({
id: article.id,
name: article.name,
className: 'Organization',
style: 'full',
});
return parsedDocument.body.innerHTML;
}
if (article) {