import type { GetStaticProps } from 'next';
import Head from 'next/head';
import NextImage from 'next/image';
import React, { type ReactNode } from 'react';
import { useIntl } from 'react-intl';
import {
  getLayout,
  Heading,
  ImageWidget,
  Link,
  SocialMediaWidget,
  Page,
  PageHeader,
  PageSidebar,
  TocWidget,
  PageBody,
} from '../components';
import { mdxComponents } from '../components/mdx';
import CVContent, { data, meta } from '../content/pages/cv.mdx';
import type { NextPageWithLayout } from '../types';
import { CONFIG } from '../utils/config';
import { PERSONAL_LINKS, ROUTES } from '../utils/constants';
import { getAboutPageGraph, getSchemaFrom } from '../utils/helpers';
import { loadTranslation } from '../utils/helpers/server';
import { useBreadcrumbs, useHeadingsTree } from '../utils/hooks';

const DownloadLink = (chunks: ReactNode) => (
  <Link href={data.file} isDownload>
    {chunks}
  </Link>
);

/**
 * CV page.
 */
const CVPage: NextPageWithLayout = () => {
  const intl = useIntl();
  const { ref, tree } = useHeadingsTree<HTMLDivElement>({ fromLevel: 2 });
  const { dates, intro, seo, title } = meta;
  const { items: breadcrumbItems, schema: breadcrumbSchema } =
    useBreadcrumbs(title);
  const messages = {
    image: {
      caption: intl.formatMessage(
        {
          defaultMessage: '<link>Download the CV in PDF</link>',
          id: 'fN04AJ',
          description: 'CVPage: download CV in PDF text',
        },
        {
          link: DownloadLink,
        }
      ),
      title: intl.formatMessage({
        defaultMessage: 'Others formats',
        description: 'CVPage: cv preview widget title',
        id: 'B9OCyV',
      }),
    },
    socialMedia: {
      github: intl.formatMessage({
        defaultMessage: 'Github profile',
        description: 'CVPage: Github profile link',
        id: 'Jm0a6H',
      }),
      gitlab: intl.formatMessage({
        defaultMessage: 'Gitlab profile',
        description: 'CVPage: Gitlab profile link',
        id: '++U2Hm',
      }),
      linkedin: intl.formatMessage({
        defaultMessage: 'LinkedIn profile',
        description: 'CVPage: LinkedIn profile link',
        id: 'Sm2wCk',
      }),
      title: intl.formatMessage({
        defaultMessage: 'Open-source projects',
        description: 'CVPage: social media widget title',
        id: '+Dre5J',
      }),
    },
    toc: {
      title: intl.formatMessage({
        defaultMessage: 'Table of Contents',
        description: 'PageLayout: table of contents title',
        id: 'eys2uX',
      }),
    },
  };

  const jsonLd = getSchemaFrom([
    getAboutPageGraph({
      breadcrumb: breadcrumbSchema,
      copyrightYear: new Date(dates.publication).getFullYear(),
      cover: data.image.src,
      dates,
      description: intro,
      slug: ROUTES.CV,
      title,
    }),
  ]);

  const page = {
    title: `${seo.title} - ${CONFIG.name}`,
    url: `${CONFIG.url}${ROUTES.CV}`,
  };

  return (
    <Page breadcrumbs={breadcrumbItems} isBodyLastChild>
      <Head>
        <title>{page.title}</title>
        {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */}
        <meta name="description" content={seo.description} />
        <meta property="og:url" content={page.url} />
        {/*eslint-disable-next-line react/jsx-no-literals -- Content allowed */}
        <meta property="og:type" content="article" />
        <meta property="og:title" content={title} />
        <meta property="og:description" content={intro} />
        <meta property="og:image" content={data.image.src} />
        <meta property="og:image:alt" content={title} />
        <script
          // eslint-disable-next-line react/no-danger
          dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
          type="application/ld+json"
        />
      </Head>
      <PageHeader
        heading={title}
        intro={intro}
        meta={{
          publicationDate: dates.publication,
          updateDate: dates.update,
        }}
      />
      <PageSidebar>
        <TocWidget
          heading={<Heading level={3}>{messages.toc.title}</Heading>}
          tree={tree}
        />
      </PageSidebar>
      <PageBody ref={ref}>
        <CVContent components={mdxComponents} />
      </PageBody>
      <PageSidebar>
        <ImageWidget
          description={messages.image.caption}
          heading={
            <Heading isFake level={3}>
              {messages.image.title}
            </Heading>
          }
          img={<NextImage {...data.image} />}
        />
        <SocialMediaWidget
          heading={
            <Heading isFake level={3}>
              {messages.socialMedia.title}
            </Heading>
          }
          media={[
            {
              icon: 'Github',
              id: 'github',
              label: messages.socialMedia.github,
              url: PERSONAL_LINKS.GITHUB,
            },
            {
              icon: 'Gitlab',
              id: 'gitlab',
              label: messages.socialMedia.gitlab,
              url: PERSONAL_LINKS.GITLAB,
            },
          ]}
        />
      </PageSidebar>
    </Page>
  );
};

