aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-29 18:42:58 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-29 18:42:58 +0100
commit86d70a6343b6d8ed2a1dbeadec10348de87fcf49 (patch)
tree76f0004d58adfc6057d7e749afd980d74314abcf
parentd363306235f2a48f16e488f20f73e2233ddcf281 (diff)
refactor(pages): refine CV page
* reduce the number of statements by grouping the messages * remove LinkedIn from the widget (it is obviously not a repo and my CV is already here, no need to link to an external site)
m---------src/content0
-rw-r--r--src/pages/cv.tsx124
-rw-r--r--tests/cypress/e2e/pages/cv.cy.ts31
3 files changed, 91 insertions, 64 deletions
diff --git a/src/content b/src/content
-Subproject a9aa65d7f81b6ad72ef707f40f14e955cf4fcd6
+Subproject fca1bc948fbe5ff2eca1194a1397aeb8a4f6605
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx
index edf267d..edff59f 100644
--- a/src/pages/cv.tsx
+++ b/src/pages/cv.tsx
@@ -31,65 +31,71 @@ import {
import { loadTranslation } from '../utils/helpers/server';
import { useBreadcrumb, 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({ fromLevel: 2 });
- const { file, image } = data;
const { dates, intro, seo, title } = meta;
const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
title,
url: ROUTES.CV,
});
-
- const imageWidgetTitle = intl.formatMessage({
- defaultMessage: 'Others formats',
- description: 'CVPage: cv preview widget title',
- id: 'B9OCyV',
- });
- const socialMediaTitle = intl.formatMessage({
- defaultMessage: 'Open-source projects',
- description: 'CVPage: social media widget title',
- id: '+Dre5J',
- });
- const tocTitle = intl.formatMessage({
- defaultMessage: 'Table of Contents',
- description: 'PageLayout: table of contents title',
- id: 'eys2uX',
- });
-
- const cvCaption = intl.formatMessage(
- {
- defaultMessage: '<link>Download the CV in PDF</link>',
- id: 'fN04AJ',
- description: 'CVPage: download CV in PDF text',
- },
- {
- link: (chunks: ReactNode) => (
- <Link href={file} isDownload>
- {chunks}
- </Link>
+ 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,
+ }
),
- }
- );
-
- const githubLabel = intl.formatMessage({
- defaultMessage: 'Github profile',
- description: 'CVPage: Github profile link',
- id: 'Jm0a6H',
- });
- const gitlabLabel = intl.formatMessage({
- defaultMessage: 'Gitlab profile',
- description: 'CVPage: Gitlab profile link',
- id: '++U2Hm',
- });
- const linkedinLabel = intl.formatMessage({
- defaultMessage: 'LinkedIn profile',
- description: 'CVPage: LinkedIn profile link',
- id: 'Sm2wCk',
- });
+ 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 { asPath } = useRouter();
const webpageSchema = getWebPageSchema({
@@ -100,7 +106,7 @@ const CVPage: NextPageWithLayout = () => {
updateDate: dates.update,
});
const cvSchema = getSinglePageSchema({
- cover: image.src,
+ cover: data.image.src,
dates,
description: intro,
id: 'cv',
@@ -126,7 +132,7 @@ const CVPage: NextPageWithLayout = () => {
<meta property="og:type" content="article" />
<meta property="og:title" content={title} />
<meta property="og:description" content={intro} />
- <meta property="og:image" content={image.src} />
+ <meta property="og:image" content={data.image.src} />
<meta property="og:image:alt" content={title} />
</Head>
<Script
@@ -151,7 +157,7 @@ const CVPage: NextPageWithLayout = () => {
/>
<PageSidebar>
<TocWidget
- heading={<Heading level={3}>{tocTitle}</Heading>}
+ heading={<Heading level={3}>{messages.toc.title}</Heading>}
tree={tree}
/>
</PageSidebar>
@@ -160,39 +166,33 @@ const CVPage: NextPageWithLayout = () => {
</PageBody>
<PageSidebar>
<ImageWidget
- description={cvCaption}
+ description={messages.image.caption}
heading={
<Heading isFake level={3}>
- {imageWidgetTitle}
+ {messages.image.title}
</Heading>
}
- img={<NextImage {...image} />}
+ img={<NextImage {...data.image} />}
/>
<SocialMediaWidget
heading={
<Heading isFake level={3}>
- {socialMediaTitle}
+ {messages.socialMedia.title}
</Heading>
}
media={[
{
icon: 'Github',
id: 'github',
- label: githubLabel,
+ label: messages.socialMedia.github,
url: PERSONAL_LINKS.GITHUB,
},
{
icon: 'Gitlab',
id: 'gitlab',
- label: gitlabLabel,
+ label: messages.socialMedia.gitlab,
url: PERSONAL_LINKS.GITLAB,
},
- {
- icon: 'LinkedIn',
- id: 'linkedin',
- label: linkedinLabel,
- url: PERSONAL_LINKS.LINKEDIN,
- },
]}
/>
</PageSidebar>
diff --git a/tests/cypress/e2e/pages/cv.cy.ts b/tests/cypress/e2e/pages/cv.cy.ts
index 13b937f..c509640 100644
--- a/tests/cypress/e2e/pages/cv.cy.ts
+++ b/tests/cypress/e2e/pages/cv.cy.ts
@@ -1,8 +1,35 @@
-import { ROUTES } from '../../../../src/utils/constants';
+import { PERSONAL_LINKS, ROUTES } from '../../../../src/utils/constants';
describe('CV Page', () => {
- it('successfully loads', () => {
+ beforeEach(() => {
cy.visit(ROUTES.CV);
+ });
+
+ it('renders the page contents', () => {
cy.findByRole('heading', { level: 1 }).contains('CV');
+ cy.findByRole('heading', { level: 2, name: 'Compétences' }).should('exist');
+ cy.findByRole('heading', {
+ level: 2,
+ name: 'Expériences professionnelles',
+ }).should('exist');
+ cy.findByRole('heading', { level: 2, name: 'Formations' }).should('exist');
+ });
+
+ it('renders an image with a link to download the CV', () => {
+ cy.findByRole('img', { name: /CV/ }).should('exist');
+ cy.findByRole('link', { name: /Télécharger/i }).should('exist');
+ });
+
+ it('renders some links to my repositories', () => {
+ cy.findByRole('link', { name: /Github/i }).should(
+ 'have.attr',
+ 'href',
+ PERSONAL_LINKS.GITHUB
+ );
+ cy.findByRole('link', { name: /Gitlab/i }).should(
+ 'have.attr',
+ 'href',
+ PERSONAL_LINKS.GITLAB
+ );
});
});