Skip to content

Commit

Permalink
feat: extract jobs data
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 30, 2023
1 parent 867aa32 commit e9e37d0
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/app/(public)/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { initReactI18next } from 'react-i18next';
i18n.use(initReactI18next).init({
resources: {
en: {
translation: require('../../locales/en.json'),
translation: require('@/data/locales/en.json'),
},
it: {
translation: require('../../locales/it.json'),
translation: require('@/data/locales/it.json'),
},
},
lng: 'en', // Default language
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { AiFillCaretDown, AiFillCaretUp } from 'react-icons/ai';

import { useOnKeyDown } from '@/hooks/useOnKeyDown';

import languages from '@/data/languages.json';

import { BurgerIcon } from '@/components/atoms/BurgerIcon';
import LanguageSwitcher, {
LanguageDef,
Expand All @@ -20,8 +22,6 @@ import ModeToggleButton from '@/components/buttons/ModeToggleButton';
import UnstyledLink from '@/components/links/UnstyledLink';
import { MobileMenu } from '@/components/molecules/MobileMenu/MobileMenu';

import languages from '@/locales/languages.json';

export const links = [
{ href: '/projects', label: 'headerMenu.projects' },
{ href: '/cv', label: 'headerMenu.cv' },
Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/MobileMenu/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { AnimatePresence, motion } from 'framer-motion';
import * as React from 'react';
import { useTranslation } from 'react-i18next';

import languages from '@/data/languages.json';

import LanguageSwitcherMobile from '@/components/atoms/LanguageSwitcher/LanguageSwitcherMobile';
import { NavigationItem } from '@/components/atoms/NavigationItem';
import ModeToggleButton from '@/components/buttons/ModeToggleButton';
import { links } from '@/components/layout/Header';

import languages from '@/locales/languages.json';

export interface MobileMenuProps {
isOpen: boolean;
}
Expand Down
72 changes: 18 additions & 54 deletions src/components/organisms/home/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ import React from 'react';
import ReactMarkdown from 'react-markdown';
import reactStringReplace from 'react-string-replace';

import { HomePage } from '@/types/HomePage';
import jobs from '@/data/jobs.json';

export interface SummaryProps {
homePage: HomePage;
}
import { HomePage } from '@/types/HomePage';

interface LinkProps {
url: string;
href: string;
classes: string;
image: string;
alt: string;
width: number;
height: number;
}

function _buildLink(link: LinkProps) {
export interface SummaryProps {
homePage: HomePage;
}

function buildLink(link: LinkProps) {
return (
<Link href={link.url} target='_blank' rel='noopener noreferrer'>
<Link href={link.href} target='_blank' rel='noopener noreferrer'>
<Image
className={link.classes}
src={link.image}
Expand All @@ -34,63 +36,25 @@ function _buildLink(link: LinkProps) {
}

const Summary = ({ homePage }: SummaryProps) => {
const resourcifyLogo = (
<Link
href='https://resourcify.com/'
target='_blank'
rel='noopener noreferrer'
>
<Image
className='ms-1 inline'
src='https://res.cloudinary.com/dwrurydlt/image/upload/v1693067033/resourcify_69f3b5b70d.webp'
alt='Resourcify'
width='106'
height='21'
/>
</Link>
);

const bjssLogo = (
<Link href='https://bjss.com/' target='_blank' rel='noopener noreferrer'>
<Image
className='mx-1 inline'
src='https://res.cloudinary.com/dwrurydlt/image/upload/v1692645367/bjss_180dc7fdd7.webp'
alt='BJSS'
width='45'
height='25'
/>
</Link>
);

const bookingLogo = (
<Link href='https://booking.com/' target='_blank' rel='noopener noreferrer'>
<Image
className='ms-1 inline'
src='https://res.cloudinary.com/dwrurydlt/image/upload/v1693067075/bookingcom_91b7aa2e36.svg'
alt='Booking.com'
width='115'
height='25'
/>
</Link>
);

const part1 = reactStringReplace(
const introduction_1 = reactStringReplace(
homePage.introduction_1,
'{Resourcify}',
() => resourcifyLogo,
() => buildLink(jobs.resourcify),
);

let part2 = reactStringReplace(
let introduction_2 = reactStringReplace(
homePage.introduction_2,
'{BJSS}',
() => bjssLogo,
() => buildLink(jobs.bjss),
);
introduction_2 = reactStringReplace(introduction_2, '{Booking}', () =>
buildLink(jobs.booking),
);
part2 = reactStringReplace(part2, '{Booking}', () => bookingLogo);

return (
<div className='text-base antialiased'>
<p className='mb-4 md:mb-1'>{part1}</p>
<p className='mb-4'>{part2}</p>
<p className='mb-4 md:mb-1'>{introduction_1}</p>
<p className='mb-4'>{introduction_2}</p>
<ReactMarkdown className='mb-4'>{homePage.introduction_3}</ReactMarkdown>
<ReactMarkdown className='mb-4'>{homePage.introduction_4}</ReactMarkdown>
<ReactMarkdown className='mb-4'>{homePage.introduction_5}</ReactMarkdown>
Expand Down
26 changes: 26 additions & 0 deletions src/data/jobs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"resourcify": {
"href": "https://resourcify.com/",
"classes": "ms-1 inline",
"image": "https://res.cloudinary.com/dwrurydlt/image/upload/v1693067033/resourcify_69f3b5b70d.webp",
"alt": "Resourcify",
"width": 106,
"height": 21
},
"bjss": {
"href": "https://bjss.com/",
"classes": "mx-1 inline",
"image": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692645367/bjss_180dc7fdd7.webp",
"alt": "BJSS",
"width": 45,
"height": 25
},
"booking": {
"href": "https://booking.com/",
"classes": "ms-1 inline",
"image": "https://res.cloudinary.com/dwrurydlt/image/upload/v1693067075/bookingcom_91b7aa2e36.svg",
"alt": "Booking.com",
"width": 115,
"height": 25
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e9e37d0

Please sign in to comment.