CVPage.getLayout = (page) => getLayout(page);

export const getStaticProps: GetStaticProps = async ({ locale }) => {
  const translation = await loadTranslation(locale);

  return {
    props: {
      translation,
    },
  };
};

export default CVPage;
='#n70'>70</a>
<a id='n71' href='#n71'>71</a>
<a id='n72' href='#n72'>72</a>
<a id='n73' href='#n73'>73</a>
<a id='n74' href='#n74'>74</a>
<a id='n75' href='#n75'>75</a>
<a id='n76' href='#n76'>76</a>
<a id='n77' href='#n77'>77</a>
<a id='n78' href='#n78'>78</a>
<a id='n79' href='#n79'>79</a>
<a id='n80' href='#n80'>80</a>
<a id='n81' href='#n81'>81</a>
<a id='n82' href='#n82'>82</a>
<a id='n83' href='#n83'>83</a>
<a id='n84' href='#n84'>84</a>
<a id='n85' href='#n85'>85</a>
<a id='n86' href='#n86'>86</a>
<a id='n87' href='#n87'>87</a>
<a id='n88' href='#n88'>88</a>
<a id='n89' href='#n89'>89</a>
<a id='n90' href='#n90'>90</a>
<a id='n91' href='#n91'>91</a>
<a id='n92' href='#n92'>92</a>
<a id='n93' href='#n93'>93</a>
<a id='n94' href='#n94'>94</a>
<a id='n95' href='#n95'>95</a>
<a id='n96' href='#n96'>96</a>
<a id='n97' href='#n97'>97</a>
<a id='n98' href='#n98'>98</a>
<a id='n99' href='#n99'>99</a>
<a id='n100' href='#n100'>100</a>
<a id='n101' href='#n101'>101</a>
<a id='n102' href='#n102'>102</a>
<a id='n103' href='#n103'>103</a>
<a id='n104' href='#n104'>104</a>
<a id='n105' href='#n105'>105</a>
<a id='n106' href='#n106'>106</a>
<a id='n107' href='#n107'>107</a>
<a id='n108' href='#n108'>108</a>
<a id='n109' href='#n109'>109</a>
<a id='n110' href='#n110'>110</a>
<a id='n111' href='#n111'>111</a>
<a id='n112' href='#n112'>112</a>
<a id='n113' href='#n113'>113</a>
<a id='n114' href='#n114'>114</a>
<a id='n115' href='#n115'>115</a>
<a id='n116' href='#n116'>116</a>
<a id='n117' href='#n117'>117</a>
<a id='n118' href='#n118'>118</a>
<a id='n119' href='#n119'>119</a>
<a id='n120' href='#n120'>120</a>
<a id='n121' href='#n121'>121</a>
</pre></td>
<td class='lines'><pre><code><style>pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span>import { getLayout } from &#39;@components/Layouts/Layout&#39;;
import { seo } from &#39;@config/seo&#39;;
import { NextPageWithLayout } from &#39;@ts/types/app&#39;;
import { loadTranslation } from &#39;@utils/helpers/i18n&#39;;
import { GetStaticProps, GetStaticPropsContext } from &#39;next&#39;;
import Head from &#39;next/head&#39;;
import CVContent, { intro, meta, pdf, image } from &#39;@content/pages/cv.mdx&#39;;
import PostHeader from &#39;@components/PostHeader/PostHeader&#39;;
import { ArticleMeta } from &#39;@ts/types/articles&#39;;
import styles from &#39;@styles/pages/Page.module.scss&#39;;
import { CVPreview, SocialMedia, ToC } from &#39;@components/Widgets&#39;;
import { t } from &#39;@lingui/macro&#39;;
import Sidebar from &#39;@components/Sidebar/Sidebar&#39;;
import { AboutPage, Graph, WebPage } from &#39;schema-dts&#39;;
import { config } from &#39;@config/website&#39;;
import { useRouter } from &#39;next/router&#39;;

