added news images and mobile social media icons
All checks were successful
publish / publish (push) Successful in 25s
All checks were successful
publish / publish (push) Successful in 25s
This commit is contained in:
parent
aebd0828ad
commit
91ab098e98
4 changed files with 79 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
// noinspection JSUnresolvedReference
|
||||
|
||||
/* ========================
|
||||
Darkmode
|
||||
======================== */
|
||||
|
@ -61,11 +63,38 @@ fetch('https://api.rss2json.com/v1/api.json?rss_url=https://toot.kif.rocks/@ifsr
|
|||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const container = document.getElementById('feed');
|
||||
data.items.slice(0, 5).forEach(item => {
|
||||
const isInFeedSection = container.closest('.feed-section') !== null;
|
||||
const maxItems = isInFeedSection ? 4 : data.items.length;
|
||||
|
||||
data.items.slice(0, maxItems).forEach(item => {
|
||||
const cleanedContent = item.content.replace(/<span class="invisible">.*?<\/span>/g, '');
|
||||
|
||||
let imageUrl;
|
||||
|
||||
if (item.thumbnail) {
|
||||
imageUrl = item.thumbnail;
|
||||
} else if (item.enclosure && item.enclosure.link) {
|
||||
imageUrl = item.enclosure.link;
|
||||
} else {
|
||||
const imgMatch = item.content.match(/<img.*?src="(.*?)"/);
|
||||
if (imgMatch && imgMatch[1]) {
|
||||
imageUrl = imgMatch[1];
|
||||
} else {
|
||||
imageUrl = '/images/thumbnail.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
const entry = document.createElement('article');
|
||||
entry.classList.add('feed-entry');
|
||||
|
||||
const imageHtml = `
|
||||
<div class="feed-thumbnail-wrapper">
|
||||
<img src="${imageUrl}" alt="Beitragsbild" class="feed-thumbnail" />
|
||||
</div>
|
||||
`;
|
||||
|
||||
entry.innerHTML = `
|
||||
${imageHtml}
|
||||
<div class="feed-content">${cleanedContent}</div>
|
||||
<a href="${item.link}" class="btn btn-secondary" target="_blank">Zum Beitrag</a>
|
||||
`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue