This project uses MkDocs Material to create a beautiful, responsive documentation website for competitive programming techniques and algorithms, hosted on Firebase with analytics.
-
Install dependencies:
# Install Python dependencies npm run install:python # Install Firebase CLI npm run install:firebase # Or install everything at once npm run setup
-
Verify installations:
mkdocs --version firebase --version
- Go to Firebase Console
- Click "Create a project"
- Enter project name:
comp-prog - Enable Google Analytics (recommended)
- Choose or create a Google Analytics account
- Hosting: Go to Hosting section and click "Get started"
- Analytics: Already enabled if you selected it during project creation
# Login to Firebase
firebase login
# Initialize Firebase (select Hosting when prompted)
firebase init
# Or use the existing configuration files
# (firebase.json and .firebaserc are already created)- Go to Firebase Console → Project Settings → General
- Copy your Web App's Firebase config
- Set the
GOOGLE_ANALYTICS_KEYenvironment variable:# Windows set GOOGLE_ANALYTICS_KEY=your-analytics-key # Linux/Mac export GOOGLE_ANALYTICS_KEY=your-analytics-key
Start the development server to preview your documentation:
# Standard development server
npm run serve
# Development server accessible from all interfaces
npm run devThe site will be available at http://127.0.0.1:8000/
To build the static site with versioned service worker and PWA manifest:
# Build everything (MkDocs + Service Worker + Manifest)
npm run build
# Or use the Python build script (recommended)
python build.py
# Or use platform-specific scripts
build.bat # Windows
./build.sh # Unix/Mac
# Build only MkDocs
npm run build:mkdocs
# Generate only service worker (after MkDocs build)
npm run build:swThe built site will be in the site/ directory with:
- A dynamically generated service worker
- PWA manifest links added to all HTML pages
- Theme color meta tags for mobile browsers
The build process automatically:
- Builds the MkDocs site - Generates static HTML from markdown
- Adds PWA manifest links - Injects manifest and theme tags into all HTML pages
- Generates service worker - Creates a versioned SW with caching
- Dynamic Versioning: Each build generates a unique cache version
- Automatic File Discovery: Scans the built site for all cacheable files
- Smart Caching: Only caches relevant file types (HTML, CSS, JS, images, fonts)
- Cache Management: Automatically cleans up old cache versions
- Offline Support: Serves cached content when offline
- Manifest Integration: Updates manifest.json with version information
- Auto-linking: Manifest is automatically linked in all HTML pages
- Theme Colors: Mobile browser theme colors configured
- App Icons: Multiple icon sizes for different devices (192x192, 512x512)
- Install Prompt: Users can install the site as a Progressive Web App
The service worker is generated in scripts/build-sw.js and includes:
- Precaching of all static assets
- Cache-first strategy for performance
- Network fallback for dynamic content
- Offline page for navigation requests
- Background sync and push notification support
The project uses a specific file organization to handle the build process:
docs/
├── assets/
│ ├── images/ # All images (favicons, icons, diagrams)
│ │ ├── favicon.ico
│ │ ├── favicon.png
│ │ ├── icon-192.png
│ │ └── icon-512.png
│ ├── css/ # Custom stylesheets
│ └── js/ # Custom JavaScript
├── manifest.json # PWA manifest (copied to site/)
├── offline.html # Offline page (copied to site/)
└── overrides/ # MkDocs template overrides
site/ # Generated by MkDocs (cleared on each build)
├── assets/ # Copied from docs/assets/
├── manifest.json # Copied from docs/manifest.json
├── offline.html # Copied from docs/offline.html
└── sw.js # Generated by build-sw.js
Important Notes:
- The
site/directory is completely regenerated on each build - Source files (
manifest.json,offline.html) are stored indocs/ - MkDocs copies these files to
site/using theextra_filesconfiguration - The service worker is generated after MkDocs build completes
-
Build and deploy:
# One command to build and deploy npm run deploy # Or manually: npm run build firebase deploy --only hosting
-
Preview deployment:
npm run preview
-
Your site will be available at:
https://comp.mendez.codes(custom domain)https://comp-prog.web.app(Firebase default)https://comp-prog.firebaseapp.com(Firebase default)
- Enable GitHub Pages in your repository settings
- Deploy automatically:
mkdocs gh-deploy
The site/ directory contains static files that can be deployed to any web server or CDN.
# Development
npm run serve # Start development server
npm run dev # Start dev server on all interfaces (0.0.0.0:8000)
npm run build # Build MkDocs and generate versioned service worker
npm run build:mkdocs # Build MkDocs site only
npm run build:sw # Generate service worker only
# Deployment
npm run deploy # Build and deploy to Firebase
npm run preview # Preview Firebase deployment locally
# Setup & Maintenance
npm run setup # Install Python and Firebase dependencies
npm run install:python # Install Python dependencies only
npm run install:firebase # Install Firebase CLI only
npm run clean # Remove build directory (Unix/Mac)
npm run clean:win # Remove build directory (Windows)
# Quality Assurance
npm run lint # Lint markdown files
npm run test # Build with strict mode for testing
npm run help # Show all available commandsdocs/
├── index.md # Homepage
├── brute-force/ # Brute Force & Search Enumeration
│ ├── index.md
│ ├── boolean-counter.md
│ ├── recursive-backtracking.md
│ ├── meet-in-middle.md
│ └── permutation-enumeration.md
├── counting/ # Counting, Frequency, and Precomputation
│ ├── index.md
│ ├── frequency-arrays.md
│ ├── prefix-arrays.md
│ └── sieve-eratosthenes.md
├── dynamic-programming/ # Dynamic Programming
│ ├── index.md
│ ├── top-down-bottom-up.md
│ ├── bitmask-dp.md
│ └── dp-trees-graphs.md
├── graph-modeling/ # Graph & Network Modeling
│ ├── index.md
│ ├── dfs-bfs.md
│ ├── dijkstra-bellman-ford.md
│ └── union-find.md
├── geometry/ # Geometry & Spatial Modeling
│ ├── index.md
│ ├── sweep-line.md
│ └── convex-hull.md
├── string-bitwise/ # String & Bitwise Techniques
│ ├── index.md
│ ├── kmp-z-algorithm.md
│ ├── trie-aho-corasick.md
│ └── bitmask-tricks.md
├── simulation/ # Simulation & Modeling
│ ├── index.md
│ ├── two-pointer-sliding-window.md
│ ├── binary-search-answer.md
│ └── greedy-algorithms.md
└── data-structures/ # Data Structures
├── index.md
├── segment-tree-bit.md
├── heap-priority-queue.md
└── disjoint-set.md
Edit mkdocs.yml to customize:
- Colors and palettes
- Navigation structure
- Features and plugins
- Markdown extensions
- Create a new markdown file in the appropriate category directory
- Add the page to the navigation in
mkdocs.yml - Follow the existing format for consistency
The site uses Material Design principles. You can customize:
- Colors in the
theme.palettesection - Features in the
theme.featuressection - Additional CSS in a custom stylesheet
- Responsive Design: Works on desktop, tablet, and mobile
- Dark/Light Mode: Automatic theme switching
- Search: Built-in search functionality
- Code Highlighting: Syntax highlighting for multiple languages
- Navigation: Sticky navigation with tabs and sections
- Copy Code: One-click code copying
- Git Integration: Shows last modified dates
- Firebase Hosting: Fast, secure, and reliable hosting
- Analytics: Track visitor engagement and popular content
- Custom Domain: Easy to set up custom domain
- CDN: Global content delivery network
- SSL: Automatic HTTPS encryption
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with
npm run serve - Run tests with
npm run test - Submit a pull request
This project is open source and available under the MIT License.