Benjamin Oddou Photographe
Welcome to the repository of my personal website dedicated to Photography
π¦Ύ
Main Technologies
Design
Front-End
Nuxt 3
Tailwind CSS
GSAP with Premium Shockingly Green Plugins
ImageKit CDN
Photoswipe
Vue Masonry Wall
Back-End
IDE and Production
β¨
Code Usage and Contribution
Code Usage
The project is open source so you can use part of the code but not entirely. Also, don't use the style (CSS and assets) as it is personnal and makes this website unique.
This code is under MIT Licence
Contribute
To contribute to the project, you can read the Contributing document and the Code of Conduct
π¨βπ»
Environment (for OSX or Linux)
NVM
Install nvm. Open the terminal
and run one of the following :
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
To verify that nvm has been installed, do:
command -v nvm
Node.js and npm
Install node.js using nvm by running :
# the last stable version like 16.17.0
nvm install
To display a list of node.js versions that are installed on your machine, enter:
nvm ls
Switch versions by passing the version the same way you do when installing:
# version like 18.12.1
nvm use
Check the node.js and npm versions by running :
node -v
npm -v
To get the latest LTS version of node and migrate your existing installed packages, use :
nvm install 'lts/*' --reinstall-packages-from=current
To get the the latest version of npm, use one of the following command :
nvm install-latest-npm
npm install -g npm@latest
VSCode
- Install Visual Studio Code
- Install the following extensions :
π οΈ
Setup
Command-line interface (CLI)
Always reinstall CLI packages after changing the node version
Dotenv CLI
Install the dotenv cli globally by running :
npm install -g dotenv-cli
Use env variables
(e.g. API keys) by creating a .env
file at the root of the project
Quicktype CLI
Install the quicktype cli globally by running :
npm install -g quicktype
Use quicktype
to generate a strongly typed API response :
quicktype --src tmp/imgkit.json --top-level ImageKit --just-types --nice-property-names --acronym-style pascal --lang ts -o tmp/tmp.ts
To run after generating the proper
.json
file
- Use the cURL command to download a sample response under
tmp
folder. - Run
quicktype
command to generate atmp.ts
file and copy it under the global declartion of./types/imgkit.d.ts
// ./types/imgkit.d.ts
export {}
declare global {
// Copy Code Here
}
Packages
Copy the current repo locally and install all node_modules
via the following command :
dotenv npm install
GitHub Hooks
Install Husky to perform actions when commiting or pushing code to GitHub :
# Create .husky folder
npx husky-init
π
Scripts
Documentation)
Nuxt API commands (seeRun development server
# it will run "npx nuxi dev"
npm run dev
Build / Generate the app
Build the app without prerendering pages
# it will run "npx nuxi build"
npm run build
Build the app and prerender all .vue
files into .html
static files
# it will run "npx nuxi generate"
npm run generate
Preview the app
Preview the built / generated app
# it will run "npx nuxi preview"
npm run preview
Upgrade nuxt version
Using directly npx
# please don't use `-f` | `--force` parameter
npx nuxi upgrade
Remove manually
node_modules
andpackage-lock.json
after upgrade and rundotenv install
Update npm packages
- Using npm command
dotenv npm update
Note that by default
npm update
will not update the semver values of direct dependencies in the projectpackage.json
- Using npm-check-updates to force package.json to update to latest version (recommended)
# it will run "npx --yes npm-check-updates -u"
dotenv npm run upck
Run
dotenv npm install
instead of the proposednpm install
in order to use.env
variables
Format the code
Run globally ESLint on the project to format the code.
# it will run "eslint . --fix"
npm run eslint-fix
Push a release on GitHub
Semantic versioning
Semantic Versioning (SemVer) is a de facto standard for code versioning. It specifies that a version number always contains these three parts :
- MAJOR version is incremented when you add breaking changes, e.g. an incompatible API change
- MINOR version when you add functionality in a backwards compatible manner
- PATCH version when you make backwards compatible bug fixes
First Release
To generate the changelog for the first release, run:
# npm run script
npm run release -- --first-release
GitHub Hooks
# Enable Git Hooks
npm run prepare
# it will run "standard-version -a"
npm run release
# it will run "standard-version -a --release-as patch"
npm run release:patch
# it will run "standard-version -a --release-as minor"
npm run release:minor
# it will run "standard-version -a --release-as major"
npm run release:major
See GitHub repo of Standard Version
Create a performance report
Run Unlighthouse to scan an entire website (to define in package.json
file) with Google LighthouseοΈ
# it will run "npx unlighthouse --site https://www.benjaminoddou-photographe.com"
npm run lighthouse
Print the structure of the project
# using -a to list all files, L <level> to define the depth of the tree and -I <pattern> to ignore patterns
tree -a -L 1 --charset utf-8
check the Documentation by running :
tree --help
Encoding API key to Base64
- Create a file named
my.key
with aprivate API key
at the root of the project - Launch the following script to encode the API key
openssl enc -base64 -in my.key -out my.key.base64
The output looks like this:
ImageKit API
Fetch Data from Using cURL
curl -X GET "https://api.imagekit.io/v1/files?<query>" \-u <private_API_key>: | json_pp > tmp/imgkit.json
curl "https://api.imagekit.io/v1/files?<query>" \-H 'Authorization: Basic <Base64_private_API_key>' | json_pp > tmp/imgkit.json
json_pp is used to format JSON.
π¨ Output directory must exists (tmp folder here)
The two command lines output the same result. To see the different options for the <query>
, check the documentation that can be found here
Nuxt 3
Using API endpoint and $fetch / useFetch() composable from // In nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
IMAGEKIT_B64_API: process.env.IMAGEKIT_B64_API, // Defined in .env file
public: {
// public keys here
}
},
})
// In server/api/imgkit.ts
export default defineEventHandler(async () => {
const config = useRuntimeConfig()
const response = await $fetch('https://api.imagekit.io/v1/files', {
method: 'GET',
headers: {
Authorization: 'Basic ' + config.IMAGEKIT_B64_API
}
})
return response
})
// In pages/components
<script setup>
const { data: images } = useFetch<ImageKit[]>('/api/imgkit')
</script>
ποΈ
Structure
Generated with tree
.
βββ .commitlintrc.json # Commitlint configuration file
βββ .env # Environment variables (not in GitHub repo - private π€)
βββ .eslintrc.json # ESLint config file
βββ .github # Assets for GitHub repo
βββ .netlify # netlify edge / internal functions (not in GitHub repo β)
βββ .gitignore # List of files that should be ignore by Git
βββ .husky # husky config folder (GitHub hooks)
β βββ _ # generated by husky init command
β β βββ .gitignore
β β βββ husky.sh
β βββ commit-msg # Commitlint with Github hooks
βββ .npmrc # Npm config file with GSAP connexion to private repository
βββ .nuxt # Nuxt uses the .nuxt/ directory in development to generate Vue application (not in GitHub repo β)
βββ .output # Nuxt creates the .output/ directory when building the application for production. (not in GitHub repo β)
βββ .versionrc.json # Changelog format configuration file
βββ .vscode
β βββ settings.json # VSCode local settings
βββ README.md # This document π
βββ app.vue # entry point and general backbone of the app. This is the main component in Nuxt 3 applications
βββ assets # The assets/ directory is used to add all the website's assets that the build tool (Vite) will process.
β βββ css
β β βββ tailwind.css # Tailwind directives
β βββ pwa-512x512.png # PWA Icon
β βββ svgs # svgs used in the website
β β βββ checkmark.svg
βββ components # The components/ directory is where all Vue components can be imported inside pages or other components
β βββ FAQquestion.vue
β βββ TheAlert.vue
β βββ theAwwwards.vue
β βββ theCursor.vue
β βββ theFooter.vue
β βββ theForm.vue
β βββ theHeader.vue
β βββ theImgDrag.vue
β βββ theMenu.vue
β βββ TheMenuLink.vue
β βββ thePreloader.vue
β βββ theTransition.vue
βββ composables # Auto imported functions
β βββ piniaStore.ts # State Management store functions
β βββ utils.ts # Helper functions
βββ dist # folder with built website (not in GitHub repo β)
βββ node_modules # All modules installed by npm (not in GitHub repo β)
βββ CHANGELOG.md # File that tracks all changes
βββ CODE_OF_CONDUCT.md # Code of conduct
βββ CONTRIBUTING.md # Contributing guide
βββ LICENSE # MIT License
βββ netlify.toml # Configuration file for netlify
βββ nuxt.config.ts # Nuxt configuration file
βββ package-lock.json # Aggregates an immutable version of the package.json file
βββ package.json # Contains all the dependencies and scripts of the application
βββ pages # All pages belongs here. Nuxt provides a file-based routing to create routes within the app using Vue Router under the hood.
β βββ [...slug].vue # catch all route (404 not founf)
β βββ about.vue # About page
β βββ gallery.vue # Gallery page
β βββ index.vue # Home page
βββ plugins # All Nuxt and Vue plugins
β βββ vue-masonry-wall.ts # Vue masonry plugin
βββ public # files that shouldn't be processed by build tool (Vite)
β βββ _redirects # redirects rules for Netlify
β βββ banner.jpg
β βββ browserconfig.xml
β βββ favicon.ico
β βββ me.jpg
β βββ mstile-150x150.png
β βββ robots.txt
β βββsafari-pinned-tab.svg
βββ server # Directory which register API and server handlers (Nitro routes) with HMR support
β βββ api
β β βββ imgkit.ts # ImageKit API endpoint (act as proxy)
β βββ routes
β β βββ sitemap.xml.ts # Sitemap generator
βββ tmp # Temporary files to perform tests on API
β βββ .gitkeep # empty hidden file to keep tmp folder in GitHub repo
β βββ imgkit.json # Sample data from ImageKit cURL command (not in GitHub repo β)
β βββ tmp.ts # Output typescript API generated with quicktype command (not in GitHub repo β)
βββ types # Typescript declaration
β βββ imgkit.d.ts # Declaration file for ImageKit API
βββ tailwind.config.js # Tailwind config file
βββ tsconfig.json # File that references .nuxt/tsconfig.json which resolved aliases used in a Nuxt project
π
Deploy
The hosting of the website is made available by connecting this GitHub repository to
Netlify.
When deploying, the command script
and environment variable(s)
needs to be defined under Build & deploy | Site settings
on Netlify.
Command scripts :
# Classic SSR build
npm run build
# Prerendering routes to optimize SEO and response time
npm run generate
βοΈ Nitro used byNuxt 3 will detect automatically
Netlify hosting and deploy with preset='netlify'
Environment variable(s) :
βοΈ
License
MIT License Β© Benjamin Oddou