diff --git a/app/src/pages/TagPage.jsx b/app/src/pages/TagPage.jsx new file mode 100644 index 0000000..ef76993 --- /dev/null +++ b/app/src/pages/TagPage.jsx @@ -0,0 +1,28 @@ +import { useState, useEffect } from 'react'; +import { EmptyState } from '../../teknav-ui.jsx'; +import { ArticleRow } from '../../teknav-articles.jsx'; +import { contentApi } from '../../src/lib/content-api.js'; + +export function TagPage({ tag }) { + const decoded = decodeURIComponent(tag); + const [articles, setArticles] = useState(() => contentApi.fallbackArticles().filter((item) => item.tags?.includes(decoded))); + useEffect(() => { + let cancelled = false; + setArticles(contentApi.fallbackArticles().filter((item) => item.tags?.includes(decoded))); + contentApi.listArticles({ tag: decoded, limit: 100 }) + .then((res) => { if (!cancelled) setArticles(res.items ?? []); }) + .catch(() => {}); + return () => { cancelled = true; }; + }, [decoded]); + return ( +
+
+

برچسب {decoded}

+

همه مقاله‌هایی که با این برچسب منتشر شده‌اند.

+ {articles.length === 0 ? : articles.map((article, index) => ( + + ))} +
+
+ ); +}