const CV: NextPageWithLayout = () =&gt; {
  const router = useRouter();
  const dates = {
    publication: meta.publishedOn,
    update: meta.updatedOn,
  };

  const pageMeta: ArticleMeta = {
    dates,
  };

  const webpageSchema: WebPage = {
    &#39;@id&#39;: `${config.url}${router.asPath}`,
    &#39;@type&#39;: &#39;WebPage&#39;,
    breadcrumb: { &#39;@id&#39;: `${config.url}/#breadcrumb` },
    name: seo.cv.title,
    description: seo.cv.description,
    reviewedBy: { &#39;@id&#39;: `${config.url}/#branding` },
    url: `${config.url}${router.asPath}`,
    isPartOf: {
      &#39;@id&#39;: `${config.url}`,
    },
  };

  const publicationDate = new Date(dates.publication);
  const updateDate = new Date(dates.update);

  const cvSchema: AboutPage = {
    &#39;@id&#39;: `${config.url}/#cv`,
    &#39;@type&#39;: &#39;AboutPage&#39;,
    name: `${config.name} CV`,
    description: intro,
    author: { &#39;@id&#39;: `${config.url}/#branding` },
    creator: { &#39;@id&#39;: `${config.url}/#branding` },
    dateCreated: publicationDate.toISOString(),
    dateModified: updateDate.toISOString(),
    datePublished: publicationDate.toISOString(),
    editor: { &#39;@id&#39;: `${config.url}/#branding` },
    image,
    inLanguage: config.locales.defaultLocale,
    license: &#39;https://creativecommons.org/licenses/by-sa/4.0/deed.fr&#39;,
    thumbnailUrl: image,
    mainEntityOfPage: { &#39;@id&#39;: `${config.url}${router.asPath}` },
  };

  const schemaJsonLd: Graph = {
    &#39;@context&#39;: &#39;https://schema.org&#39;,
    &#39;@graph&#39;: [webpageSchema, cvSchema],
  };

  return (
    &lt;&gt;
      &lt;Head&gt;
        &lt;title&gt;{seo.cv.title}&lt;/title&gt;
        &lt;meta name=&quot;description&quot; content={seo.cv.description} /&gt;
        &lt;script
          type=&quot;application/ld+json&quot;
          dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }}
        &gt;&lt;/script&gt;
      &lt;/Head&gt;
      &lt;article
        id=&quot;cv&quot;
        className={`${styles.article} ${styles[&#39;article--no-comments&#39;]}`}
      &gt;
        &lt;PostHeader intro={intro} meta={pageMeta} title={meta.title} /&gt;
        &lt;Sidebar position=&quot;left&quot;&gt;
          &lt;ToC /&gt;
        &lt;/Sidebar&gt;
        &lt;div className={styles.body}&gt;
          &lt;CVContent /&gt;
        &lt;/div&gt;
        &lt;Sidebar position=&quot;right&quot;&gt;
          &lt;CVPreview title={t`Other formats`} imgSrc={image} pdf={pdf} /&gt;
          &lt;SocialMedia
            title={t`Open-source projects`}
            github={true}
            gitlab={true}
          /&gt;
        &lt;/Sidebar&gt;
      &lt;/article&gt;
    &lt;/&gt;
  );
};

CV.getLayout = getLayout;

export const getStaticProps: GetStaticProps = async (
  context: GetStaticPropsContext
) =&gt; {
  const translation = await loadTranslation(
    context.locale!,
    process.env.NODE_ENV === &#39;production&#39;
  );
  const breadcrumbTitle = meta.title;

  return {
    props: {
      breadcrumbTitle,
      translation,
    },
  };
};

export default CV;
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.39.1</a>) at 2025-10-27 08:08:06 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
