feat(news): implement news section with loading state and error handling in NoLoginView
All checks were successful
Deploy to production / deploy (push) Successful in 3m8s

This commit is contained in:
Torsten Schulz (local)
2026-09-03 14:18:14 +02:00
parent c4977ec826
commit d9a46dcb34
9 changed files with 168 additions and 9 deletions

View File

@@ -104,20 +104,21 @@ async function getCachedNews({ language = 'de', category = 'top', minArticles =
* @param {number} options.counter - Index des Artikels (0 = erster, 1 = zweiter, …)
* @param {string} [options.language]
* @param {string} [options.category]
* @param {number} [options.count] - Anzahl aufeinanderfolgender Artikel
* @returns {Promise<{ results: Array, nextPage: string|null }>}
*/
async function getNews({ counter = 0, language = 'de', category = 'top' }) {
async function getNews({ counter = 0, count = 1, language = 'de', category = 'top' }) {
const neededIndex = Math.max(0, counter);
const requestedCount = Math.min(6, Math.max(1, Number.parseInt(count, 10) || 1));
// Mindestens so viele Artikel laden wie benötigt
const articles = await getCachedNews({
language,
category,
minArticles: neededIndex + 1
minArticles: neededIndex + requestedCount
});
const single = articles[neededIndex] ? [articles[neededIndex]] : [];
return { results: single, nextPage: null };
return { results: articles.slice(neededIndex, neededIndex + requestedCount), nextPage: null };
}
export default { getNews };