diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/PostFooter/PostFooter.tsx | 25 | ||||
| -rw-r--r-- | src/components/PostMeta/PostMeta.tsx | 20 | ||||
| -rw-r--r-- | src/components/PostPreview/PostPreview.tsx | 2 | ||||
| -rw-r--r-- | src/components/Widgets/RelatedTopics/RelatedTopics.tsx | 18 | ||||
| -rw-r--r-- | src/components/Widgets/TopicsList/TopicsList.tsx | 16 |
5 files changed, 40 insertions, 41 deletions
diff --git a/src/components/PostFooter/PostFooter.tsx b/src/components/PostFooter/PostFooter.tsx index 06e86bc..ad471eb 100644 --- a/src/components/PostFooter/PostFooter.tsx +++ b/src/components/PostFooter/PostFooter.tsx @@ -1,26 +1,25 @@ import { ButtonLink } from '@components/Buttons'; import { t } from '@lingui/macro'; -import { SubjectPreview } from '@ts/types/taxonomies'; +import { TopicPreview } from '@ts/types/taxonomies'; import Image from 'next/image'; -import Link from 'next/link'; import styles from './PostFooter.module.scss'; -const PostFooter = ({ subjects }: { subjects: SubjectPreview[] }) => { - const getSubjects = () => { - return subjects.map((subject) => { +const PostFooter = ({ topics }: { topics: TopicPreview[] }) => { + const getTopics = () => { + return topics.map((topic) => { return ( - <li className={styles.item} key={subject.id}> - <ButtonLink target={`/sujet/${subject.slug}`}> - {subject.featuredImage && ( + <li className={styles.item} key={topic.id}> + <ButtonLink target={`/sujet/${topic.slug}`}> + {topic.featuredImage && ( <Image - src={subject.featuredImage.sourceUrl} - alt={subject.featuredImage.altText} + src={topic.featuredImage.sourceUrl} + alt={topic.featuredImage.altText} layout="intrinsic" width="20" height="20" /> )} - {subject.title} + {topic.title} </ButtonLink> </li> ); @@ -29,12 +28,12 @@ const PostFooter = ({ subjects }: { subjects: SubjectPreview[] }) => { return ( <footer> - {subjects.length > 0 && ( + {topics.length > 0 && ( <> <dl className={styles.meta}> <dt>{t`Read more articles about:`}</dt> <dd> - <ul className={styles.list}>{getSubjects()}</ul> + <ul className={styles.list}>{getTopics()}</ul> </dd> </dl> </> diff --git a/src/components/PostMeta/PostMeta.tsx b/src/components/PostMeta/PostMeta.tsx index 0b68d70..57c2ded 100644 --- a/src/components/PostMeta/PostMeta.tsx +++ b/src/components/PostMeta/PostMeta.tsx @@ -13,7 +13,7 @@ const PostMeta = ({ meta: ArticleMeta; mode?: PostMetaMode; }) => { - const { author, commentCount, dates, subjects, thematics, website } = meta; + const { author, commentCount, dates, topics, thematics, website } = meta; const { asPath, locale } = useRouter(); const isThematic = () => asPath.includes('/thematique/'); const isArticle = () => asPath.includes('/article/'); @@ -24,14 +24,14 @@ const PostMeta = ({ year: 'numeric', }; - const getSubjects = () => { + const getTopics = () => { return ( - subjects && - subjects.map((subject) => { + topics && + topics.map((topic) => { return ( - <dd key={subject.id} className={styles.description}> - <Link href={`/sujet/${subject.slug}`}> - <a>{subject.title}</a> + <dd key={topic.id} className={styles.description}> + <Link href={`/sujet/${topic.slug}`}> + <a>{topic.title}</a> </Link> </dd> ); @@ -102,12 +102,12 @@ const PostMeta = ({ {getThematics()} </div> )} - {isThematic() && subjects && subjects.length > 0 && ( + {isThematic() && topics && topics.length > 0 && ( <div className={styles.item}> <dt className={styles.term}> - {subjects.length > 1 ? t`Subjects` : t`Subject`} + {topics.length > 1 ? t`Topics` : t`Topic`} </dt> - {getSubjects()} + {getTopics()} </div> )} {website && ( diff --git a/src/components/PostPreview/PostPreview.tsx b/src/components/PostPreview/PostPreview.tsx index 47dbe5e..b52d675 100644 --- a/src/components/PostPreview/PostPreview.tsx +++ b/src/components/PostPreview/PostPreview.tsx @@ -23,7 +23,7 @@ const PostPreview = ({ const meta: ArticleMeta = { commentCount: post.commentCount ? post.commentCount : 0, dates: post.dates, - subjects: post.subjects, + topics: post.topics, thematics: post.thematics, }; 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 ( |
