Prerequisites
Before you begin, ensure you have the following installed:Bun
CodeInk uses Bun as its JavaScript runtime and package managerInstall Bun
Node.js 18+
Optional but recommended for compatibilityInstall Node.js
Quick Start
Install dependencies
Install all required dependencies using Bun:This will install all packages defined in
package.json, including:- Astro framework and integrations
- CodeMirror editor and extensions
- Markdown processing libraries (marked, remark)
- Syntax highlighting (Shiki)
- Math rendering (KaTeX) and diagrams (Mermaid)
Start the development server
Launch the development server:The development server will start at:The server supports hot module replacement (HMR), so changes to your code will be reflected immediately in the browser.
Open in browser
Navigate to http://localhost:4321 in your web browser to see CodeInk running locally.
Available Scripts
CodeInk provides several npm scripts for development and production:Project Structure
After cloning, your project directory will look like this:Development Workflow
Making Changes
- Edit components in
src/components/orsrc/pages/ - Modify styles in
src/styles/ - Update scripts in
src/scripts/
Type Checking
Run type checking before committing:Building for Production
Create an optimized production build:- Type checks all TypeScript files
- Bundles JavaScript with Vite
- Optimizes assets (images, CSS, fonts)
- Code splits vendor libraries:
vendor-codemirror: CodeMirror editorvendor-marked: Markdown parservendor-remark: Markdown linter
- Generates server-side rendered pages
dist/ directory.
Preview Production Build
Test the production build locally:Environment Configuration
CodeInk runs entirely client-side with no environment variables required for development.Deployment Configuration
For production deployment to Cloudflare Pages, the following configuration is used:wrangler.toml
Troubleshooting
Port 4321 is already in use
Port 4321 is already in use
If port 4321 is taken, Astro will automatically try the next available port. You can also specify a custom port:
Dependencies fail to install
Dependencies fail to install
Try clearing Bun’s cache and reinstalling:
TypeScript errors in editor
TypeScript errors in editor
Ensure your editor is using the workspace TypeScript version:VS Code: Press
Cmd+Shift+P and select “TypeScript: Select TypeScript Version” → “Use Workspace Version”Changes not reflecting in browser
Changes not reflecting in browser
- Hard refresh the browser (
Cmd+Shift+RorCtrl+Shift+R) - Restart the development server
- Clear browser cache and IndexedDB
Next Steps
Architecture
Learn about CodeInk’s technical architecture
Code Structure
Explore the codebase organization
Contributing
Start contributing to CodeInk