1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

Compare commits

...

25 Commits

Author SHA1 Message Date
87fbfe4940 chore(release): 2.7.2 [skip ci] 2023-05-29 15:29:07 +00:00
271aa60247 test: update with new changes 2023-05-29 17:26:06 +02:00
ba34e314c9 fix: update name with full name and nickname 2023-05-29 17:10:14 +02:00
f41bc644b1 fix(deps): remove next-pwa dependency 2023-05-29 16:24:49 +02:00
a18cec4826 chore(release): 2.7.1 [skip ci] 2023-05-21 16:27:24 +00:00
61e589f0f4 fix: responsive on blog post with code blocks and katex 2023-05-21 18:21:46 +02:00
dc5c3cee41 chore(release): 2.7.0 [skip ci] 2023-05-21 12:49:17 +00:00
20cb0c21d5 feat(posts): add programming-challenges 2023-05-21 14:42:53 +02:00
e5232c1394 build(deps): update latest 2023-05-21 12:15:08 +02:00
fd51609713 chore(release): 2.6.1 [skip ci] 2023-05-13 17:15:54 +00:00
edf16c2562 fix(deps): update latest 2023-05-13 19:09:54 +02:00
94e0d190ae chore(release): 2.6.0 [skip ci] 2023-05-10 18:12:22 +00:00
b1cf7f8517 chore: remove unneeded Lighthouse checking 2023-05-09 23:22:33 +02:00
a1a715d3b9 feat: add Numerize as work experience 2023-05-09 23:06:10 +02:00
eede46fb41 build(deps): update latest 2023-05-09 22:56:42 +02:00
e32c53caa1 chore(release): 2.5.6 [skip ci] 2023-04-02 21:18:14 +00:00
361ea37deb chore: fix CI issues 2023-04-02 23:16:51 +02:00
d49a8a7470 fix: update dependencies to latest 2023-04-02 22:44:09 +02:00
a4996c8251 chore: remove useless runner-dependencies in Dockerfile 2023-01-11 17:42:29 +01:00
b25451e631 chore(release): 2.5.5 [skip ci] 2023-01-10 23:05:24 +00:00
042a861f58 fix: update dependencies to latest 2023-01-10 23:56:46 +01:00
d76db36dbc chore(release): 2.5.4 [skip ci] 2022-12-08 08:54:03 +00:00
99d9dcf334 fix: improve Resume 2022-12-08 09:52:39 +01:00
ece5ded1b4 chore(release): 2.5.3 [skip ci] 2022-11-29 09:33:10 +00:00
1514600998 fix: improve Resume 2022-11-29 10:29:02 +01:00
67 changed files with 10872 additions and 25004 deletions

View File

@ -3,18 +3,22 @@
"dockerComposeFile": "./docker-compose.yml",
"service": "workspace",
"workspaceFolder": "/workspace",
"settings": {
"remote.autoForwardPorts": false
"customizations": {
"vscode": {
"settings": {
"remote.autoForwardPorts": false
},
"extensions": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"bradlc.vscode-tailwindcss",
"mikestead.dotenv",
"davidanson.vscode-markdownlint",
"ms-azuretools.vscode-docker"
]
}
},
"extensions": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"bradlc.vscode-tailwindcss",
"mikestead.dotenv",
"davidanson.vscode-markdownlint",
"ms-azuretools.vscode-docker"
],
"forwardPorts": [3000],
"postAttachCommand": ["npm", "install"],
"remoteUser": "node"

View File

@ -1,12 +1,5 @@
.vscode
.git
.env
.*
!.npmrc
build
.next
coverage
node_modules
tmp
temp
.DS_Store
.lighthouseci
.vercel

View File

@ -1,2 +1,2 @@
COMPOSE_PROJECT_NAME=divlo.fr
COMPOSE_PROJECT_NAME=divlo
PORT=3000

View File

@ -4,13 +4,7 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"env": {
"node": true,
"browser": true
},
"rules": {
"prettier/prettier": "error",
"unicorn/prefer-node-protocol": "error",
"@next/next/no-img-element": "off"
"prettier/prettier": "error"
}
}

View File

@ -1,6 +1,6 @@
<!-- Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time. -->
## What changes this PR introduce?
# What changes this PR introduce?
## List any relevant issue numbers

View File

@ -16,7 +16,7 @@ jobs:
language: ['javascript']
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.2'
- name: 'Initialize CodeQL'
uses: 'github/codeql-action/init@v2'

View File

@ -10,16 +10,16 @@ jobs:
build:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3.6.0'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Install dependencies'
run: 'npm clean-install'
- name: 'Build'
run: 'npm run build'

View File

@ -10,16 +10,16 @@ jobs:
lint:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3.6.0'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Install dependencies'
run: 'npm clean-install'
- name: 'lint:commit'
run: 'npm run lint:commit -- --to "${{ github.sha }}"'
@ -30,8 +30,8 @@ jobs:
- name: 'lint:markdown'
run: 'npm run lint:markdown'
- name: 'lint:typescript'
run: 'npm run lint:typescript'
- name: 'lint:eslint'
run: 'npm run lint:eslint'
- name: 'lint:prettier'
run: 'npm run lint:prettier'
@ -40,8 +40,3 @@ jobs:
uses: 'dotenv-linter/action-dotenv-linter@v2'
with:
github_token: ${{ secrets.github_token }}
- name: 'lint:docker'
uses: 'hadolint/hadolint-action@v1.6.0'
with:
dockerfile: './Dockerfile'

View File

@ -8,26 +8,26 @@ jobs:
release:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.2'
with:
fetch-depth: 0
persist-credentials: false
- name: 'Import GPG key'
uses: 'crazy-max/ghaction-import-gpg@v4'
uses: 'crazy-max/ghaction-import-gpg@v5.3.0'
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3.6.0'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Install dependencies'
run: 'npm clean-install'
- name: 'Release'
run: 'npm run release'

View File

@ -10,33 +10,33 @@ jobs:
test-unit:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.2'
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3.6.0'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Install dependencies'
run: 'npm clean-install'
- name: 'Unit Test'
run: 'npm run test:unit'
test-lighthouse:
test-e2e:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- uses: 'actions/checkout@v3.5.0'
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3.6.0'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Install dependencies'
run: 'npm clean-install'
- name: 'Build'
run: 'npm run build'
@ -44,27 +44,5 @@ jobs:
- name: 'html-w3c-validator'
run: 'npm run test:html-w3c-validator'
- name: 'Lighthouse'
run: 'npm run test:lighthouse'
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
test-e2e:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js'
uses: 'actions/setup-node@v3.5.1'
with:
node-version: '18.x'
cache: 'npm'
- name: 'Install'
run: 'npm install'
- name: 'Build'
run: 'npm run build'
- name: 'End To End (e2e) Test'
run: 'npm run test:e2e'

View File

@ -1,30 +0,0 @@
{
"ci": {
"collect": {
"startServerCommand": "npm run start",
"startServerReadyPattern": "ready on",
"startServerReadyTimeout": 20000,
"url": [
"http://127.0.0.1:3000/",
"http://127.0.0.1:3000/blog",
"http://127.0.0.1:3000/blog/hello-world"
],
"numberOfRuns": 1
},
"assert": {
"preset": "lighthouse:recommended",
"assertions": {
"csp-xss": "warning",
"non-composited-animations": "warning",
"unused-javascript": "warning",
"image-size-responsive": "warning",
"unsized-images": "warning",
"color-contrast": "warning"
}
},
"upload": {
"target": "temporary-public-storage"
},
"server": {}
}
}

View File

@ -1,11 +1,12 @@
{
"config": {
"default": true,
"MD013": false,
"relative-links": true,
"extends": "markdownlint/style/prettier",
"MD024": false,
"MD033": false,
"MD041": false
"MD033": false
},
"globs": ["**/*.{md,mdx}"],
"ignores": ["**/node_modules"]
"ignores": ["**/node_modules"],
"customRules": ["markdownlint-rule-relative-links"]
}

View File

@ -6,5 +6,9 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
},
"eslint.options": {
"ignorePath": ".gitignore"
},
"prettier.ignorePath": ".gitignore"
}

View File

@ -60,7 +60,7 @@ representative at an online or offline event.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
contact@divlo.fr.
<contact@divlo.fr>.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the

View File

