summaryrefslogtreecommitdiffstats
path: root/src/pages
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-23 00:20:08 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-23 00:24:39 +0100
commit368fbbf83b913b90cef9dfbe4288e148d589d033 (patch)
treee86d6006dec67ffe485cbab5141609759ce7d501 /src/pages
parent6d514259dd5e60af83b42f938ea9f6b017b7377f (diff)
refactor: rename all subject occurrences into topic
I change the name in graphql endpoint, so I decided to repercute this change here.
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/article/[slug].tsx4
-rw-r--r--src/pages/projet/[slug].tsx2
-rw-r--r--src/pages/sujet/[slug].tsx84
-rw-r--r--src/pages/thematique/[slug].tsx22
4 files changed, 53 insertions, 59 deletions
diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx
index b9c0021..f43c9ee 100644
--- a/src/pages/article/[slug].tsx
+++ b/src/pages/article/[slug].tsx
@@ -30,7 +30,7 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => {
featuredImage,
intro,
seo,
- subjects,
+ topics,
thematics,
title,
} = post;
@@ -137,7 +137,7 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => {
className={styles.body}
dangerouslySetInnerHTML={{ __html: content }}
></div>
- <PostFooter subjects={subjects} />
+ <PostFooter topics={topics} />
<Sidebar position="right">
<Sharing title={title} excerpt={intro} />
</Sidebar>
diff --git a/src/pages/projet/[slug].tsx b/src/pages/projet/[slug].tsx
index e497481..82e2ea3 100644
--- a/src/pages/projet/[slug].tsx
+++ b/src/pages/projet/[slug].tsx
@@ -57,7 +57,7 @@ const Project: NextPageWithLayout<ProjectProps> = ({
const updateDate = new Date(dates.update);
const articleSchema: Article = {
- '@id': `${config.url}/subject`,
+ '@id': `${config.url}/project`,
'@type': 'Article',
name: title,
description: intro,
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx
index 6c72cf9..ba65a27 100644
--- a/src/pages/sujet/[slug].tsx
+++ b/src/pages/sujet/[slug].tsx
@@ -2,26 +2,23 @@ import { getLayout } from '@components/Layouts/Layout';
import PostPreview from '@components/PostPreview/PostPreview';
import { t } from '@lingui/macro';
import { NextPageWithLayout } from '@ts/types/app';
-import { SubjectProps, ThematicPreview } from '@ts/types/taxonomies';
+import { TopicProps, ThematicPreview } from '@ts/types/taxonomies';
import { loadTranslation } from '@utils/helpers/i18n';
import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
import { ParsedUrlQuery } from 'querystring';
import styles from '@styles/pages/Page.module.scss';
-import {
- getAllSubjectsSlug,
- getSubjectBySlug,
-} from '@services/graphql/queries';
+import { getAllTopicsSlug, getTopicBySlug } from '@services/graphql/queries';
import PostHeader from '@components/PostHeader/PostHeader';
import { ArticleMeta } from '@ts/types/articles';
import { RelatedThematics, ToC, TopicsList } from '@components/Widgets';
import { useRef } from 'react';
import Head from 'next/head';
import Sidebar from '@components/Sidebar/Sidebar';
-import { Article as Article, Blog, Graph, WebPage } from 'schema-dts';
+import { Article as Article, Graph, WebPage } from 'schema-dts';
import { config } from '@config/website';
import { useRouter } from 'next/router';
-const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
+const Topic: NextPageWithLayout<TopicProps> = ({ topic }) => {
const relatedThematics = useRef<ThematicPreview[]>([]);
const router = useRouter();
@@ -37,7 +34,7 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
};
const getPostsList = () => {
- return [...subject.posts].reverse().map((post) => {
+ return [...topic.posts].reverse().map((post) => {
updateRelatedThematics(post.thematics);
return (
@@ -49,17 +46,17 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
};
const meta: ArticleMeta = {
- dates: subject.dates,
- website: subject.officialWebsite,
+ dates: topic.dates,
+ website: topic.officialWebsite,
};
- const subjectUrl = `${config.url}${router.asPath}`;
+ const topicUrl = `${config.url}${router.asPath}`;
const webpageSchema: WebPage = {
- '@id': `${subjectUrl}`,
+ '@id': `${topicUrl}`,
'@type': 'WebPage',
breadcrumb: { '@id': `${config.url}/#breadcrumb` },
- name: subject.seo.title,
- description: subject.seo.metaDesc,
+ name: topic.seo.title,
+ description: topic.seo.metaDesc,
inLanguage: config.locales.defaultLocale,
reviewedBy: { '@id': `${config.url}/#branding` },
url: `${config.url}`,
@@ -68,14 +65,14 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
},
};
- const publicationDate = new Date(subject.dates.publication);
- const updateDate = new Date(subject.dates.update);
+ const publicationDate = new Date(topic.dates.publication);
+ const updateDate = new Date(topic.dates.update);
const articleSchema: Article = {
- '@id': `${config.url}/subject`,
+ '@id': `${config.url}/topic`,
'@type': 'Article',
- name: subject.title,
- description: subject.intro,
+ name: topic.title,
+ description: topic.intro,
author: { '@id': `${config.url}/#branding` },
copyrightYear: publicationDate.getFullYear(),
creator: { '@id': `${config.url}/#branding` },
@@ -83,12 +80,12 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
dateModified: updateDate.toISOString(),
datePublished: publicationDate.toISOString(),
editor: { '@id': `${config.url}/#branding` },
- thumbnailUrl: subject.featuredImage?.sourceUrl,
- image: subject.featuredImage?.sourceUrl,
+ thumbnailUrl: topic.featuredImage?.sourceUrl,
+ image: topic.featuredImage?.sourceUrl,
inLanguage: config.locales.defaultLocale,
isPartOf: { '@id': `${config.url}/blog` },
license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr',
- mainEntityOfPage: { '@id': `${subjectUrl}` },
+ mainEntityOfPage: { '@id': `${topicUrl}` },
subjectOf: { '@id': `${config.url}/blog` },
};
@@ -100,40 +97,37 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
return (
<>
<Head>
- <title>{subject.seo.title}</title>
- <meta name="description" content={subject.seo.metaDesc} />
- <meta property="og:url" content={`${subjectUrl}`} />
+ <title>{topic.seo.title}</title>
+ <meta name="description" content={topic.seo.metaDesc} />
+ <meta property="og:url" content={`${topicUrl}`} />
<meta property="og:type" content="article" />
- <meta property="og:title" content={subject.title} />
- <meta property="og:description" content={subject.intro} />
- <meta property="og:image" content={subject.featuredImage?.sourceUrl} />
- <meta
- property="og:image:alt"
- content={subject.featuredImage?.altText}
- />
+ <meta property="og:title" content={topic.title} />
+ <meta property="og:description" content={topic.intro} />
+ <meta property="og:image" content={topic.featuredImage?.sourceUrl} />
+ <meta property="og:image:alt" content={topic.featuredImage?.altText} />
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }}
></script>
</Head>
<article
- id="subject"
+ id="topic"
className={`${styles.article} ${styles['article--no-comments']}`}
>
<PostHeader
- cover={subject.featuredImage}
- intro={subject.intro}
+ cover={topic.featuredImage}
+ intro={topic.intro}
meta={meta}
- title={subject.title}
+ title={topic.title}
/>
<Sidebar position="left">
<ToC />
</Sidebar>
<div className={styles.body}>
- <div dangerouslySetInnerHTML={{ __html: subject.content }}></div>
- {subject.posts.length > 0 && (
+ <div dangerouslySetInnerHTML={{ __html: topic.content }}></div>
+ {topic.posts.length > 0 && (
<section className={styles.section}>
- <h2>{t`All posts in ${subject.title}`}</h2>
+ <h2>{t`All posts in ${topic.title}`}</h2>
<ol className={styles.list}>{getPostsList()}</ol>
</section>
)}
@@ -147,7 +141,7 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
);
};
-Subject.getLayout = getLayout;
+Topic.getLayout = getLayout;
interface PostParams extends ParsedUrlQuery {
slug: string;
@@ -161,20 +155,20 @@ export const getStaticProps: GetStaticProps = async (
process.env.NODE_ENV === 'production'
);
const { slug } = context.params as PostParams;
- const subject = await getSubjectBySlug(slug);
- const breadcrumbTitle = subject.title;
+ const topic = await getTopicBySlug(slug);
+ const breadcrumbTitle = topic.title;
return {
props: {
breadcrumbTitle,
- subject,
+ topic,
translation,
},
};
};
export const getStaticPaths: GetStaticPaths = async () => {
- const allSlugs = await getAllSubjectsSlug();
+ const allSlugs = await getAllTopicsSlug();
return {
paths: allSlugs.map((post) => `/sujet/${post.slug}`),
@@ -182,4 +176,4 @@ export const getStaticPaths: GetStaticPaths = async () => {
};
};
-export default Subject;
+export default Topic;
diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx
index 93b1221..c76831d 100644
--- a/src/pages/thematique/[slug].tsx
+++ b/src/pages/thematique/[slug].tsx
@@ -2,7 +2,7 @@ import { getLayout } from '@components/Layouts/Layout';
import PostPreview from '@components/PostPreview/PostPreview';
import { t } from '@lingui/macro';
import { NextPageWithLayout } from '@ts/types/app';
-import { SubjectPreview, ThematicProps } from '@ts/types/taxonomies';
+import { TopicPreview, ThematicProps } from '@ts/types/taxonomies';
import { loadTranslation } from '@utils/helpers/i18n';
import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
import { ParsedUrlQuery } from 'querystring';
@@ -17,28 +17,28 @@ import { useRef } from 'react';
import { ArticleMeta } from '@ts/types/articles';
import Head from 'next/head';
import Sidebar from '@components/Sidebar/Sidebar';
-import { Article, Blog, Graph, WebPage } from 'schema-dts';
+import { Article, Graph, WebPage } from 'schema-dts';
import { config } from '@config/website';
import { useRouter } from 'next/router';
const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => {
- const relatedSubjects = useRef<SubjectPreview[]>([]);
+ const relatedTopics = useRef<TopicPreview[]>([]);
const router = useRouter();
- const updateRelatedSubjects = (newSubjects: SubjectPreview[]) => {
- newSubjects.forEach((subject) => {
- const subjectIndex = relatedSubjects.current.findIndex(
- (relatedSubject) => relatedSubject.id === subject.id
+ const updateRelatedTopics = (newTopics: TopicPreview[]) => {
+ newTopics.forEach((topic) => {
+ const topicIndex = relatedTopics.current.findIndex(
+ (relatedTopic) => relatedTopic.id === topic.id
);
- const hasSubject = subjectIndex === -1 ? false : true;
+ const hasTopic = topicIndex === -1 ? false : true;
- if (!hasSubject) relatedSubjects.current.push(subject);
+ if (!hasTopic) relatedTopics.current.push(topic);
});
};
const getPostsList = () => {
return [...thematic.posts].reverse().map((post) => {
- updateRelatedSubjects(post.subjects);
+ updateRelatedTopics(post.topics);
return (
<li key={post.id} className={styles.item}>
@@ -123,7 +123,7 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => {
)}
</div>
<Sidebar position="right">
- <RelatedTopics topics={relatedSubjects.current} />
+ <RelatedTopics topics={relatedTopics.current} />
<ThematicsList title={t`Other thematics`} />
</Sidebar>
</article>