portfolio/README.md

203 lines
7.7 KiB
Markdown
Raw Permalink Normal View History

2018-05-14 02:44:11 +02:00
<p align="center">
<a href="https://matthiaskretschmann.com"><img src="public/github-header.png" /></a>
2018-05-14 02:44:11 +02:00
</p>
2018-11-24 18:29:02 +01:00
<h2 align="center">
👔 Portfolio thingy.
2018-11-24 18:29:02 +01:00
</h2>
2018-05-14 02:44:11 +02:00
<p align="center">
<a href="https://matthiaskretschmann.com">matthiaskretschmann.com</a>
</p>
<p align="center">
2019-11-26 11:12:51 +01:00
<a href="https://github.com/kremalicious/portfolio/actions"><img src="https://github.com/kremalicious/portfolio/workflows/CI%2FCD%20Pipeline/badge.svg" /></a>
2018-05-22 22:41:59 +02:00
<a href="https://codeclimate.com/github/kremalicious/portfolio/maintainability"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/maintainability" /></a>
2019-04-14 19:28:05 +02:00
<a href="https://codeclimate.com/github/kremalicious/portfolio/test_coverage"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/test_coverage" /></a>
2018-05-14 02:44:11 +02:00
</p>
2018-05-14 01:50:11 +02:00
---
2018-09-20 14:45:07 +02:00
- [🎉 Features](#-features)
- [💍 One data file to rule all pages](#-one-data-file-to-rule-all-pages)
- [🖼 Project images](#-project-images)
2019-05-26 22:55:28 +02:00
- [🐱 GitHub repositories](#-github-repositories)
- [📍 Location](#-location)
2018-09-20 14:45:07 +02:00
- [💅 Theme switcher](#-theme-switcher)
- [📇 Client-side vCard creation](#-client-side-vcard-creation)
- [💎 Importing SVG assets](#-importing-svg-assets)
2022-11-16 20:04:06 +01:00
- [🤓 Scripts](#-scripts)
- [🎈 Add a new project](#-add-a-new-project)
- [🌄 Favicon generation](#-favicon-generation)
2018-09-20 14:45:07 +02:00
- [✨ Development](#-development)
- [🔮 Linting](#-linting)
2019-04-14 17:19:33 +02:00
- [👩‍🔬 Testing](#-testing)
2018-09-20 14:45:07 +02:00
- [🚚 Deployment](#-deployment)
- [🏛 Licenses](#-licenses)
2018-05-14 01:50:11 +02:00
---
2018-09-17 19:00:38 +02:00
## 🎉 Features
2018-05-14 01:50:11 +02:00
The whole [portfolio](https://matthiaskretschmann.com) is a React-based app built with [Next.js](https://nextjs.org) in Typescript, using statically generated pages with a pinch of server-side rendering and server actions.
2019-11-19 22:49:17 +01:00
If you are looking for the former Gatsby-based app, it is archived in the [`gatsby-deprecated`](https://github.com/kremalicious/portfolio/tree/gatsby-deprecated) branch.
2018-05-14 01:50:11 +02:00
2021-03-14 01:56:46 +01:00
### 💍 One data file to rule all pages
All displayed project content is powered by one YAML file where all the portfolio's projects are defined. The project description itself is transformed from Markdown written inside the YAML file into HTML on build time.
2024-02-05 10:29:00 +01:00
Next.js automatically creates pages from each item in that file utilizing the [`scripts/prebuild.ts`](scripts/prebuild.ts) script and the [`[slug]/page.tsx`](src/app/[slug]/page.tsx) template.
2021-03-14 01:56:46 +01:00
- [`_content/projects.yml`](_content/projects.yml)
2024-02-05 10:29:00 +01:00
- [`scripts/prebuild.ts`](scripts/prebuild.ts)
- [`src/app/[slug]/page.tsx`](src/app/[slug]/page.tsx)
2021-03-14 01:56:46 +01:00
### 🖼 Project images
2019-11-19 22:49:17 +01:00
All project images live under `public/images` and are automatically attached to each project based on the inclusion of the project's `slug` in their filenames.
2019-11-19 22:49:17 +01:00
Next.js with `next/image` generates all required image sizes for delivering responsible, responsive images to visitors, including lazy loading of all images. For this to work, images are analyzed on build time and various image metadata is passed down as props.
2019-11-19 22:49:17 +01:00
- [`src/components/ProjectImage/index.tsx`](src/components/ProjectImage/index.tsx)
2024-02-05 10:29:00 +01:00
- [`script/content/images.ts`](script/content/images.ts)
2019-11-19 22:49:17 +01:00
2019-05-26 22:55:28 +02:00
### 🐱 GitHub repositories
The open source section at the bottom of the front page shows selected GitHub repositories, sourced from GitHub.
On build time, all my public repositories are fetched from GitHub, then filtered against the ones defined in `_content/repos.json`, sorted by the last push date, and provided via the `pageContext` of the front page.
2019-05-26 22:55:28 +02:00
If you want to know how, have a look at the respective components:
- [`src/lib/github.ts`](src/lib/github.ts)
- [`_content/repos.json`](_content/repos.json)
- [`src/components/Repository/index.tsx`](src/components/Repository/index.tsx)
2019-05-26 22:55:28 +02:00
### 📍 Location
On client-side, my current and, if known, my next physical location on a city level is fetched from my (private) [nomadlist.com](https://nomadlist.com) profile and displayed in the header.
Fetching is split up into an external serverless function, a server action, and display component. Fetching is done with a serverless function as to not expose the whole profile response into the browser.
If you want to know how, have a look at the respective components:
- [`src/app/actions.ts`](src/app/actions.ts)
- [`src/components/Location/index.tsx`](src/components/Location/index.tsx)
2021-12-03 01:57:26 +01:00
- [kremalicious/location](https://github.com/kremalicious/location)
2018-09-17 19:00:38 +02:00
### 💅 Theme switcher
2018-05-14 01:50:11 +02:00
Includes a theme switcher which allows user to toggle between a light and a dark theme, where by default the user's system theme is used automatically. Uses [next-themes](https://github.com/pacocoursey/next-themes) under the hood.
2018-10-17 20:42:15 +02:00
2023-01-29 06:05:18 +01:00
If you want to know how, have a look at the respective component:
2018-10-17 20:42:15 +02:00
- [`src/components/ThemeSwitch/index.tsx`](src/components/ThemeSwitch/index.tsx)
2018-05-14 01:50:11 +02:00
2018-09-17 19:00:38 +02:00
### 📇 Client-side vCard creation
2018-05-14 01:50:11 +02:00
The _Add to addressbook_ link in the footer automatically creates a downloadable vCard file on the client-side, based on data defined in `_content/meta.json`.
2018-05-14 01:50:11 +02:00
2018-10-17 20:42:15 +02:00
If you want to know how, have a look at the respective component:
- [`src/components/Vcard/index.tsx`](src/components/Vcard/index.tsx)
2018-05-14 01:50:11 +02:00
2018-09-17 19:00:38 +02:00
### 💎 Importing SVG assets
2018-05-14 01:50:11 +02:00
All SVG assets will be converted to React components with the help of [@svgr/webpack](https://react-svgr.com). Makes use of [SVGR](https://github.com/smooth-code/svgr) so SVG assets can be imported like so:
2018-05-14 01:50:11 +02:00
```js
import Logo from './images/logo.svg'
2019-01-20 14:43:15 +01:00
return <Logo />
2018-09-20 19:06:46 +02:00
```
2018-07-15 00:26:35 +02:00
2022-11-16 20:04:06 +01:00
## 🤓 Scripts
### 🎈 Add a new project
To add a new project, run the following command. This adds a new item to the top of the `projects.yml` file, creating the title & slug from the argument:
```bash
npm run new -- "Hello"
```
Then continue modifying the new entry in [`_content/projects.yml`](_content/projects.yml).
Finally, add as many images as needed with the file name format and put into `public/images/`:
```text
SLUG-01.png
SLUG-02.png
SLUG-03.png
...
```
### 🌄 Favicon generation
2022-11-16 21:36:25 +01:00
This generates all required favicon sizes from:
2022-11-16 20:04:06 +01:00
- `src/images/favicon-512.png`
2022-11-16 21:36:25 +01:00
- `src/images/favicon.svg` (handcrafted, adaptive based on OS theme)
Also creates a web manifest.
2022-11-16 20:04:06 +01:00
```bash
npm run favicon
```
2018-09-17 19:00:38 +02:00
## ✨ Development
2018-03-18 20:39:18 +01:00
```bash
2018-05-14 01:50:11 +02:00
git clone git@github.com:kremalicious/portfolio.git
cd portfolio/
# GITHUB_TOKEN is required for some parts
# See https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
2019-11-17 02:28:31 +01:00
cp .env.sample .env
vi .env
2018-03-18 20:39:18 +01:00
npm i
2024-04-10 17:05:26 +02:00
npm run dev
2018-03-18 20:39:18 +01:00
```
2018-04-21 15:02:56 +02:00
2018-09-17 19:00:38 +02:00
### 🔮 Linting
2018-04-22 23:51:50 +02:00
ESLint, Prettier, and Stylelint are setup for all linting purposes:
2018-05-14 01:50:11 +02:00
```bash
npm run lint
```
To automatically format all code files:
```bash
npm run format
```
2019-04-14 17:19:33 +02:00
### 👩‍🔬 Testing
Test suite is setup with [Jest](https://jestjs.io) and [react-testing-library](https://github.com/kentcdodds/react-testing-library).
To run all tests, including type checking and linting of all files:
2019-04-14 17:19:33 +02:00
```bash
npm test
```
Most test files live beside the respective component. Testing setup, fixtures, and mocks can be found in the `tests/` folder.
2019-04-14 17:19:33 +02:00
2018-09-17 19:00:38 +02:00
## 🚚 Deployment
2018-04-21 15:02:56 +02:00
2021-02-06 13:19:30 +01:00
Every branch or Pull Request is automatically deployed by [Vercel](https://vercel.com) with their GitHub integration, where the `main` branch is automatically aliased to `matthiaskretschmann.com`. A link to a preview deployment will appear under each Pull Request.
2018-05-14 01:50:11 +02:00
2018-09-17 19:00:38 +02:00
## 🏛 Licenses
2018-05-14 01:50:11 +02:00
**© Copyright 2024 Matthias Kretschmann**
2018-05-14 01:50:11 +02:00
2018-11-24 18:29:02 +01:00
All images and projects are plain ol' copyright, most displayed projects are subject to the copyright of their respective owners.
Don't care if you fork & play with it, but you're not allowed to publish anything from it as a whole without my written permission. Also please be aware, the combination of typography, colors & layout makes up my brand identity. So please don't just clone everything, but rather do a remix!
2018-05-14 01:50:11 +02:00
All the rest, like all code and documentation, is under:
**The MIT License**
[Full MIT license text](LICENSE)