1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-11-15 01:25:25 +01:00
portfolio/README.md

242 lines
10 KiB
Markdown
Raw Normal View History

2018-05-14 02:44:11 +02:00
<p align="center">
2018-09-17 19:00:38 +02:00
<a href="https://matthiaskretschmann.com"><img src="src/images/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, built with <a href="https://www.gatsbyjs.org">Gatsby</a>.
</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)
2021-03-14 01:56:46 +01:00
- [🗂 JSON Resume](#-json-resume)
2019-05-26 22:55:28 +02:00
- [🐱 GitHub repositories](#-github-repositories)
2018-09-20 14:45:07 +02:00
- [💅 Theme switcher](#-theme-switcher)
- [🏆 SEO component](#-seo-component)
- [📇 Client-side vCard creation](#-client-side-vcard-creation)
- [💫 Page transitions](#-page-transitions)
- [📈 Matomo (formerly Piwik) analytics tracking](#-matomo-formerly-piwik-analytics-tracking)
- [🖼 Project images](#-project-images)
- [💎 Importing SVG assets](#-importing-svg-assets)
- [🍬 Typekit component](#-typekit-component)
- [✨ Development](#-development)
- [🔮 Linting](#-linting)
2019-04-14 17:19:33 +02:00
- [👩‍🔬 Testing](#-testing)
2018-09-20 14:45:07 +02:00
- [🎈 Add a new project](#-add-a-new-project)
- [🚚 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
2021-03-14 01:55:22 +01:00
The whole [portfolio](https://matthiaskretschmann.com) is a React-based single page app built with [Gatsby v3](https://www.gatsbyjs.org).
2019-11-19 22:49:17 +01:00
Most metadata is powered by one `resume.json` file based on [🗂 JSON Resume](#-json-resume), and one `projects.yml` file to [define the displayed projects](#-one-data-file-to-rule-all-pages).
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.
Gatsby automatically creates pages from each item in that file utilizing the [`{ProjectsYaml.slug}.jsx`](src/pages/{ProjectsYaml.slug}.jsx) template.
- [`content/projects.yml`](content/projects.yml)
- [`src/pages/{ProjectsYaml.slug}.jsx`](src/pages/{ProjectsYaml.slug}.jsx)
2019-11-19 22:49:17 +01:00
### 🗂 JSON Resume
Most site metadata and social profiles are defined in [`content/resume.json`](content/resume.json) based on the [JSON Resume](https://jsonresume.org) standard and used throughout the site as a custom React hook. Additionally, a resume page is created under `/resume`.
If you want to know how, have a look at the respective components:
- [`content/resume.json`](content/resume.json)
- [`src/pages/resume/index.jsx`](src/pages/resume/index.jsx)
- [`src/hooks/use-resume.js`](src/hooks/use-resume.js)
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.
2019-11-19 22:49:17 +01:00
On build time, all my public repositories are fetched from GitHub, then filtered against the ones defined in `content/repos.yml`, 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:
- [`gatsby-node.js`](gatsby-node.js)
- [`content/repos.yml`](content/repos.yml)
- [`src/components/molecules/Repository.jsx`](src/components/molecules/Repository.jsx)
2018-09-17 19:00:38 +02:00
### 💅 Theme switcher
2018-05-14 01:50:11 +02:00
2021-03-13 03:35:50 +01:00
Includes a theme switcher which allows user to toggle between a light and a dark theme. Switching between them also happens automatically based on user's system preferences.
2018-10-17 20:42:15 +02:00
If you want to know how, have a look at the respective components:
- [`src/components/molecules/ThemeSwitch.jsx`](src/components/molecules/ThemeSwitch.jsx)
2021-03-13 03:35:50 +01:00
- [`src/hooks/useDarkMode.js`](src/hooks/useDarkMode.js)
2018-05-14 01:50:11 +02:00
2018-09-17 19:00:38 +02:00
### 🏆 SEO component
2018-05-14 01:50:11 +02:00
Includes a SEO component which automatically switches all required `meta` tags for search engines, Twitter Cards, and Facebook OpenGraph tags based on the browsed route/page.
2018-10-17 20:42:15 +02:00
If you want to know how, have a look at the respective component:
- [`src/components/atoms/SEO.jsx`](src/components/atoms/SEO.jsx)
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
2019-03-30 00:24:57 +01: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.yml`.
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/atoms/Vcard.jsx`](src/components/atoms/Vcard.jsx)
2018-05-14 01:50:11 +02:00
2018-09-20 14:13:32 +02:00
### 💫 Page transitions
2018-09-20 14:45:07 +02:00
Includes mechanism for transitioning between route changes with full page transitions defined with [react-pose](https://popmotion.io/pose/). Mechanism ~~stolen~~ inspired by [gatsby-universal](https://github.com/fabe/gatsby-universal).
2018-09-20 14:13:32 +02:00
2018-10-17 20:42:15 +02:00
If you want to know how, have a look at the respective components:
- [`src/components/Layout.jsx`](src/components/Layout.jsx)
- [`src/helpers/wrapPageElement.jsx`](src/helpers/wrapPageElement.jsx)
- [`gatsby-browser.js`](gatsby-browser.js)
- [`gatsby-ssr.js`](gatsby-ssr.js)
2018-09-17 19:00:38 +02:00
### 📈 Matomo (formerly Piwik) analytics tracking
2018-05-14 01:50:11 +02:00
Site sends usage statistics to my own [Matomo](https://matomo.org) installation. To make this work in Gatsby, I created and open sourced a plugin, [gatsby-plugin-matomo](https://github.com/kremalicious/gatsby-plugin-matomo), which is in use on this site.
2018-10-17 20:42:15 +02:00
- [gatsby-plugin-matomo](https://github.com/kremalicious/gatsby-plugin-matomo)
2018-09-17 19:00:38 +02:00
### 🖼 Project images
2018-05-14 01:50:11 +02:00
2019-03-30 00:24:57 +01:00
All project images live under `content/images` and are automatically attached to each project based on the inclusion of the project's `slug` in their filenames.
2018-05-14 01:50:11 +02:00
2021-03-13 01:03:23 +01:00
All project images make use of the excellent [gatsby-plugin-image](https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-plugin-image/) plugin, working in tandem with [gatsby-plugin-sharp](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-sharp) and [gatsby-transformer-sharp](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-sharp).
2018-05-14 01:50:11 +02:00
All together, Gatsby automatically generates all required image sizes for delivering responsible, responsive images to visitors, including lazy loading of all images. Also includes the [intersection-observer polyfill](https://github.com/w3c/IntersectionObserver) to make lazy loading work properly in Safari.
2018-10-17 20:42:15 +02:00
All project images use one single component where one main GraphQL query fragment is defined, which then gets used throughout other GraphQL queries.
2019-11-07 23:54:33 +01:00
- [`src/components/atoms/ProjectImage.jsx`](src/components/atoms/ProjectImage.jsx)
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
2018-09-20 19:06:46 +02:00
All SVG assets under `src/images/` will be converted to React components with the help of [gatsby-plugin-svgr](https://github.com/zabute/gatsby-plugin-svgr). 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
2018-09-20 19:06:46 +02:00
import { ReactComponent as Logo } from './components/svg/Logo'
2018-03-18 20:39:18 +01:00
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
2018-09-17 19:00:38 +02:00
### 🍬 Typekit component
2018-07-15 00:26:35 +02:00
Includes a component for adding the Typekit snippet.
2018-10-17 20:42:15 +02:00
If you want to know how, have a look at the respective component:
- [`src/components/atoms/Typekit.jsx`](src/components/atoms/Typekit.jsx)
2018-07-15 00:26:35 +02:00
2018-09-17 19:00:38 +02:00
## ✨ Development
2018-03-18 20:39:18 +01:00
2018-09-20 22:38:10 +02:00
You can simply use [Docker](https://www.docker.com) & [Docker Compose](https://docs.docker.com/compose/) or install and run dependencies on your local system.
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/
2019-11-17 02:28:31 +01:00
# GATSBY_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-09-20 22:38:10 +02:00
# use Docker
docker-compose up
# or go with local system
2018-03-18 20:39:18 +01:00
npm i
npm start
```
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
2018-05-14 01:50:11 +02:00
ESlint, Prettier, and Stylelint are setup for all linting purposes:
```bash
npm run lint
```
To automatically format all code files:
```bash
npm run format
npm run format:css
```
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 all linting tests:
```bash
npm test
```
2021-02-06 14:40:39 +01:00
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
### 🎈 Add a new project
2018-05-14 01:50:11 +02:00
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"
```
2019-03-30 00:24:57 +01:00
Then continue modifying the new entry in [`content/projects.yml`](content/projects.yml).
2018-05-14 01:50:11 +02:00
2019-03-30 00:24:57 +01:00
Finally, add as many images as needed with the file name format and put into `content/images/`:
2018-05-14 01:50:11 +02:00
2019-01-20 14:43:15 +01:00
```text
2019-03-30 00:24:57 +01:00
SLUG-01.png
SLUG-02.png
SLUG-03.png
2018-05-14 01:50:11 +02:00
...
2018-04-22 23:51:50 +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
2021-02-06 13:19:30 +01:00
A backup deployment is also happening to a S3 bucket, triggered by pushes to `main` and executed via GitHub Actions. The deploy command simply calls the [`scripts/deploy-s3.sh`](scripts/deploy-s3.sh) script, syncing the contents of the `public/` folder to S3:
2018-05-14 01:50:11 +02:00
2018-04-21 15:02:56 +02:00
```bash
2021-02-06 13:19:30 +01:00
npm run deploy:s3
2018-04-21 15:02:56 +02:00
```
2018-05-14 01:50:11 +02:00
2021-02-06 13:19:30 +01:00
Upon live deployment, deploy script also pings search engines. GitHub requires the following environment variables to be setup for successful deployments in the repository secrets:
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_DEFAULT_REGION`
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
2019-11-26 02:18:54 +01:00
**© Copyright 2019 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)