diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pages/sujet/[slug].tsx | 57 | ||||
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 47 | ||||
| -rw-r--r-- | src/ts/types/taxonomies.ts | 4 | ||||
| -rw-r--r-- | src/utils/helpers/format.ts | 15 | 
4 files changed, 77 insertions, 46 deletions
| diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index 167bfc0..a7adf89 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -16,6 +16,7 @@ import { ArticleMeta } from '@ts/types/articles';  import ToC from '@components/ToC/ToC';  import { RelatedThematics, TopicsList } from '@components/Widget';  import { useRef } from 'react'; +import Head from 'next/head';  const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {    const relatedThematics = useRef<ThematicPreview[]>([]); @@ -49,30 +50,38 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {    };    return ( -    <article className={`${styles.article} ${styles['article--no-comments']}`}> -      <PostHeader -        cover={subject.featuredImage} -        intro={subject.intro} -        meta={meta} -        title={subject.title} -      /> -      <aside className={styles.toc}> -        <ToC /> -      </aside> -      <div className={styles.body}> -        <div dangerouslySetInnerHTML={{ __html: subject.content }}></div> -        {subject.posts.length > 0 && ( -          <section className={styles.section}> -            <h2>{t`All posts in ${subject.title}`}</h2> -            <ol className={styles.list}>{getPostsList()}</ol> -          </section> -        )} -      </div> -      <aside className={`${styles.aside} ${styles['aside--overflow']}`}> -        <RelatedThematics thematics={relatedThematics.current} /> -        <TopicsList title={t`Other topics`} /> -      </aside> -    </article> +    <> +      <Head> +        <title>{subject.seo.title}</title> +        <meta name="description" content={subject.seo.metaDesc} /> +      </Head> +      <article +        className={`${styles.article} ${styles['article--no-comments']}`} +      > +        <PostHeader +          cover={subject.featuredImage} +          intro={subject.intro} +          meta={meta} +          title={subject.title} +        /> +        <aside className={styles.toc}> +          <ToC /> +        </aside> +        <div className={styles.body}> +          <div dangerouslySetInnerHTML={{ __html: subject.content }}></div> +          {subject.posts.length > 0 && ( +            <section className={styles.section}> +              <h2>{t`All posts in ${subject.title}`}</h2> +              <ol className={styles.list}>{getPostsList()}</ol> +            </section> +          )} +        </div> +        <aside className={`${styles.aside} ${styles['aside--overflow']}`}> +          <RelatedThematics thematics={relatedThematics.current} /> +          <TopicsList title={t`Other topics`} /> +        </aside> +      </article> +    </>    );  }; diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 4921806..f23ad5b 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -16,6 +16,7 @@ import ToC from '@components/ToC/ToC';  import { RelatedTopics, ThematicsList } from '@components/Widget';  import { useRef } from 'react';  import { ArticleMeta } from '@ts/types/articles'; +import Head from 'next/head';  const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => {    const relatedSubjects = useRef<SubjectPreview[]>([]); @@ -48,25 +49,33 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => {    };    return ( -    <article className={`${styles.article} ${styles['article--no-comments']}`}> -      <PostHeader intro={thematic.intro} meta={meta} title={thematic.title} /> -      <aside className={styles.toc}> -        <ToC /> -      </aside> -      <div className={styles.body}> -        <div dangerouslySetInnerHTML={{ __html: thematic.content }}></div> -        {thematic.posts.length > 0 && ( -          <section className={styles.section}> -            <h2>{t`All posts in ${thematic.title}`}</h2> -            <ol className={styles.list}>{getPostsList()}</ol> -          </section> -        )} -      </div> -      <aside className={`${styles.aside} ${styles['aside--overflow']}`}> -        <RelatedTopics topics={relatedSubjects.current} /> -        <ThematicsList title={t`Other thematics`} /> -      </aside> -    </article> +    <> +      <Head> +        <title>{thematic.seo.title}</title> +        <meta name="description" content={thematic.seo.metaDesc} /> +      </Head> +      <article +        className={`${styles.article} ${styles['article--no-comments']}`} +      > +        <PostHeader intro={thematic.intro} meta={meta} title={thematic.title} /> +        <aside className={styles.toc}> +          <ToC /> +        </aside> +        <div className={styles.body}> +          <div dangerouslySetInnerHTML={{ __html: thematic.content }}></div> +          {thematic.posts.length > 0 && ( +            <section className={styles.section}> +              <h2>{t`All posts in ${thematic.title}`}</h2> +              <ol className={styles.list}>{getPostsList()}</ol> +            </section> +          )} +        </div> +        <aside className={`${styles.aside} ${styles['aside--overflow']}`}> +          <RelatedTopics topics={relatedSubjects.current} /> +          <ThematicsList title={t`Other thematics`} /> +        </aside> +      </article> +    </>    );  }; diff --git a/src/ts/types/taxonomies.ts b/src/ts/types/taxonomies.ts index 0b2d696..a0aaa5e 100644 --- a/src/ts/types/taxonomies.ts +++ b/src/ts/types/taxonomies.ts @@ -1,6 +1,7 @@  import { ContentParts, Dates, Slug } from './app';  import { ArticlePreview, RawArticlePreview } from './articles';  import { Cover, RawCover } from './cover'; +import { SEO } from './seo';  //==============================================================================  // Taxonomies base @@ -13,10 +14,11 @@ type Taxonomy = {    id: string;    intro: string;    posts: ArticlePreview[]; +  seo: SEO;    title: string;  }; -type TaxonomyPreview = Pick<Taxonomy, 'databaseId' | 'id' | 'title'> & { +type TaxonomyPreview = Pick<Taxonomy, 'databaseId' | 'id' | 'seo' | 'title'> & {    slug: string;  }; diff --git a/src/utils/helpers/format.ts b/src/utils/helpers/format.ts index e628369..b79daef 100644 --- a/src/utils/helpers/format.ts +++ b/src/utils/helpers/format.ts @@ -84,6 +84,7 @@ export const getFormattedSubject = (rawSubject: RawSubject): Subject => {      featuredImage,      id,      modified, +    seo,      title,    } = rawSubject; @@ -103,6 +104,7 @@ export const getFormattedSubject = (rawSubject: RawSubject): Subject => {      intro: contentParts.beforeMore,      officialWebsite: acfSubjects.officialWebsite,      posts, +    seo,      title,    }; @@ -115,8 +117,16 @@ export const getFormattedSubject = (rawSubject: RawSubject): Subject => {   * @returns A formatted thematic.   */  export const getFormattedThematic = (rawThematic: RawThematic): Thematic => { -  const { acfThematics, contentParts, databaseId, date, id, modified, title } = -    rawThematic; +  const { +    acfThematics, +    contentParts, +    databaseId, +    date, +    id, +    modified, +    seo, +    title, +  } = rawThematic;    const dates = {      publication: date, @@ -132,6 +142,7 @@ export const getFormattedThematic = (rawThematic: RawThematic): Thematic => {      id,      intro: contentParts.beforeMore,      posts, +    seo,      title,    }; | 