@ -2,6 +2,10 @@
Thanks a lot for your interest in contributing to **divlo.fr**! 🎉
## Code of Conduct
**divlo.fr** adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](./CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
## Types of contributions
- Reporting a bug.
@ -21,29 +25,7 @@ If you're adding new features to **divlo.fr**, please include tests.
## Commits
The commit message guidelines respect [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) and [Semantic Versioning](https://semver.org/) for releases.
### Types
Types define which kind of changes you made to the project.
| Types | Description |
| -------- | ------------------------------------------------------------------------------------------------------------ |
| feat | A new feature. |
| fix | A bug fix. |
| docs | Documentation only changes. |
| style | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). |
| refactor | A code change that neither fixes a bug nor adds a feature. |
| perf | A code change that improves performance. |
| test | Adding missing tests or correcting existing tests. |
| build | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm). |
| ci | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs). |
| chore | Other changes that don't modify src or test files. |
| revert | Reverts a previous commit. |
### Scopes
Scopes define what part of the code changed.
The commit message guidelines adheres to [Conventional Commits](https://www.conventionalcommits.org/) and [Semantic Versioning](https://semver.org/) for releases.
## Getting Started
@ -86,4 +68,4 @@ docker compose up --build
### Services started
- website : `http://127.0.0.1:3000`
- website: `http://127.0.0.1:3000`

View File

@ -1,21 +1,21 @@
FROM node:18.12.1 AS dependencies
WORKDIR /usr/src/app
FROM node:18.16.0 AS builder-dependencies
WORKDIR /usr/src/application
COPY ./package*.json ./
RUN npm install
RUN npm clean-install
FROM node:18.12.1 AS builder
WORKDIR /usr/src/app
FROM node:18.16.0 AS builder
WORKDIR /usr/src/application
COPY --from=builder-dependencies /usr/src/application/node_modules ./node_modules
COPY ./ ./
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
RUN npm run build
FROM node:18.12.1 AS runner
WORKDIR /usr/src/app
FROM gcr.io/distroless/nodejs18-debian11:latest AS runner
WORKDIR /usr/src/application
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=builder /usr/src/app/.next/standalone ./
COPY --from=builder /usr/src/app/.next/static ./.next/static
COPY --from=builder /usr/src/app/public ./public
COPY --from=builder /usr/src/app/locales ./locales
COPY --from=builder /usr/src/app/next.config.js ./next.config.js
CMD ["node", "server.js"]
COPY --from=builder /usr/src/application/.next/standalone ./
COPY --from=builder /usr/src/application/.next/static ./.next/static
COPY --from=builder /usr/src/application/public ./public
COPY --from=builder /usr/src/application/locales ./locales
COPY --from=builder /usr/src/application/next.config.js ./next.config.js
CMD ["./server.js"]

View File

@ -1,4 +1,4 @@
<h1 align="center"><a href="https://divlo.fr/">Divlo</a></h1>
<h1 align="center"><a href="https://divlo.fr/">Théo LUDWIG (Divlo)</a></h1>
<p align="center">
<strong>Developer Full Stack • Open-Source enthusiast</strong>
@ -21,25 +21,15 @@
```json
{
"name": "Divlo",
"name": "Théo LUDWIG (Divlo)",
"pronouns": "He/Him",
"birthDate": "31/03/2003",
"birthdate": "31/03/2003",
"nationality": "Alsace, France",
"interests": [
"Developer Full Stack",
"Open-Source enthusiast",
"Passionate about High-Tech"
],
"interests": ["Open-Source enthusiast", "Passionate about High-Tech"],
"skills": {
"programmingLanguages": [
"JavaScript",
"TypeScript",
"Python",
"C/C++",
"PHP"
],
"frontEnd": ["HTML", "CSS", "Tailwind CSS", "React.js (+ Next.js)"],
"backEnd": ["Laravel", "Node.js", "Fastify", "Prisma", "PostgreSQL"],
"programmingLanguages": ["JavaScript/TypeScript", "Python", "C/C++", "PHP"],
"frontEnd": ["HTML", "CSS", "Tailwind CSS", "React.js/Next.js"],
"backEnd": ["Laravel", "Node.js", "Fastify", "PostgreSQL"],
"tools": ["GNU/Linux", "Ubuntu", "Visual Studio Code", "Git", "Docker"]
}
}

View File

@ -21,7 +21,7 @@ export const Footer: React.FC<FooterProps> = (props) => {
href='/'
className='text-yellow hover:underline dark:text-yellow-dark'
>
Divlo
Théo LUDWIG (Divlo)
</Link>{' '}
| {t('common:all-rights-reserved')}
</p>

View File

@ -9,9 +9,9 @@ interface HeadProps {
export const Head: React.FC<HeadProps> = (props) => {
const {
title = 'Divlo',
image = 'https://divlo.fr/images/icons/icon-96x96.png',
description = 'Divlo - Developer Full Stack • Passionate about High-Tech',
title = 'Théo LUDWIG (Divlo)',
image = 'https://divlo.fr/images/icon-96x96.png',
description = 'Théo LUDWIG (Divlo) - Developer Full Stack • Passionate about High-Tech',
url = 'https://divlo.fr/'
} = props
@ -23,7 +23,7 @@ export const Head: React.FC<HeadProps> = (props) => {
{/* Meta Tag */}
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<meta name='description' content={description} />
<meta name='Language' content='fr, en' />
<meta name='Language' content='fr-FR, en-US' />
<meta name='theme-color' content='#ffd800' />
{/* Open Graph Metadata */}
@ -32,7 +32,7 @@ export const Head: React.FC<HeadProps> = (props) => {
<meta property='og:url' content={url} />
<meta property='og:image' content={image} />
<meta property='og:description' content={description} />
<meta property='og:locale' content='fr_FR, en_US' />
<meta property='og:locale' content='fr-FR, en-US' />
<meta property='og:site_name' content={title} />
{/* Twitter card Metadata */}
@ -46,12 +46,6 @@ export const Head: React.FC<HeadProps> = (props) => {
name='google-site-verification'
content='j9CQEbSuYydXytr6gdkTfam_xX_pU97NSpVH3Bq-6f4'
/>
{/* PWA Data */}
<link rel='manifest' href='/manifest.json' />
<meta name='apple-mobile-web-app-capable' content='yes' />
<meta name='mobile-web-app-capable' content='yes' />
<link rel='apple-touch-icon' href={image} />
</NextHead>
)
}

View File

@ -55,7 +55,7 @@ export const Language: React.FC = () => {
<ul
data-cy='languages-list'
className={classNames(
'absolute top-14 z-10 mt-3 mr-4 flex w-24 list-none flex-col items-center justify-center rounded-lg bg-white p-0 shadow-lightFlag dark:bg-black dark:shadow-darkFlag',
'absolute top-14 z-10 mr-4 mt-3 flex w-24 list-none flex-col items-center justify-center rounded-lg bg-white p-0 shadow-lightFlag dark:bg-black dark:shadow-darkFlag',
{ hidden: hiddenMenu }
)}
>

View File

@ -29,7 +29,7 @@ export const SwitchTheme: React.FC = () => {
<div
data-cy='switch-theme-dark'
className={classNames(
'absolute top-0 bottom-0 left-[8px] mt-auto mb-auto h-[10px] w-[14px] leading-[0] transition-opacity duration-[250ms] ease-in-out',
'absolute bottom-0 left-[8px] top-0 mb-auto mt-auto h-[10px] w-[14px] leading-[0] transition-opacity duration-[250ms] ease-in-out',
{
'opacity-100': theme === 'dark',
'opacity-0': theme === 'light'
@ -43,7 +43,7 @@ export const SwitchTheme: React.FC = () => {
<div
data-cy='switch-theme-light'
className={classNames(
'absolute right-[10px] top-0 bottom-0 mt-auto mb-auto h-[10px] w-[10px] leading-[0]',
'absolute bottom-0 right-[10px] top-0 mb-auto mt-auto h-[10px] w-[10px] leading-[0]',
{
'opacity-100': theme === 'light',
'opacity-0': theme === 'dark'

View File

@ -21,9 +21,10 @@ export const Header: React.FC<HeaderProps> = (props) => {
height={60}
src='/images/divlo_icon_small.png'
alt='Divlo'
priority
/>
<strong className='ml-1 hidden font-headline font-semibold text-yellow dark:text-yellow-dark xs:block'>
Divlo
Théo LUDWIG (Divlo)
</strong>
</div>
</Link>
@ -37,7 +38,7 @@ export const Header: React.FC<HeaderProps> = (props) => {
Blog
</Link>
</div>
{showLanguage && <Language />}
{showLanguage ? <Language /> : null}
<SwitchTheme />
</div>
</header>

View File

@ -10,7 +10,7 @@ export const InterestItem: React.FC<InterestItemProps> = (props) => {
const { fontAwesomeIcon, title } = props
return (
<li className='interest-item my-2 mx-2 h-8 w-8' title={title}>
<li className='interest-item mx-2 my-2 h-8 w-8' title={title}>
<FontAwesomeIcon
className='block h-full w-full text-yellow dark:text-yellow-dark'
icon={fontAwesomeIcon}

View File

@ -4,9 +4,9 @@ export const ProfileDescriptionBottom: React.FC = () => {
const { t, lang } = useTranslation()
return (
<p className='mt-8 mb-8 text-base font-normal text-gray dark:text-gray-dark'>
<p className='mb-8 mt-8 text-base font-normal text-gray dark:text-gray-dark'>
{t('home:about.description-bottom')}
{lang === 'fr' && (
{lang === 'fr' ? (
<>
<br />
<br />
@ -17,7 +17,7 @@ export const ProfileDescriptionBottom: React.FC = () => {
Curriculum vitæ
</a>
</>
)}
) : null}
</p>
)
}

View File

@ -5,11 +5,8 @@ export const ProfileInformation: React.FC = () => {
return (
<div className='mb-6 border-b-2 border-gray-600 pb-2 font-headline dark:border-gray-400'>
<h1 className='mb-2 text-4xl'>
{t('home:about.i-am')}{' '}
<strong className='font-semibold text-yellow dark:text-yellow-dark'>
Divlo
</strong>
<h1 className='mb-2 text-4xl font-semibold text-yellow dark:text-yellow-dark'>
Théo LUDWIG (Divlo)
</h1>
<h2 className='mb-3 text-base'>{t('home:about.description')}</h2>
</div>

View File

@ -12,7 +12,7 @@ export const ProfileItem: React.FC<ProfileItemProps> = (props) => {
<strong className='float-left block w-28 text-sm font-bold text-black dark:text-white'>
{title}
</strong>
<span className='ml-0 mb-4 block text-sm font-normal text-gray dark:text-gray-dark sm:mb-0 sm:ml-32'>
<span className='mb-4 ml-0 block text-sm font-normal text-gray dark:text-gray-dark sm:mb-0 sm:ml-32'>
{link != null ? (
<a
className='text-gray hover:underline dark:text-gray-dark'

View File

@ -1,7 +1,7 @@
import useTranslation from 'next-translate/useTranslation'
import { useMemo } from 'react'
import { DIVLO_BIRTHDAY, DIVLO_BIRTHDAY_DATE, getAge } from 'utils/getAge'
import { DIVLO_BIRTH_DATE, DIVLO_BIRTH_DATE_STRING, getAge } from 'utils/getAge'
import { ProfileItem } from './ProfileItem'
@ -9,15 +9,20 @@ export const ProfileList: React.FC = () => {
const { t } = useTranslation('home')
const age = useMemo(() => {
return getAge(DIVLO_BIRTHDAY)
return getAge(DIVLO_BIRTH_DATE)
}, [])
return (
<ul className='m-0 list-none p-0'>
<ProfileItem title={t('home:about.full-name')} value='Théo LUDWIG' />
<ProfileItem
title={t('home:about.pronouns')}
value={t('home:about.pronouns-value')}
/>
<ProfileItem
title={t('home:about.birth-date')}
value={`${DIVLO_BIRTHDAY_DATE} (${age} ${t('home:about.years-old')})`}
value={`${DIVLO_BIRTH_DATE_STRING} (${age} ${t(
'home:about.years-old'
)})`}
/>
<ProfileItem title={t('home:about.nationality')} value='Alsace, France' />
<ProfileItem

View File

@ -27,7 +27,6 @@ export const Skills: React.FC = () => {
<SkillComponent skill='Laravel' />
<SkillComponent skill='Node.js' />
<SkillComponent skill='Fastify' />
<SkillComponent skill='Prisma' />
<SkillComponent skill='PostgreSQL' />
</SkillsSection>

View File

@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react'
export const RevealFade: React.FC<React.PropsWithChildren<{}>> = (props) => {
export const RevealFade: React.FC<React.PropsWithChildren> = (props) => {
const { children } = props
const htmlElement = useRef<HTMLDivElement>(null)

View File

@ -4,7 +4,7 @@ export const SectionHeading: React.FC<SectionHeadingProps> = (props) => {
const { children, ...rest } = props
return (
<h2 {...rest} className='mt-1 mb-3 text-center text-4xl font-semibold'>
<h2 {...rest} className='mb-3 mt-1 text-center text-4xl font-semibold'>
{children}
</h2>
)

View File

@ -23,7 +23,9 @@ export const Section: React.FC<SectionProps> = (props) => {
<div className='w-full px-3'>
<ShadowContainer style={{ marginTop: 50 }}>
<section {...rest}>
{heading != null && <SectionHeading>{heading}</SectionHeading>}
{heading != null ? (
<SectionHeading>{heading}</SectionHeading>
) : null}
<div className='w-full px-3'>{children}</div>
</section>
</ShadowContainer>
@ -34,7 +36,7 @@ export const Section: React.FC<SectionProps> = (props) => {
if (withoutShadowContainer) {
return (
<section {...rest}>
{heading != null && <SectionHeading>{heading}</SectionHeading>}
{heading != null ? <SectionHeading>{heading}</SectionHeading> : null}
<div className='w-full px-3'>{children}</div>
</section>
)
@ -42,16 +44,18 @@ export const Section: React.FC<SectionProps> = (props) => {
return (
<section {...rest}>
{heading != null && (
<SectionHeading style={{ ...(description != null && { margin: 0 }) }}>
{heading != null ? (
<SectionHeading
style={{ ...(description != null ? { margin: 0 } : {}) }}
>
{heading}
</SectionHeading>
)}
{description != null && (
) : null}
{description != null ? (
<p style={{ marginTop: 7 }} className='text-center'>
{description}
</p>
)}
) : null}
<div className='w-full px-3'>
<ShadowContainer>
<div className='w-full px-16 py-4 leading-8'>{children}</div>

View File

@ -1,4 +1,4 @@
import { Footer } from 'components/Footer'
import { Footer } from '@/components/Footer'
describe('<Footer />', () => {
it('should render with appropriate link tag version', () => {

View File

@ -38,7 +38,7 @@ describe('Common > Header', () => {
describe('Switch Language', () => {
it('should switch language from EN (default) to FR', () => {
cy.get('h1').contains('I am Divlo')
cy.get('h1').contains('Divlo')
cy.get('[data-cy=language-flag-text]').contains('EN')
cy.get('[data-cy=languages-list]').should('not.be.visible')
cy.get('[data-cy=language-click]').click()
@ -46,7 +46,7 @@ describe('Common > Header', () => {
cy.get('[data-cy=languages-list] > li:first-child').contains('FR').click()
cy.get('[data-cy=languages-list]').should('not.be.visible')
cy.get('[data-cy=language-flag-text]').contains('FR')
cy.get('h1').contains('Je suis Divlo')
cy.get('h1').contains('Divlo')
})
it('should close the language list menu when clicking outside', () => {

View File

@ -1,11 +1,11 @@
services:
divlo.fr:
divlo:
container_name: ${COMPOSE_PROJECT_NAME}
image: 'divlo.fr'
image: 'divlo'
build:
context: './'
ports:
- '${PORT-3000}:${PORT-3000}'
environment:
PORT: ${PORT-3000}
env_file: './.env'
env_file: '.env'

View File

@ -3,10 +3,10 @@ import fs from 'node:fs'
import { build } from 'vite'
const jsonResumeThemeCustom = new URL('../', import.meta.url)
const jsonResumeThemeCustom = new URL('./', import.meta.url)
const jsonResumeThemeCustomDist = new URL('./dist', jsonResumeThemeCustom)
const publicResumeOutputURL = new URL(
'../../public/curriculum-vitae',
'../public/curriculum-vitae',
import.meta.url
)

View File

@ -1,11 +1,12 @@
<!DOCTYPE html>
<html lang="fr">
<html lang="fr-FR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%= locals.basics.name %></title>
<link rel="icon" type="image/png" href="<%= locals.basics.image %>" />
<link rel="stylesheet" href="./styles/global.css" />
<script defer type="module" src="./scripts/main.js"></script>
</head>
<body>
<div class="container-fluid">
@ -26,12 +27,15 @@
<strong><%= locals.basics.name %></strong>
</h3>
<h5 class="text-muted"><%= locals.basics.label %></h5>
<h5 class="text-muted">
<%= locals.basics.age %> (<span id="year-old"></span> ans)
</h5>
<h5 class="text-muted">
<%= locals.basics.location.address %>
</h5>
</div>
</div>
<div class="contact-details clearfix">
<div class="detail">
<span class="info"><%= locals.basics.phone %></span>
</div>
<div class="detail">
<span class="info">
<a
@ -71,40 +75,44 @@
<hr />
<section class="section-separated">
<div class="detail" id="work-experience">
<div class="detail" id="education">
<div class="icon">
<img src="./images/building-columns.svg" alt="work" />
<img src="./images/graduation-cap.svg" alt="graduation" />
</div>
<div class="info">
<h4 class="title text-uppercase">Expériences</h4>
<ul class="list-unstyled clear-margin">
<% locals.work.forEach((experience) => { %>
<li class="card card-nested clearfix">
<div class="content">
<p class="clear-margin relative">
<a href="<%= experience.website %>">
<strong><%= experience.name %></strong>
</a>
</p>
<p class="clear-margin relative">
<strong><%- experience.position %></strong>
</p>
<p class="text-muted">
<small>
<span class="space-right">
<%= date.format(new Date(experience.startDate),
'DD/MM/YYYY') %> - <%= date.format(new
Date(experience.endDate), 'DD/MM/YYYY') %>
</span>
</small>
</p>
<div class="experience-description">
<p><%- experience.summary %></p>
<h4 class="title text-uppercase">Formations</h4>
<div class="content">
<ul class="list-unstyled clear-margin">
<% locals.education.forEach((degree) => { %>
<li class="card card-nested">
<div class="content">
<p class="clear-margin relative">
<strong><%= degree.studyType %></strong>
</p>
<p class="clear-margin relative">
<strong><%= degree.score %></strong>
</p>
<p class="text-muted clear-margin">
<%= degree.institution %>
</p>
<p class="text-muted clear-margin">
<small>
<%= degree.startDate %> <%= degree.endDate !=
null ? " - " + degree.endDate : "" %>
</small>
</p>
<% if (degree.courses != null) { %>
<ul class="education-courses">
<% degree.courses.forEach((course) => { %>
<li><%= course %></li>
<% }) %>
</ul>
<% } %>
</div>
</div>
</li>
<% }) %>
</ul>
</li>
<% }) %>
</ul>
</div>
</div>
</div>
@ -137,37 +145,43 @@
<hr />
<section class="section-separated">
<div class="detail" id="education">
<div class="detail" id="work-experience">
<div class="icon">
<img src="./images/graduation-cap.svg" alt="graduation" />
<img src="./images/building-columns.svg" alt="work" />
</div>
<div class="info">
<h4 class="title text-uppercase">Éducation</h4>
<div class="content">
<ul class="list-unstyled clear-margin">
<% locals.education.forEach((degree) => { %>
<li class="card card-nested">
<div class="content">
<p class="clear-margin relative">
<strong><%= degree.studyType %></strong>
</p>
<p class="clear-margin relative">
<strong><%= degree.score %></strong>
</p>
<p class="text-muted clear-margin">
<%= degree.institution %>
</p>
<p class="text-muted clear-margin">
<small>
<%= degree.startDate %> <%= degree.endDate !=
null ? " - " + degree.endDate : "" %>
</small>
</p>
<h4 class="title text-uppercase">Expériences</h4>
<ul class="list-unstyled clear-margin">
<% locals.work.filter((experience) =>
experience.description == null).forEach((experience) => {
%>
<li class="card card-nested clearfix">
<div class="content">
<p class="clear-margin relative">
<a href="<%= experience.website %>">
<strong><%= experience.name %></strong>
</a>
</p>
<p class="clear-margin relative">
<strong><%- experience.position %></strong>
</p>
<p class="text-muted">
<small>
<span class="space-right">
<%= date.format(new Date(experience.startDate),
'DD/MM/YYYY') %> - <%= date.format(new
Date(experience.endDate), 'DD/MM/YYYY') %> (<%=
experience.duration %>)
</span>
</small>
</p>
<div class="experience-description">
<p><%- experience.summary %></p>
</div>
</li>
<% }) %>
</ul>
</div>
</div>
</li>
<% }) %>
</ul>
</div>
</div>
@ -185,6 +199,38 @@
</li>
<% }) %>
</ul>
<ul class="list-unstyled clear-margin">
<% locals.work.filter((experience) =>
experience.description != null).forEach((experience) =>
{ %>
<li class="card card-nested clearfix">
<div class="content">
<p class="clear-margin relative">
<a href="<%= experience.website %>">
<strong><%= experience.name %></strong>
</a>
</p>
<p class="clear-margin relative">
<strong><%- experience.position %></strong>
</p>
<p class="text-muted">
<small>
<span class="space-right">
<%= date.format(new
Date(experience.startDate), 'DD/MM/YYYY') %> -
<%= date.format(new Date(experience.endDate),
'DD/MM/YYYY') %> (<%= experience.duration %>)
</span>
</small>
</p>
<div class="experience-description">
<p><%- experience.summary %></p>
</div>
</div>
</li>
<% }) %>
</ul>
</div>
</div>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,13 @@
"preview": "vite preview"
},
"dependencies": {
"modern-normalize": "1.1.0"
"jsonc-parser": "3.2.0",
"modern-normalize": "2.0.0"
},
"devDependencies": {
"@types/node": "18.11.9",
"date-and-time": "2.4.1",
"vite": "3.2.4",
"@types/node": "20.2.5",
"date-and-time": "3.0.0",
"vite": "4.3.9",
"vite-plugin-html": "3.2.0"
}
}

View File

@ -0,0 +1,5 @@
import { DIVLO_BIRTH_DATE, getAge } from '../../utils/getAge.ts'
const yearOld = document.getElementById('year-old')
yearOld.textContent = getAge(DIVLO_BIRTH_DATE).toString()

View File

@ -226,5 +226,4 @@ h5 {
}
.section-separated {
display: flex;
align-items: space-evenly;
}

View File

@ -1,16 +1,19 @@
import fs from 'node:fs'
import { defineConfig } from 'vite'
import { parse as JSONCParser } from 'jsonc-parser'
import { createHtmlPlugin } from 'vite-plugin-html'
import date from 'date-and-time'
const jsonResumeURL = new URL('../resume.json', import.meta.url)
const jsonResumeURL = new URL('../resume.jsonc', import.meta.url)
const dataResumeStringJSON = await fs.promises.readFile(jsonResumeURL, {
encoding: 'utf-8'
})
const resume = JSON.parse(dataResumeStringJSON)
const resume = JSONCParser(dataResumeStringJSON)
// https://vitejs.dev/config/
/**
* Documentation: <https://vitejs.dev/config/>
*/
export default defineConfig({
build: {
assetsDir: './'

View File

@ -1,8 +1,8 @@
{
"about": {
"i-am": "I am",
"description": "Developer Full Stack • Open-Source enthusiast",
"full-name": "Full name",
"pronouns": "Pronouns",
"pronouns-value": "He/Him",
"birth-date": "Birth date",
"years-old": "years old",
"nationality": "Nationality",

View File

@ -1,8 +1,8 @@
{
"about": {
"i-am": "Je suis",
"description": "Développeur Full Stack • Enthousiaste de l'Open-Source",
"full-name": "Prénom NOM",
"pronouns": "Pronoms",
"pronouns-value": "Il/Lui",
"birth-date": "Date de naissance",
"years-old": "ans",
"nationality": "Nationalité",

View File

@ -1,8 +1,4 @@
const nextPWA = require('next-pwa')({
disable: process.env.NODE_ENV !== 'production',
dest: 'public'
})
const nextTranslate = require('next-translate')
const nextTranslate = require('next-translate-plugin')
/** @type {import("next").NextConfig} */
const nextConfig = {
@ -10,4 +6,4 @@ const nextConfig = {
output: 'standalone'
}
module.exports = nextTranslate(nextPWA(nextConfig))
module.exports = nextTranslate(nextConfig)

32401
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "divlo",
"version": "2.5.2",
"version": "2.7.2",
"private": true,
"repository": {
"type": "git",
@ -12,87 +12,89 @@
},
"scripts": {
"dev": "next dev",
"start": "next start",
"start": "node .next/standalone/server.js",
"build": "npm run resume:build && next build",
"export": "next export",
"lint:commit": "commitlint",
"lint:editorconfig": "editorconfig-checker",
"lint:markdown": "markdownlint-cli2",
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
"lint:eslint": "eslint \".\" --ignore-path \".gitignore\"",
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
"lint:staged": "lint-staged",
"test:unit": "cypress run --component",
"test:html-w3c-validator": "start-server-and-test \"start\" \"http://127.0.0.1:3000\" \"html-w3c-validator\"",
"test:lighthouse": "lhci autorun",
"test:e2e": "start-server-and-test \"start\" \"http://127.0.0.1:3000\" \"cypress run\"",
"test:dev": "start-server-and-test \"dev\" \"http://127.0.0.1:3000\" \"cypress open\"",
"resume:build": "node ./jsonresume-theme-custom/scripts/build.js",
"resume:build": "node ./jsonresume-theme-custom/build.js",
"release": "semantic-release",
"deploy": "vercel",
"postinstall": "husky install"
},
"dependencies": {
"@fontsource/montserrat": "4.5.13",
"@fortawesome/fontawesome-svg-core": "6.2.1",
"@fortawesome/free-brands-svg-icons": "6.2.1",
"@fortawesome/free-solid-svg-icons": "6.2.1",
"@fontsource/montserrat": "5.0.1",
"@fortawesome/fontawesome-svg-core": "6.4.0",
"@fortawesome/free-brands-svg-icons": "6.4.0",
"@fortawesome/free-solid-svg-icons": "6.4.0",
"@fortawesome/react-fontawesome": "0.2.0",
"@giscus/react": "2.2.3",
"@giscus/react": "2.2.8",
"clsx": "1.2.1",
"date-and-time": "2.4.1",
"date-and-time": "3.0.0",
"gray-matter": "4.0.3",
"html-react-parser": "3.0.4",
"next": "13.0.4",
"next-mdx-remote": "4.2.0",
"next-pwa": "5.6.0",
"html-react-parser": "3.0.16",
"katex": "0.16.7",
"next": "13.4.4",
"next-mdx-remote": "4.4.1",
"next-themes": "0.2.1",
"next-translate": "1.6.0",
"next-translate": "2.0.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"read-pkg": "7.1.0",
"read-pkg": "8.0.0",
"rehype-katex": "6.0.3",
"rehype-raw": "6.1.1",
"rehype-slug": "5.1.0",
"remark-gfm": "3.0.1",
"sharp": "0.31.2",
"shiki": "0.11.1",
"remark-math": "5.1.1",
"sharp": "0.32.1",
"shiki": "0.14.2",
"unified": "10.1.2",
"unist-util-visit": "4.1.1",
"unist-util-visit": "4.1.2",
"universal-cookie": "4.0.4"
},
"devDependencies": {
"@commitlint/cli": "17.2.0",
"@commitlint/config-conventional": "17.2.0",
"@lhci/cli": "0.10.0",
"@saithodev/semantic-release-backmerge": "2.1.2",
"@commitlint/cli": "17.6.3",
"@commitlint/config-conventional": "17.6.3",
"@saithodev/semantic-release-backmerge": "3.2.0",
"@semantic-release/git": "10.0.1",
"@tailwindcss/typography": "0.5.8",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@tailwindcss/typography": "0.5.9",
"@tsconfig/strictest": "2.0.1",
"@types/node": "20.2.5",
"@types/react": "18.2.7",
"@types/unist": "2.0.6",
"@typescript-eslint/eslint-plugin": "5.43.0",
"autoprefixer": "10.4.13",
"cypress": "11.1.0",
"editorconfig-checker": "4.0.2",
"eslint": "8.28.0",
"eslint-config-conventions": "5.0.0",
"eslint-config-next": "13.0.4",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"@typescript-eslint/eslint-plugin": "5.59.7",
"autoprefixer": "10.4.14",
"cypress": "12.13.0",
"editorconfig-checker": "5.0.1",
"eslint": "8.41.0",
"eslint-config-conventions": "9.0.0",
"eslint-config-next": "13.4.4",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-unicorn": "44.0.2",
"html-w3c-validator": "1.2.1",
"husky": "8.0.2",
"eslint-plugin-unicorn": "47.0.0",
"html-w3c-validator": "1.3.0",
"husky": "8.0.3",
"jsonresume-theme-custom": "file:./jsonresume-theme-custom",
"lint-staged": "13.0.3",
"markdownlint-cli2": "0.5.1",
"postcss": "8.4.19",
"prettier": "2.7.1",
"prettier-plugin-tailwindcss": "0.1.13",
"semantic-release": "19.0.5",
"start-server-and-test": "1.14.0",
"tailwindcss": "3.2.4",
"typescript": "4.9.3",
"vercel": "28.5.5"
"lint-staged": "13.2.2",
"markdownlint-cli2": "0.7.1",
"markdownlint-rule-relative-links": "1.2.0",
"next-translate-plugin": "2.0.5",
"postcss": "8.4.24",
"prettier": "2.8.8",
"prettier-plugin-tailwindcss": "0.3.0",
"semantic-release": "21.0.2",
"start-server-and-test": "2.0.0",
"tailwindcss": "3.3.2",
"typescript": "5.0.4",
"vercel": "30.0.0"
}
}

View File

@ -13,7 +13,7 @@ const Error404: NextPage<Error404Props> = (props) => {
return (
<>
<Head title='404 | Divlo' />
<Head title='404 | Théo LUDWIG (Divlo)' />
<ErrorPage
statusCode={404}
message={t('errors:not-found')}

View File

@ -13,7 +13,7 @@ const Error500: NextPage<Error500Props> = (props) => {
return (
<>
<Head title='500 | Divlo' />
<Head title='500 | Théo LUDWIG (Divlo)' />
<ErrorPage
statusCode={500}
message={t('errors:server-error')}

View File

@ -1,9 +1,12 @@
import type { GetStaticProps, GetStaticPaths, NextPage } from 'next'
import Image from 'next/image'
import { MDXRemote } from 'next-mdx-remote'
import date from 'date-and-time'
import Giscus from '@giscus/react'
import { useTheme } from 'next-themes'
import 'katex/dist/katex.min.css'
import { Head } from 'components/Head'
import { Header } from 'components/Header'
import type { FooterProps } from 'components/Footer'
@ -22,56 +25,63 @@ const BlogPostPage: NextPage<BlogPostPageProps> = (props) => {
return (
<>
<Head
title={`${post.frontmatter.title} | Divlo`}
title={`${post.frontmatter.title} | Théo LUDWIG (Divlo)`}
description={post.frontmatter.description}
/>
<Header />
<main className='flex flex-1 flex-col flex-wrap items-center'>
<div className='my-10 flex flex-col items-center'>
<main className='break-wrap-words flex flex-1 flex-col flex-wrap items-center'>
<div className='my-10 flex flex-col items-center text-center'>
<h1 className='text-3xl font-semibold'>{post.frontmatter.title}</h1>
<p className='mt-2' data-cy='blog-post-date'>
{date.format(new Date(post.frontmatter.publishedOn), 'DD/MM/YYYY')}
</p>
</div>
<div className='prose mb-10 px-8'>
<MDXRemote
{...post.source}
components={{
img: (properties) => {
const { src, alt, ...props } = properties
let source = src
source = src?.replace('../public/', '/')
return (
<span className='flex flex-col items-center justify-center'>
<img src={source} alt={alt} {...props} />
</span>
)
},
a: (props) => {
if (props.href?.startsWith('#') ?? false) {
return <a {...props} />
<div className='prose mb-10'>
<div className='px-8'>
<MDXRemote
{...post.source}
components={{
img: (properties) => {
const { src = '', alt = 'Blog Image' } = properties
const source = src.replace('../public/', '/')
return (
<span className='flex flex-col items-center justify-center'>
<Image
src={source}
alt={alt}
width={1000}
height={1000}
className='h-auto w-auto'
/>
</span>
)
},
a: (props) => {
if (props.href?.startsWith('#') ?? false) {
return <a {...props} />
}
return (
<a target='_blank' rel='noopener noreferrer' {...props} />
)
}
return (
<a target='_blank' rel='noopener noreferrer' {...props} />
)
}
}}
/>
<Giscus
id='comments'
repo='Divlo/Divlo'
repoId='MDEwOlJlcG9zaXRvcnkzNTg5NDg1NDQ='
category='General'
categoryId='DIC_kwDOFWUewM4CQ_WK'
mapping='pathname'
reactionsEnabled='1'
emitMetadata='0'
inputPosition='top'
theme={theme}
lang='en'
loading='lazy'
/>
}}
/>
<Giscus
id='comments'
repo='Divlo/Divlo'
repoId='MDEwOlJlcG9zaXRvcnkzNTg5NDg1NDQ='
category='General'
categoryId='DIC_kwDOFWUewM4CQ_WK'
mapping='pathname'
reactionsEnabled='1'
emitMetadata='0'
inputPosition='top'
theme={theme}
lang='en'
loading='lazy'
/>
</div>
</div>
</main>
<Footer version={version} />
@ -82,7 +92,7 @@ const BlogPostPage: NextPage<BlogPostPageProps> = (props) => {
export const getStaticProps: GetStaticProps<BlogPostPageProps> = async (
context
) => {
const slug = context?.params?.slug
const slug = context?.params?.['slug']
const { getPostBySlug } = await import('utils/blog')
const post = await getPostBySlug(slug)
if (post == null || (post != null && !post.frontmatter.isPublished)) {

View File

@ -31,7 +31,7 @@ For example the [Linux kernel](https://www.kernel.org/), is one of the biggest o
With a project of this magnitude, we can't let everyone do what they want and however they want, **we must set rules and conventions** to get everyone to agree, this allows to add features faster and will reduce possible bugs as **developers** will not struggle as much to understand the code.
## Definition : Design Patterns
## Definition: Design Patterns
These **rules** and **conventions** are so called **Design Patterns**.
@ -77,8 +77,8 @@ setTimeout(restart, 86400000)
##### Example (good way)
```typescript
const MILLISECONDS_IN_A_DAY = 24 * 60 * 60 * 1000
setTimeout(restart, MILLISECONDS_IN_A_DAY)
const MILLISECONDS_IN_ONE_DAY = 24 * 60 * 60 * 1000
setTimeout(restart, MILLISECONDS_IN_ONE_DAY)
```
---
@ -131,7 +131,9 @@ const printCar = (car: Car): void => {
---
#### Boolean names (Prefix: is, has, can)
#### Boolean names
The name of a boolean variable should be a question, and the answer should be true or false. We can use prefixes like `is`, `has`, `can` to make it more explicit and we should avoid negation.
##### Example (bad way)
@ -171,7 +173,10 @@ We have to keep it as simple as possible, not to implement features that are not
import fs from 'node:fs'
import path from 'node:path'
const createFile = async (name: string, isTemporary: boolean = false) => {
const createFile = async (
name: string,
isTemporary: boolean = false
): Promise<void> => {
if (isTemporary) {
return await fs.promises.writeFile(path.join('temporary', name), '')
}
@ -187,11 +192,11 @@ const createFile = async (name: string, isTemporary: boolean = false) => {
import fs from 'node:fs'
import path from 'node:path'
const createFile = async (name: string) => {
const createFile = async (name: string): Promise<void> => {
await fs.promises.writeFile(name, '')
}
const createTemporaryFile = async (name: string) => {
const createTemporaryFile = async (name: string): Promise<void> => {
await createFile(path.join('temporary', name))
}
```
@ -210,7 +215,7 @@ The End To End (e2e) and Unit tests should document what is the behavior intende
### Avoid comments
One of the most important rule of "Clean Code" : If you need to add **comments**, it's because your code is **not clean**.
One of the most important rule of "Clean Code": If you need to add **comments**, it's because your code is **not clean**.
I know that might be counter intuitive at first, as most developers will advice you to add comments to your code, to document what it does.

View File

@ -0,0 +1,343 @@
---
title: '🧠 Programming Challenges'
description: 'What are Programming Challenges and Competitive Programming and an introduction to Time/Space Complexity with Big O Notation.'
isPublished: true
publishedOn: '2023-05-21T10:20:18.837Z'
---
Hello! 👋
As **performance** and **reliability** is more and more important in software development, it is important to know how to write **efficient code**, and also learn to **not rely on every possible dependency of the world**, when it is not worth it.
The more dependencies we add to our projects, the greater the complexity and maintenance overhead becomes. Each additional dependency requires understanding its functionality, <abbr title="Application Programming Interface">API</abbr>, and potential conflicts with other dependencies. This complexity makes the codebase harder to maintain, and it also poses significant security risks.
We don't want to "reinvent the wheel" and rewrite everything from scratch for each project. In fact, you are **always depending on something** when you are writing your software. At the very least, you are dependent on the programming language you are using. Even if you are doing very low-level stuff, you are still depending on something: hardware.
However, it is important to draw a line between what dependencies are worth the cost and which are not.
Most likely adding a [JavaScript npm package `is-odd`](https://www.npmjs.com/package/is-odd) to check if a number is odd or even for example, is not worth it. Writing it ourselves is easier and allows a better maintenance in the long term.
Learning **how to solve problems** and how to write efficient code is very important and also a very broad and complicated topic, so this blog post will only be an **introduction to the subject**, and will not go in depth.
**Note:** Sources used to write this blog post are available at the [end of this post](#sources).
## What is Competitive Programming?
**Competitive programming** consists of solving correctly and efficiently **well-defined problems** by writing **computer programs** under specified **constraints**. Typically a solution to a problem is a combination of well-known techniques and new insights.
There are many famous competitions: [Google Code Jam](https://codingcompetitions.withgoogle.com/codejam), [Facebook Hacker Cup](https://www.facebook.com/codingcompetitions/hacker-cup), [International Olympiad in Informatics](https://ioinformatics.org/), [International Collegiate Programming Contest](https://icpc.global/), [LeetCode](https://leetcode.com/), [CodinGame](https://www.codingame.com/), etc.
The most common programming languages used for Competitive Programming are: **C++**, **Python** and **Java**. However the design of the algorithms and data structures are applicable to **any programming language**.
All examples solutions on this blog post will be done in **Python**.
## Topics to explore/learn with Competitive Programming
- Time/Space complexity and Big O Notation
- Sorting: Sorting algorithms and Binary search
- Data structures: Arrays (1D, 2D: Matrix, 3D, Multidimensional), Dictionaries, Linked lists, Stack, Queue, Trees, Graphs, Heaps, etc.
- Complete search: Generating Subsets, Permutations, Combinations, etc.
- Greedy algorithms: Coin problem, Scheduling, Minimizing sums, etc.
- Dynamic programming: Fibonacci, Coin problem, Knapsack, etc.
- Bit manipulation: Bit representation, Bit operations, etc.
- Shortest path: Dijkstra, Bellman-Ford, Floyd-Warshall, etc.
- String: Trie structure, String hashing, Z-algorithm, etc.
You can see there are lot of concepts to learn and explore, and it is not an exhaustive list. On this blog post, we will only see the first topic: **Time/Space complexity and Big O Notation**.
## Time/Space complexity and Big O Notation
### Definition
An Algorithm is a finite sequence of well-defined instructions, that have to be given to the computer to perform a specific task. In this context, the variation can occur the way how the instructions are defined. There can be **any number of ways**, a specific set of instructions can be defined **to perform the same task**. Also, with options available to choose any one of the available programming languages, the instructions can take any form of syntax along with the performance boundaries of the chosen programming language. We also indicated the algorithm to be performed in a computer, which leads to the next variation, in terms of the operating system, processor, hardware, etc. that are used, which can also influence the way an algorithm can be performed.
Different factors can influence the outcome of an algorithm being executed, it is wise to understand how efficiently such programs are used to perform a task. To gauge this, we require to evaluate:
- The **Space complexity** of an algorithm **quantifies** the amount of **space or memory taken** by an algorithm to run based on the size of the input.
- The **Time complexity** of an algorithm **quantifies** the amount of **time taken** by an algorithm to run based on the size of the input.
We more often talk about the **time complexity** than space complexity of an algorithm, because we can reuse memory unlike time and memory is cheap nowadays.
**Big O Notation** describes the complexity of an algorithm in terms of **how quickly it grows relative to the input size $n$ (e.g: length of the string, size of the array etc.)** by defining the $N$ number of operations that are done on it.
Example of Big O notation: $O(n^2)$.
### Time complexity
Time complexity **measures** the **time taken** **to execute each statement** of code in an algorithm. It is not going to examine the total execution time of an algorithm. Rather, it is going to give information about the variation (increase or decrease) in execution time when the number of operations (increase or decrease) in an algorithm.
There are many rules to calculate the time complexity of an algorithm.
#### Loops
A common reason why an algorithm is slow is that it contains many loops that go through the input. The more nested loops the algorithm contains, the slower it will run.
If there are $k$ nested loops, the time complexity of the algorithm will be $O(n^k)$.
##### Example $O(n)$
```python
for iteration in range(n):
pass
# or with a while loop
iteration = 0
while iteration < n:
pass
```
##### Example $O(n^2)$
```python
for iteration in range(n):
for iteration2 in range(n):
pass
```
##### Example $O(n^3)$
```python
for iteration in range(n):
for iteration2 in range(n):
for iteration3 in range(n):
pass
```
etc.
#### Order of magnitude
A time complexity does not tell us the exact number of times the code inside a loop is executed, but it only shows the **order of magnitude**.
In the following examples, the time complexity of the algorithms is $O(n)$ but the number of operations is different.
##### Example 1
```python
for iteration in range(0, n * 3, 1):
pass
```
Number of operations: $3n$
##### Example 2
```python
for iteration in range(0, n + 5, 1):
pass
```
Number of operations: $n + 5$
##### Example 3
```python
for iteration in range(0, n, 2):
pass
```
Number of operations: ${n \over 2}$
#### Phases
If the algorithms consists of consecutive phases, the total time complexity is the largest time complexity of a single phase because it is usually the bottleneck of the code.
The following code consists of 3 phases, with time complexities $O(n)$, $O(n^2)$ and $O(n)$. Thus the total time complexity is $O(n^2)$.
```python
for iteration in range(n):
pass
for iteration in range(n):
for iteration2 in range(n):
pass
for iteration in range(n):
pass
```
#### Several variables
Sometimes the time complexity depends on several factors. In this case, the time complexity formula contains several variables: $O(nm)$.
```python
for iteration in range(n):
for iteration2 in range(m):
pass
```
#### Recursion
The time complexity of a recursive function depends on the number of times it is called and the time complexity of a single call. The total time complexity is the product of these values.
##### Example 1
The call `recursive(n)` causes $n$ calls and the time complexity of each call is $O(1)$. Thus the total time complexity is $O(n)$.
```python
def recursive(n: int):
if n != 1:
recursive(n - 1)
```
##### Example 2
```python
def recursive(n: int):
if n != 1:
recursive(n - 1)
recursive(n - 1)
```
In this case, `recursive(n)` causes 2 other calls except for $n = 1$.
The following table shows the function calls produced by this single call:
| function call | number of calls |
| ------------- | --------------- |
| $g(n)$ | $1$ |
| $g(n - 1)$ | $2$ |
| $g(n - 2)$ | $4$ |
| ... | ... |
| $g(1)$ | $2^{n - 1}$ |
Based on this, the time complexity is:
$$
1 + 2 + 4 + ... + 2^{n - 1} = 2^n - 1 = O(2^n)
$$
#### Complexity Classes (from fastest to slowest)
![Big O Notation](../public/images/posts/programming-challenges/big-o-chart-notations.webp)
Here is a list of classes of functions that are commonly encountered when analyzing the running time of an algorithm.
- $O(1)$: **Constant** (does not depend on the input size). A typical constant-time algorithm is a direct formula that calculates the answer.
- $O(\log_2(n))$: **Logarithmic** algorithm often halves the input size at each step. $\log_2(n)$ equals the number of times $n$ must be divided by 2 to get 1.
- $O(\sqrt{n})$: **Square root** algorithm is slower than $O(\log_2(n))$ but faster than $O(n)$.
- $O(n)$: **Linear** algorithm goes through the input a constant number of times. This is often the best possible time complexity, because it is usually necessary to access each input element at least once before reporting the answer.
- $O(n \log_2(n))$: **Log linear** often indicates that the algorithm sorts the input, because the time complexity of efficient sorting algorithms is $O(n \log_2(n))$. Another possibility is that the algorithm uses a data structure where each operation takes $O(\log_2(n))$ time.
- $O(n^2)$: **Quadratic** algorithm often contains 2 nested loops. It is possible to go trough all pairs of the input elements in $O(n^2)$ time.
- $O(n^3)$: **Cubic** algorithm often contains 3 nested loops. It is possible to go trough all triplets of the input elements in $O(n^3)$ time.
- $O(2^n)$: **Exponential** often indicates that the algorithm iterates through all subsets of the input elements. For example, the subsets of $\{1, 2, 3\}$ are $S = \{\{\empty\}, \{1\}, \{2\}, \{3\}, \{1, 2\}, \{1, 3\}, \{2, 3\}, \{1, 2, 3\} \}$.
- $O(n!)$: **Factorial** often indicates that the algorithm iterates through all permutations of the input elements. For example, the permutations of $\{1, 2, 3\}$ are $P = \{\{1, 2, 3\}, \{1, 3, 2\}, \{2, 1, 3\}, \{2, 3, 1\}, \{3, 1, 2\}, \{3, 2, 1\} \}$.
### Estimating efficiency
By checking the time complexity of an algorithm, it is possible to check before implementing the algorithm,that it is efficient enough for the problem.
Example: assume that the time limit for a problem is 1 second and the input size is $n = 10^5$. If the time complexity is $O(n^2)$, the algorithm will perform about $(10^5)^2 = 10^{10}$ operations.
Given that a modern computer can perform some hundred of millions of operations per second. This should take at least 10 seconds, so the algorithm seems to be too slow for solving the problem.
## Practical problem: Maximum subarray sum
There are often several possible algorithms for solving a problem such that their time complexities are different. This section discusses a classic problem that can be solved using several different algorithmic techniques, including brute force, divide and conquer, dynamic programming, and reduction to shortest paths, each technique with different time complexity.
**Maximum subarray sum**: Given an array of $n$ integers, find the contiguous subarray with the largest sum.
Contiguous subarray is any sub series of elements in a given array that are contiguous ie their indices are continuous. The problem is interesting when there may be negative values in the array, because if the array only contains positive values, the maximum subarray sum is basically the sum of the array (the subarray being the complete array).
### Example 1
#### Input
```txt
[1, 2, 3, 4, 5, 6]
```
#### Output
```txt
21
```
**Explanation:** The subarray with the largest sum is the array itself (as there is no negative values) `[1, 2, 3, 4, 5, 6]` which has a sum of `21`.
### Example 2
#### Input
```txt
[-1, 2, 4, -3, 5, 2, -5, 2]
```
#### Output
```txt
10
```
**Explanation:** The subarray with the largest sum is `[2, 4, -3, 5, 2]` which has a sum of `10`.
### Worst solution: Brute force
```python
def maximum_subarray_sum_cubic(array: list[int]) -> int:
"""
Time complexity: O((array_length)^3)
We go through all possible subarrays, calculate the sum in each subarray and maintain the maximum sum.
"""
if len(array) == 0:
return 0
best_sum = array[0]
length = len(array)
for i in range(length):
for j in range(i, length):
sum = 0
for k in range(i, j + 1):
sum += array[k]
if sum > best_sum:
best_sum = sum
return best_sum
```
### Better solution: Linear time
```python
def maximum_subarray_sum_linear(array: list[int]) -> int:
"""
Time complexity: O(array_length)
We loop through the array and for each array position, we calculate the maximum sum of a subarray that ends at that position. After this, the answer for the problem is the maximum of those sums.
"""
if len(array) == 0:
return 0
best_sum = array[0]
length = len(array)
sum = 0
for i in range(length):
sum = max(array[i], sum + array[i])
best_sum = max(best_sum, sum)
return best_sum
```
## Conclusion
Problems solving is a very complicated and large topic, and also a very important skill to have as a software developer.
To improve our problems solving skills, we can regularly practice with [programming challenges](https://github.com/Divlo/programming-challenges).
## Sources
- [Wikipedia - Competitive programming](https://en.wikipedia.org/wiki/Competitive_programming)
- [Frontend Masters - The Last Algorithms Course You'll Need](https://frontendmasters.com/courses/algorithms/)
- [Big-O Cheat Sheet](https://www.bigocheatsheet.com/)
- [programming challenges](https://github.com/Divlo/programming-challenges)

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,51 +0,0 @@
{
"name": "Divlo",
"short_name": "Divlo",
"icons": [
{
"src": "images/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "images/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "images/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "images/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "images/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffd800",
"background_color": "#181818",
"start_url": "/",
"display": "standalone"
}

View File

@ -1,118 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"meta": {
"theme": "custom"
},
"basics": {
"name": "Théo LUDWIG",
"label": "Développeur Full Stack • Enthousiaste de l'Open-Source",
"image": "https://divlo.fr/images/logo_orange.png",
"email": "contact@divlo.fr",
"location": {},
"url": "https://divlo.fr",
"summary": "Je suis étudiant à l'université suivant la formation \"BUT Informatique\" et me forme en autodidacte dans l'informatique en suivant des formations en ligne. <br/> Je mets en pratique tout ce que j'apprends et réalise de nombreux projets (disponible sur divlo.fr)."
},
"education": [
{
"startDate": "2022",
"studyType": "Diplôme du Bachelor Universitaire de Technologie (BUT) Informatique",
"institution": "IUT Robert Schuman à Illkirch-Graffenstaden",
"score": "2ème année"
},
{
"startDate": "2019",
"endDate": "2021",
"studyType": "Diplôme du Baccalauréat Général (Mathématiques et Numériques Sciences Informatiques)",
"institution": "Lycée Heinrich Nessel à Haguenau",
"score": "Mention Assez Bien"
},
{
"startDate": "2014",
"endDate": "2018",
"studyType": "Diplôme national du brevet",
"institution": "Collège Gustave Doré à Hochfelden",
"score": "Mention Bien"
}
],
"work": [
{
"summary": "Développement site web en React.js et Strapi afin de répondre <a href=\"https://www.nuitdelinfo.com/nuitinfo/_media/infos:la_nuit_de_l_info_2021_-_sujet.pdf\">au sujet de la Nuit de l'Info 2021</a>.<br /> Classé n°1 en France sur le Défi de l'entreprise <a href=\"https://www.nuitdelinfo.com/inscription/defis/300\">ToolPad</a>.",
"website": "https://www.nuitdelinfo.com/",
"name": "La Nuit de l'info 2021",
"position": "Participation en équipe de 5 personnes",
"startDate": "2021-12-02",
"endDate": "2021-12-03"
},
{
"summary": "Agent administratif - Numérisation et archivage des plans électriques initialement sous format papier calque.",
"website": "https://www.es.fr/",
"name": "ÉS (Électricité de Strasbourg)",
"location": "5 Rue André Marie Ampère, 67450 Mundolsheim",
"position": "Emploi d'été en qualité d'agent administratif",
"startDate": "2021-07-07",
"endDate": "2021-07-30"
},
{
"summary": "Hackathon développement d'une landing page et web scraping.",
"website": "https://www.wildcodeschool.fr/",
"name": "Wild Code School",
"location": "32 Rue du Bass. d'Austerlitz, 67100 Strasbourg",
"position": "Stage initiation métier développeur web",
"startDate": "2019-06-24",
"endDate": "2019-06-28"
},
{
"summary": "Développement d'un site web pour trouver un restaurant à la pause repas.",
"website": "https://www.itpartners.fr/",
"name": "Tribe | IT Partners",
"location": "16 Rue du Parc, 67205 Oberhausbergen",
"position": "Stage initiation métier développeur web",
"startDate": "2019-06-17",
"endDate": "2019-06-21"
},
{
"summary": "Apprentissage du métier \"Chargé de communication\" et des logiciels de graphisme tels que \"Adobe Photoshop\".",
"website": "https://www.es.fr/",
"name": "ÉS (Électricité de Strasbourg)",
"location": "26 Bd du Président-Wilson, 67000 Strasbourg",
"position": "Stage de découverte (3ème)",
"startDate": "2018-02-19",
"endDate": "2018-02-23"
}
],
"interests": [
{
"name": "Développeur Full Stack"
},
{
"name": "Enthousiaste de l'Open-Source"
},
{
"name": "Passionné de High-Tech"
}
],
"skills": [
{
"keywords": ["JavaScript", "TypeScript", "Python", "C/C++", "PHP"],
"name": "Langages de programmation"
},
{
"keywords": ["HTML", "CSS", "Tailwind CSS", "React.js (+ Next.js)"],
"name": "Front-end"
},
{
"keywords": ["Laravel", "Node.js", "Fastify", "PostgreSQL"],
"name": "Back-end"
},
{
"keywords": [
"GNU/Linux",
"Ubuntu",
"Visual Studio Code",
"git",
"Docker"
],
"name": "Logiciels et outils"
}
]
}

160
resume.jsonc Normal file
View File

@ -0,0 +1,160 @@
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"meta": {
"theme": "custom"
},
"basics": {
"name": "Théo LUDWIG",
"label": "Développeur Full Stack • Étudiant",
"image": "https://divlo.fr/images/logo_orange.png",
"email": "contact@divlo.fr",
"age": "31/03/2003",
"location": {
"address": "Alsace, France"
},
"url": "https://divlo.fr",
"summary": "Je suis étudiant à l'université suivant la formation \"BUT Informatique\" et me forme en autodidacte dans l'informatique en suivant des formations en ligne. <br/> Je mets en pratique tout ce que j'apprends et réalise de nombreux projets (disponible sur <a href=\"https://divlo.fr\">divlo.fr</a>)."
},
"education": [
{
"startDate": "2022",
"endDate": "2023",
"studyType": "Bachelor Universitaire de Technologie (BUT) Informatique",
"institution": "IUT Robert Schuman à Illkirch-Graffenstaden",
"score": "2ème année",
"courses": [
"Développement Web avec le framework Laravel en PHP",
"Patrons et Principes de conceptions (Code maintenable et réutilisable) en UML",
"Programmation systèmes en C (Multi-Thread, Serveur/Client UDP/TCP)",
"Sécurisation des accès à la base de données et PL/SQL",
"Projet développement d'une application web en React.js en équipe de 3 personnes pendant 3 mois"
]
},
{
"startDate": "2021",
"endDate": "2022",
"studyType": "Bachelor Universitaire de Technologie (BUT) Informatique",
"institution": "IUT Robert Schuman à Illkirch-Graffenstaden",
"score": "1ère année",
"courses": [
"Développement Orientée Objet en Java",
"Programmation systèmes en C (Allocation mémoire, Pointeurs, Structures)",
"Développement d'application Windows Forms (.NET Framework) en C#",
"Base de données relationnelles et langage SQL"
]
},
{
"startDate": "2019",
"endDate": "2021",
"studyType": "Baccalauréat Général (Mathématiques et Numériques Sciences Informatiques)",
"institution": "Lycée Heinrich Nessel à Haguenau",
"score": "Mention Assez Bien"
}
// {
// "startDate": "2014",
// "endDate": "2018",
// "studyType": "Diplôme national du brevet",
// "institution": "Collège Gustave Doré à Hochfelden",
// "score": "Mention Bien"
// }
],
"work": [
{
"summary": "Développement d'un outil GED (Gestion Électronique de Documents) en React.js, Laravel et GraphQL.",
"website": "https://numerize.com/",
"name": "Numerize",
"location": "4 Rue Sophie Germain, 67720 Hœrdt",
"position": "Stagiaire Développeur Web",
"startDate": "2023-04-11",
"endDate": "2023-06-23",
"duration": "3 mois"
},
{
"summary": "Agent administratif - Numérisation et archivage des plans électriques initialement sous format papier calque.",
"website": "https://www.es.fr/",
"name": "ÉS (Électricité de Strasbourg)",
"location": "5 Rue André Marie Ampère, 67450 Mundolsheim",
"position": "Emploi d'été en qualité d'agent administratif",
"startDate": "2021-07-07",
"endDate": "2021-07-30",
"duration": "1 mois"
},
{
"summary": "Développement d'un site web pour trouver un restaurant à la pause repas.",
"website": "https://www.itpartners.fr/",
"name": "Tribe | IT Partners",
"location": "16 Rue du Parc, 67205 Oberhausbergen",
"position": "Stage initiation métier développeur web",
"startDate": "2019-06-17",
"endDate": "2019-06-21",
"duration": "1 semaine"
},
{
"description": "interests",
"summary": "Développement site web en React.js et Strapi.<br /> Classé n°1 en France sur le Défi de l'entreprise <a href=\"https://www.toolpad.fr/\">ToolPad</a>.",
"website": "https://www.nuitdelinfo.com/",
"name": "La Nuit de l'info 2021",
"position": "Participation en équipe de 5 personnes",
"startDate": "2021-12-02",
"endDate": "2021-12-03",
"duration": "1 semaine"
},
{
"description": "interests",
"summary": "Hackathon développement d'une landing page et web scraping.",
"website": "https://www.wildcodeschool.fr/",
"name": "Wild Code School",
"location": "32 Rue du Bass. d'Austerlitz, 67100 Strasbourg",
"position": "Initiation métier développeur web",
"startDate": "2019-06-24",
"endDate": "2019-06-28",
"duration": "1 semaine"
}
// {
// "summary": "Apprentissage du métier \"Chargé de communication\" et des logiciels de graphisme tels que \"Adobe Photoshop\".",
// "website": "https://www.es.fr/",
// "name": "ÉS (Électricité de Strasbourg)",
// "location": "26 Bd du Président-Wilson, 67000 Strasbourg",
// "position": "Stage de découverte (3ème)",
// "startDate": "2018-02-19",
// "endDate": "2018-02-23",
// "duration": "1 semaine"
// }
],
"interests": [
{
"name": "Enthousiaste de l'Open-Source"
},
{
"name": "Passionné de High-Tech"
}
],
"skills": [
{
"keywords": ["JavaScript/TypeScript", "Python", "C/C++", "PHP"],
"name": "Langages de programmation"
},
{
"keywords": ["HTML", "CSS", "Tailwind CSS", "React.js/Next.js"],
"name": "Front-end"
},
{
"keywords": ["Laravel", "Node.js", "Fastify", "PostgreSQL"],
"name": "Back-end"
},
{
"keywords": [
"GNU/Linux",
"Ubuntu",
"Visual Studio Code",
"Git",
"Docker"
],
"name": "Logiciels et outils"
},
{
"keywords": ["Permis B", "Anglais"],
"name": "Autres"
}
]
}

View File

@ -2,8 +2,13 @@
@tailwind components;
@tailwind utilities;
.break-wrap-words {
word-wrap: break-word;
word-break: break-word;
}
.prose {
@apply !max-w-4xl text-gray dark:text-gray-300;
@apply !max-w-5xl text-gray dark:text-gray-300;
}
.prose a,
@ -28,8 +33,6 @@
}
.shiki {
white-space: pre-wrap !important;
word-break: break-word !important;
word-wrap: normal;
}
code {
counter-reset: step;
@ -43,4 +46,12 @@ code .line::before {
display: inline-block;
text-align: right;
color: rgba(133, 133, 133, 0.8);
word-wrap: normal;
word-break: normal;
}
.katex .base {
display: inline !important;
white-space: normal !important;
width: 100% !important;
}

View File

@ -1,25 +1,24 @@
{
"extends": "@tsconfig/strictest/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"lib": ["dom", "dom.iterable", "ESNext"],
"allowJs": true,
"checkJs": true,
"jsx": "preserve",
"sourceMap": true,
"removeComments": true,
"noEmit": true,
"strict": true,
"types": ["cypress"],
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"types": ["cypress"],
"noEmit": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true
"jsx": "preserve",
"incremental": true,
"exactOptionalPropertyTypes": false,
"verbatimModuleSyntax": false,
"isolatedModules": true
},
"exclude": ["dist", ".next", "out", "next.config.js"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

View File

@ -7,6 +7,8 @@ import rehypeRaw from 'rehype-raw'
import { serialize } from 'next-mdx-remote/serialize'
import remarkGfm from 'remark-gfm'
import rehypeSlug from 'rehype-slug'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'
import matter from 'gray-matter'
import { getHighlighter } from 'shiki'
@ -38,11 +40,17 @@ export const getPosts = async (): Promise<PostMetadata[]> => {
const postsWithTime = await Promise.all(
posts.map(async (postFilename) => {
const [slug, extension] = postFilename.split('.')
if (slug == null || extension == null) {
throw new Error('Invalid postFilename.')
}
const blogPostPath = path.join(POSTS_PATH, `${slug}.${extension}`)
const blogPostContent = await fs.promises.readFile(blogPostPath, {
encoding: 'utf8'
})
const { data, content } = matter(blogPostContent) as any
const { data, content } = matter(blogPostContent) as unknown as {
data: FrontMatter
content: string
}
const date = new Date(data.publishedOn)
return {
slug,
@ -78,12 +86,14 @@ export const getPostBySlug = async (
const source = await serialize(post.content, {
mdxOptions: {
remarkPlugins: [
remarkGfm as any,
[remarkSyntaxHighlightingPlugin, { highlighter }]
remarkGfm,
[remarkSyntaxHighlightingPlugin, { highlighter }],
remarkMath
],
rehypePlugins: [
rehypeSlug as any,
[rehypeRaw, { passThrough: nodeTypes }]
rehypeSlug,
[rehypeRaw, { passThrough: nodeTypes }],
rehypeKatex
]
}
})

View File

@ -1,11 +1,11 @@
export const DIVLO_BIRTHDAY_DAY = '31' as const
export const DIVLO_BIRTHDAY_MONTH = '03' as const
export const DIVLO_BIRTHDAY_YEAR = '2003' as const
export const DIVLO_BIRTHDAY_DATE =
`${DIVLO_BIRTHDAY_DAY}/${DIVLO_BIRTHDAY_MONTH}/${DIVLO_BIRTHDAY_YEAR}` as const
export const DIVLO_BIRTHDAY_DATE_ISO_8061 =
`${DIVLO_BIRTHDAY_YEAR}-${DIVLO_BIRTHDAY_MONTH}-${DIVLO_BIRTHDAY_DAY}` as const
export const DIVLO_BIRTHDAY = new Date(DIVLO_BIRTHDAY_DATE_ISO_8061)
export const DIVLO_BIRTH_DATE_DAY = '31' as const
export const DIVLO_BIRTH_DATE_MONTH = '03' as const
export const DIVLO_BIRTH_DATE_YEAR = '2003' as const
export const DIVLO_BIRTH_DATE_STRING =
`${DIVLO_BIRTH_DATE_DAY}/${DIVLO_BIRTH_DATE_MONTH}/${DIVLO_BIRTH_DATE_YEAR}` as const
export const DIVLO_BIRTH_DATE_ISO_8601 =
`${DIVLO_BIRTH_DATE_YEAR}-${DIVLO_BIRTH_DATE_MONTH}-${DIVLO_BIRTH_DATE_DAY}` as const
export const DIVLO_BIRTH_DATE = new Date(DIVLO_BIRTH_DATE_ISO_8601)
/**
* Calculates the age of a person based on their birth date