Update category management and RSS endpoint handling
This commit is contained in:
@ -18,7 +18,6 @@ interface CategoryGroup {
|
||||
|
||||
function CategoryList() {
|
||||
const [groupedFeeds, setGroupedFeeds] = useState<CategoryGroup>({});
|
||||
const [categories, setCategories] = useState<string[]>([]);
|
||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
||||
const [filteredFeeds, setFilteredFeeds] = useState<Feed[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@ -52,10 +51,9 @@ function CategoryList() {
|
||||
}
|
||||
|
||||
const groupedData = await groupedResponse.json();
|
||||
const categoriesData = await categoriesResponse.json();
|
||||
await categoriesResponse.json();
|
||||
|
||||
setGroupedFeeds(groupedData.groupedFeeds || {});
|
||||
setCategories(categoriesData.categories || []);
|
||||
} catch (err) {
|
||||
console.error("Category fetch error:", err);
|
||||
setError(err instanceof Error ? err.message : "エラーが発生しました");
|
||||
@ -72,11 +70,6 @@ function CategoryList() {
|
||||
return groupedFeeds[category]?.length || 0;
|
||||
};
|
||||
|
||||
const getTotalEpisodesCount = (feeds: Feed[]) => {
|
||||
// This would require an additional API call to get episode counts per feed
|
||||
// For now, just return the feed count
|
||||
return feeds.length;
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <div className="loading">読み込み中...</div>;
|
||||
|
199
frontend/src/components/RSSEndpoints.tsx
Normal file
199
frontend/src/components/RSSEndpoints.tsx
Normal file
@ -0,0 +1,199 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface RSSEndpoint {
|
||||
title: string;
|
||||
url: string;
|
||||
description: string;
|
||||
feedCategory?: string;
|
||||
}
|
||||
|
||||
interface RSSEndpointsData {
|
||||
main: RSSEndpoint;
|
||||
categories: RSSEndpoint[];
|
||||
feeds: RSSEndpoint[];
|
||||
}
|
||||
|
||||
export default function RSSEndpoints() {
|
||||
const [endpoints, setEndpoints] = useState<RSSEndpointsData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copiedUrl, setCopiedUrl] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetchRSSEndpoints();
|
||||
}, []);
|
||||
|
||||
const fetchRSSEndpoints = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await fetch("/api/rss-endpoints");
|
||||
if (!response.ok) {
|
||||
throw new Error("RSS エンドポイント情報の取得に失敗しました");
|
||||
}
|
||||
const data = await response.json();
|
||||
setEndpoints(data.endpoints);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "エラーが発生しました");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const copyToClipboard = async (url: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
setCopiedUrl(url);
|
||||
setTimeout(() => setCopiedUrl(null), 2000);
|
||||
} catch (err) {
|
||||
console.error("クリップボードへのコピーに失敗しました:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const openInNewTab = (url: string) => {
|
||||
window.open(url, "_blank");
|
||||
};
|
||||
|
||||
if (loading) return <div className="loading">読み込み中...</div>;
|
||||
if (error) return <div className="error">エラー: {error}</div>;
|
||||
if (!endpoints) return <div className="error">データが見つかりません</div>;
|
||||
|
||||
return (
|
||||
<div className="rss-endpoints">
|
||||
<div className="rss-endpoints-header">
|
||||
<h1>RSS 配信エンドポイント</h1>
|
||||
<p>以下のRSSフィードURLをポッドキャストアプリに追加して音声コンテンツをお楽しみください。</p>
|
||||
</div>
|
||||
|
||||
{/* メインフィード */}
|
||||
<section className="rss-section">
|
||||
<h2>📻 メインフィード</h2>
|
||||
<div className="rss-endpoint-card main-feed">
|
||||
<div className="endpoint-header">
|
||||
<h3>{endpoints.main.title}</h3>
|
||||
<span className="endpoint-badge main">全エピソード</span>
|
||||
</div>
|
||||
<p className="endpoint-description">{endpoints.main.description}</p>
|
||||
<div className="endpoint-url">
|
||||
<code>{endpoints.main.url}</code>
|
||||
<div className="endpoint-actions">
|
||||
<button
|
||||
onClick={() => copyToClipboard(endpoints.main.url)}
|
||||
className={`copy-btn ${copiedUrl === endpoints.main.url ? "copied" : ""}`}
|
||||
title="URLをコピー"
|
||||
>
|
||||
{copiedUrl === endpoints.main.url ? "✓" : "📋"}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => openInNewTab(endpoints.main.url)}
|
||||
className="open-btn"
|
||||
title="新しいタブで開く"
|
||||
>
|
||||
🔗
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* カテゴリ別フィード */}
|
||||
{endpoints.categories.length > 0 && (
|
||||
<section className="rss-section">
|
||||
<h2>🏷️ カテゴリ別フィード</h2>
|
||||
<div className="rss-endpoints-grid">
|
||||
{endpoints.categories.map((endpoint, index) => (
|
||||
<div key={index} className="rss-endpoint-card">
|
||||
<div className="endpoint-header">
|
||||
<h3>{endpoint.title}</h3>
|
||||
<span className="endpoint-badge category">カテゴリ</span>
|
||||
</div>
|
||||
<p className="endpoint-description">{endpoint.description}</p>
|
||||
<div className="endpoint-url">
|
||||
<code>{endpoint.url}</code>
|
||||
<div className="endpoint-actions">
|
||||
<button
|
||||
onClick={() => copyToClipboard(endpoint.url)}
|
||||
className={`copy-btn ${copiedUrl === endpoint.url ? "copied" : ""}`}
|
||||
title="URLをコピー"
|
||||
>
|
||||
{copiedUrl === endpoint.url ? "✓" : "📋"}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => openInNewTab(endpoint.url)}
|
||||
className="open-btn"
|
||||
title="新しいタブで開く"
|
||||
>
|
||||
🔗
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* フィード別フィード */}
|
||||
{endpoints.feeds.length > 0 && (
|
||||
<section className="rss-section">
|
||||
<h2>📡 フィード別配信</h2>
|
||||
<div className="rss-endpoints-grid">
|
||||
{endpoints.feeds.map((endpoint, index) => (
|
||||
<div key={index} className="rss-endpoint-card">
|
||||
<div className="endpoint-header">
|
||||
<h3>{endpoint.title}</h3>
|
||||
<div className="endpoint-badges">
|
||||
<span className="endpoint-badge feed">フィード</span>
|
||||
{endpoint.feedCategory && (
|
||||
<span className="endpoint-badge category-tag">
|
||||
{endpoint.feedCategory}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<p className="endpoint-description">{endpoint.description}</p>
|
||||
<div className="endpoint-url">
|
||||
<code>{endpoint.url}</code>
|
||||
<div className="endpoint-actions">
|
||||
<button
|
||||
onClick={() => copyToClipboard(endpoint.url)}
|
||||
className={`copy-btn ${copiedUrl === endpoint.url ? "copied" : ""}`}
|
||||
title="URLをコピー"
|
||||
>
|
||||
{copiedUrl === endpoint.url ? "✓" : "📋"}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => openInNewTab(endpoint.url)}
|
||||
className="open-btn"
|
||||
title="新しいタブで開く"
|
||||
>
|
||||
🔗
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* 使用方法の説明 */}
|
||||
<section className="rss-section usage-info">
|
||||
<h2>📱 使用方法</h2>
|
||||
<div className="usage-cards">
|
||||
<div className="usage-card">
|
||||
<h3>1. ポッドキャストアプリを選択</h3>
|
||||
<p>Apple Podcasts、Google Podcasts、Spotify、Pocket Casts など、RSS フィードに対応したポッドキャストアプリを使用してください。</p>
|
||||
</div>
|
||||
<div className="usage-card">
|
||||
<h3>2. RSS フィードを追加</h3>
|
||||
<p>上記のURLをコピーして、ポッドキャストアプリの「フィードを追加」や「URLから購読」機能を使用してください。</p>
|
||||
</div>
|
||||
<div className="usage-card">
|
||||
<h3>3. エピソードを楽しむ</h3>
|
||||
<p>フィードが追加されると、新しいエピソードが自動的にアプリに配信されます。</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user