Thank you for considering contributing to pheralb/code-blocks! This guide will help you get started with the process of contributing to the project.
-
Click here to fork the repository on GitHub.
-
Clone your forked repository to your local machine:
git clone git@github.com:your_username/code-blocks.git- Navigate to the project directory:
cd code-blocks- Install pnpm if you haven't already:
npm install pnpm@latest -g
# Check if pnpm is installed correctly
pnpm -vMake sure you have Node.js +22 installed. Click here to download the latest version.
- Install the dependencies:
pnpm i- Start the development server:
pnpm devand open http://localhost:3000 in your browser to see the documentation site.
All the components are located in the apps/website/src/components/code-block directory.
The folder structure is organized as follows:
- 📁 blocks
- 📁 client
- 📁 mdx
- ⚛️ code-block.tsx
- ⚛️ copy-button.tsx
⚛️ code-block.tsx: The main code block component structure with header, group and content area.📁 blocks:📁 client&⚛️ code-block.tsxwith extended features, for example, multi-tabs, select package manager...📁 client: (⚛️ code-block.tsx) with syntax highlighting rendered on the client.📁 mdx:<pre>element with (⚛️ code-block.tsx) and syntax highlighting config.
-
Create a new file for your component in the appropriate directory (e.g.,
apps/website/src/components/code-block/blocks). If they are elements within code-block, you can create it outside in /code-blocks (e.g.,copy-button.tsx). -
Create a preview of your component in the
apps/website/src/components/previews. -
Go to the registry data file
apps/website/src/components/registry/data.tsxand add an entry for your new component.
reactComponentis used for the live preview, import the component that you create in step 2.
- Create the documentation for your component in the
apps/website/src/docs/reactdirectory. Add the following metadata to the top of your documentation file:
---
title: ""
description: ""
category: [""]
---The utilities are located in the apps/website/src/utils directory.
The folder structure is organized as follows:
- 📁 shiki
- 📁 sugar-high
📁 shiki: Shiki highlighter utility with custom transformers.📁 sugar-high: Sugar-high highlighter utility.
-
Create a new file for your utility in the appropriate directory (e.g.,
apps/website/src/utils/shiki). -
Create the documentation for your utility in the:
- Shiki:
apps/website/src/docs/shiki. - Sugar-High:
apps/website/src/docs/sugar-high.
and add the following metadata to the top of your documentation file:
---
title: ""
description: ""
category: [""]
---- After making your changes, commit them using Conventional Commits format:
git add .
git commit -m "feat: add new code block component"- Push your changes to your forked repository:
git push origin main- Go to the original repository on GitHub and create a new pull request from your forked repository.
Thank you for contributing to pheralb/code-blocks. We look forward to reviewing your pull request and merging your changes into the main project 🚀