summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/Widget/ThematicsList/ThematicsList.tsx16
-rw-r--r--src/pages/blog/index.tsx2
2 files changed, 13 insertions, 5 deletions
diff --git a/src/components/Widget/ThematicsList/ThematicsList.tsx b/src/components/Widget/ThematicsList/ThematicsList.tsx
index 232515d..0dc0916 100644
--- a/src/components/Widget/ThematicsList/ThematicsList.tsx
+++ b/src/components/Widget/ThematicsList/ThematicsList.tsx
@@ -1,11 +1,17 @@
import { t } from '@lingui/macro';
import { getAllThematics } from '@services/graphql/queries';
-import { ThematicPreview } from '@ts/types/taxonomies';
import Link from 'next/link';
+import { useRouter } from 'next/router';
import useSWR from 'swr';
import styles from './ThematicsList.module.scss';
-const ThematicsList = () => {
+const ThematicsList = ({ title }: { title: string }) => {
+ const router = useRouter();
+ const isThematic = () => router.asPath.includes('/thematique/');
+ const currentThematicSlug = isThematic()
+ ? router.asPath.replace('/thematique/', '')
+ : '';
+
const { data, error } = useSWR('/api/thematics', getAllThematics);
if (error) return <div>{t`Failed to load.`}</div>;
@@ -16,18 +22,20 @@ const ThematicsList = () => {
);
const thematics = sortedThematics.map((thematic) => {
- return (
+ return currentThematicSlug !== thematic.slug ? (
<li key={thematic.databaseId}>
<Link href={`/thematique/${thematic.slug}`}>
<a>{thematic.title}</a>
</Link>
</li>
+ ) : (
+ ''
);
});
return (
<div>
- <h2 className={styles.title}>{t`Thematics`}</h2>
+ <h2 className={styles.title}>{title}</h2>
<ul className={styles.list}>{thematics}</ul>
</div>
);
diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx
index 1bd6c62..0804cd2 100644
--- a/src/pages/blog/index.tsx
+++ b/src/pages/blog/index.tsx
@@ -61,7 +61,7 @@ const Blog: NextPageWithLayout<BlogPageProps> = ({ fallback }) => {
>{t`Load more?`}</Button>
)}
<Sidebar>
- <ThematicsList />
+ <ThematicsList title={t`Thematics`} />
<TopicsList />
</Sidebar>
</article>