mirror of
https://github.com/aljazceru/awesome-nostr.git
synced 2025-02-23 15:18:58 +00:00
added icons
This commit is contained in:
parent
1512364426
commit
b121ec076b
48
script.js
48
script.js
@ -309,6 +309,16 @@ function createResourceCard(resource) {
|
|||||||
card.setAttribute('itemscope', '');
|
card.setAttribute('itemscope', '');
|
||||||
card.setAttribute('itemtype', 'https://schema.org/SoftwareApplication');
|
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 = `
|
card.innerHTML = `
|
||||||
<div class="resource-header">
|
<div class="resource-header">
|
||||||
<h3 class="resource-title">
|
<h3 class="resource-title">
|
||||||
@ -316,6 +326,7 @@ function createResourceCard(resource) {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
itemprop="name">
|
itemprop="name">
|
||||||
|
${faviconUrl ? `<img src="${faviconUrl}" alt="" class="resource-favicon" />` : ''}
|
||||||
${resource.name}
|
${resource.name}
|
||||||
<i class="fas fa-external-link-alt" aria-hidden="true"></i>
|
<i class="fas fa-external-link-alt" aria-hidden="true"></i>
|
||||||
</a>
|
</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;
|
|
||||||
}
|
|
16
styles.css
16
styles.css
@ -545,3 +545,19 @@ button:focus {
|
|||||||
.content-header {
|
.content-header {
|
||||||
display: none;
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user