added icons

This commit is contained in:
Yeghro 2025-01-25 00:33:53 -08:00
parent 1512364426
commit b121ec076b
2 changed files with 27 additions and 37 deletions

View File

@ -309,6 +309,16 @@ function createResourceCard(resource) {
card.setAttribute('itemscope', '');
card.setAttribute('itemtype', 'https://schema.org/SoftwareApplication');
// Extract domain for favicon
let faviconUrl = '';
try {
const url = new URL(resource.link);
// Using Google's favicon service as a fallback if the direct favicon isn't available
faviconUrl = `https://www.google.com/s2/favicons?domain=${url.hostname}&sz=32`;
} catch (e) {
console.warn('Invalid URL:', resource.link);
}
card.innerHTML = `
<div class="resource-header">
<h3 class="resource-title">
@ -316,6 +326,7 @@ function createResourceCard(resource) {
target="_blank"
rel="noopener"
itemprop="name">
${faviconUrl ? `<img src="${faviconUrl}" alt="" class="resource-favicon" />` : ''}
${resource.name}
<i class="fas fa-external-link-alt" aria-hidden="true"></i>
</a>
@ -606,40 +617,3 @@ function displaySection(sectionName, sections) {
}
});
}
function createResourceCard(resource) {
const card = document.createElement('div');
card.className = 'resource-card';
// Add schema.org structured data
card.setAttribute('itemscope', '');
card.setAttribute('itemtype', 'https://schema.org/SoftwareApplication');
card.innerHTML = `
<div class="resource-header">
<h3 class="resource-title">
<a href="${resource.link}"
target="_blank"
rel="noopener"
itemprop="name">
${resource.name}
<i class="fas fa-external-link-alt" aria-hidden="true"></i>
</a>
</h3>
${resource.stars ? `
<div class="resource-stars" itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
<i class="fas fa-star" aria-hidden="true"></i>
<span itemprop="ratingValue">${resource.stars}</span>
<meta itemprop="ratingCount" content="${resource.stars}">
</div>
` : ''}
</div>
${resource.description ? `
<div class="resource-description" itemprop="description">
${resource.description}
</div>
` : ''}
`;
return card;
}

View File

@ -545,3 +545,19 @@ button:focus {
.content-header {
display: none;
}
.resource-favicon {
width: 16px;
height: 16px;
margin-right: 8px;
vertical-align: middle;
display: inline-block;
}
.resource-title a {
display: flex;
align-items: center;
color: var(--primary-color);
text-decoration: none;
transition: color 0.2s ease;
}