diff --git a/index.html b/index.html index e70752c..ac33af0 100644 --- a/index.html +++ b/index.html @@ -950,7 +950,38 @@ async function loadFeed() { document.getElementById('briefList').innerHTML = ''; try { - const res = await fetch(FEED_API, { cache: 'no-store' }); + const apiKey = localStorage.getItem('posimai-brief-apikey'); + let res; + if (apiKey) { + let customFeeds = []; + try { + const mediaRes = await fetch(API_BASE + '/feed/media', { + headers: { 'Authorization': `Bearer ${apiKey}` } + }); + if (mediaRes.ok) { + const medias = await mediaRes.json(); + customFeeds = medias + .filter(m => m.is_active !== false) + .map(m => ({ + id: `db-${m.id}`, + name: m.name, + url: m.feed_url, + siteUrl: m.site_url, + category: m.category || 'tech', + icon: 'rss', + dbId: m.id, + })); + } + } catch (_) { /* カスタムソース取得失敗 → デフォルトのみで続行 */ } + res = await fetch(FEED_API, { + method: 'POST', + cache: 'no-store', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ customFeeds }), + }); + } else { + res = await fetch(FEED_API, { cache: 'no-store' }); + } if (!res.ok) throw new Error(`Feed ${res.status}`); const data = await res.json(); const list = (data.articles || []).slice(0, 8);