This project is a React-based menu component for the Alzgo application. It includes multiple modules that are deployed and used on the alzgo.fr website, utilizing Vite for the build process and Tailwind CSS for styling.
src/: Contains the source code for the project.modules/: React modules for different web islands.utils/: Utility functions used across the project.index.css: Global CSS file.types.ts: TypeScript type definitions.
public/: Static files that are served directly.assets/: SVG assets for various menu icons.icons/: PNG icons for navigation.
pages/: HTML mockups that are used in development.vite.config.ts: Vite configuration file.tsconfig.json: TypeScript configuration file.eslint.config.js: ESLint configuration file.vercel.json: Vercel deployment configuration.
dev: Start the development server.build: Build the project for production.lint: Run TypeScript, Prettier, and ESLint checks.lint:prettier: Run Prettier checks.preview: Preview the production build.
The project uses Vite for environment variable management. Environment variables are defined in .env files and can be accessed using imports from 'utils/env'.
You can use the model from '.env.example' to create your own .env file.
VITE_BASE_URL: Base URL for the application.
VITE_MENU_SELECTOR: CSS selector for the main menu element.VITE_MENU_ROOT_ID: ID for the main menu root element.
VITE_MENU_MOBILE_SELECTOR: CSS selector for the mobile menu element.VITE_MENU_MOBILE_ROOT_ID: ID for the mobile menu root element.
The menu items are parsed from the DOM using a custom utility function. The parseMenu function takes the HTML content of the navigation element and converts it into a JSON structure. This JSON structure is then enhanced with additional properties like id, to, and img using the enhanceMenuWithCustomKeys function.
import parseMenu from './utils/dom-parser';
import { enhanceMenuWithCustomKeys } from './utils/compute-menu-items';
const menuEl = document.querySelector('nav');
const menuJSON = parseMenu(menuEl?.outerHTML || '');
const navbarData = enhanceMenuWithCustomKeys(menuJSON);
console.log(navbarData);This mechanism allows for dynamic generation of the menu structure based on the HTML content, making it easy to update the menu without changing the code.
This project is deployed on Vercel. The main branch is used for development, and the production branch is used for production deployments.
main: Development branch. All new features and bug fixes are merged here.production: Production branch. Only stable and tested code is merged here for deployment.
- Push changes to the
mainbranch for development. - Once the changes are tested and stable, create a pull request to merge
mainintoproduction. - After the pull request is approved and merged, Vercel will automatically deploy the changes to the production environment.
- Clone the repository:
git clone https://github.com/sakuga-software/alzgo.git
- Navigate to the project directory:
cd alzgo - Install dependencies:
pnpm install
- Create a
.envfile based on the.env.examplefile:cp .env.example .env
- Start the development server:
pnpm dev
- Build the project for production:
pnpm build
- Preview the production build:
pnpm preview