Welcome to the repository of my personal website dedicated to Photography πΈ
- Nuxt 3
- Tailwind CSS
- GSAP with Premium Shockingly Green Plugins
- ImageKit CDN
- Photoswipe
- Vue Masonry Wall
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 personal and makes this website unique.
This code is under MIT Licence βοΈ
To contribute to the project, you can read the Contributing document and the Code of Conduct π
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 | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
To verify that nvm has been installed, do:
command -v nvm
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
- Install Visual Studio Code
- Install the following extensions :
Always reinstall CLI packages after changing the node version
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
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
}
Copy the current repo locally and install all node_modules
via the following command :
dotenv npm install
Install Husky to perform actions when commiting or pushing code to GitHub :
# Create .husky folder
npx husky-init
Nuxt API commands (see Documentation)
# it will run "npx nuxi dev"
npm run dev
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 built / generated app
# it will run "npx nuxi preview"
npm run preview
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
- 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
Run globally ESLint on the project to format the code.
# it will run "eslint . --fix"
npm run eslint-fix
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
To generate the changelog for the first release, run:
# npm run script
npm run release -- --first-release
# 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
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
# 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
- 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:
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
// 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>
Generated with tree
.
βββ .commitlintrc.json # Commitlint configuration file
βββ .env # Environment variables (not in GitHub repo - private π€)
βββ .eslintrc.json # ESLint config file
βββ .git # All git info
βββ .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
β βββ svg # Non interactive svgs
β β βββ checkmark.svg
β β βββ ...svg
βββ components # The components/ directory is where all Vue components can be imported inside pages or other components
β βββ svg # Interactive svg build as vue components
β β βββ ArrowButton.vue
β β βββ ...svg
β βββ FAQquestion.vue
β βββ TheAlert.vue
β βββ TheCursor.vue
β βββ ...vue
βββ utils # Auto imported functions
β βββ piniaStore.ts # State Management store functions
β βββ index.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-setup.sh # Use SSH key in netlify
βββ 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
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 by Nuxt 3 will detect automatically Netlify hosting and deploy with preset='netlify'
Environment variable(s) :
MIT License Β© Benjamin Oddou