diff options
Diffstat (limited to 'src/components/Widgets')
| -rw-r--r-- | src/components/Widgets/RelatedTopics/RelatedTopics.tsx | 18 | ||||
| -rw-r--r-- | src/components/Widgets/TopicsList/TopicsList.tsx | 16 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/components/Widgets/RelatedTopics/RelatedTopics.tsx b/src/components/Widgets/RelatedTopics/RelatedTopics.tsx index aab8cc1..178e5bc 100644 --- a/src/components/Widgets/RelatedTopics/RelatedTopics.tsx +++ b/src/components/Widgets/RelatedTopics/RelatedTopics.tsx @@ -1,18 +1,18 @@ import { ExpandableWidget, List } from '@components/WidgetParts'; import { t } from '@lingui/macro'; -import { SubjectPreview } from '@ts/types/taxonomies'; +import { TopicPreview } from '@ts/types/taxonomies'; import Link from 'next/link'; -const RelatedTopics = ({ topics }: { topics: SubjectPreview[] }) => { - const sortedSubjects = [...topics].sort((a, b) => +const RelatedTopics = ({ topics }: { topics: TopicPreview[] }) => { + const sortedTopics = [...topics].sort((a, b) => a.title.localeCompare(b.title) ); - const subjects = sortedSubjects.map((subject) => { + const topicsList = sortedTopics.map((topic) => { return ( - <li key={subject.databaseId}> - <Link href={`/sujet/${subject.slug}`}> - <a>{subject.title}</a> + <li key={topic.databaseId}> + <Link href={`/sujet/${topic.slug}`}> + <a>{topic.title}</a> </Link> </li> ); @@ -20,10 +20,10 @@ const RelatedTopics = ({ topics }: { topics: SubjectPreview[] }) => { return ( <ExpandableWidget - title={topics.length > 1 ? t`Related topics` : t`Related topic`} + title={topicsList.length > 1 ? t`Related topics` : t`Related topic`} withBorders={true} > - <List items={subjects} /> + <List items={topicsList} /> </ExpandableWidget> ); }; diff --git a/src/components/Widgets/TopicsList/TopicsList.tsx b/src/components/Widgets/TopicsList/TopicsList.tsx index c7843b7..5b0c44e 100644 --- a/src/components/Widgets/TopicsList/TopicsList.tsx +++ b/src/components/Widgets/TopicsList/TopicsList.tsx @@ -1,7 +1,7 @@ import Spinner from '@components/Spinner/Spinner'; import { ExpandableWidget, List } from '@components/WidgetParts'; import { t } from '@lingui/macro'; -import { getAllSubjects } from '@services/graphql/queries'; +import { getAllTopics } from '@services/graphql/queries'; import { TitleLevel } from '@ts/types/app'; import Link from 'next/link'; import { useRouter } from 'next/router'; @@ -20,7 +20,7 @@ const TopicsList = ({ ? router.asPath.replace('/sujet/', '') : ''; - const { data, error } = useSWR('/api/subjects', getAllSubjects); + const { data, error } = useSWR('/api/topics', getAllTopics); const getList = () => { if (error) return <ul>{t`Failed to load.`}</ul>; @@ -31,11 +31,11 @@ const TopicsList = ({ </ul> ); - const subjects = data.map((subject) => { - return currentTopicSlug !== subject.slug ? ( - <li key={subject.databaseId}> - <Link href={`/sujet/${subject.slug}`}> - <a>{subject.title}</a> + const topics = data.map((topic) => { + return currentTopicSlug !== topic.slug ? ( + <li key={topic.databaseId}> + <Link href={`/sujet/${topic.slug}`}> + <a>{topic.title}</a> </Link> </li> ) : ( @@ -43,7 +43,7 @@ const TopicsList = ({ ); }); - return <List items={subjects} />; + return <List items={topics} />; }; return ( |
