Skip to content

Commit 06e4987

Browse files
committed
Update guidelines for new storage system
1 parent 711b560 commit 06e4987

File tree

2 files changed

+144
-97
lines changed

2 files changed

+144
-97
lines changed

CONTRIBUTING.md

+119-79
Original file line numberDiff line numberDiff line change
@@ -13,121 +13,161 @@ You can contribute in two main ways:
1313

1414
If you have a feature request or want to fix a bug, feel free to:
1515

16-
- [Open an Issue](https://github.com/dostonnabotov/quicksnip/issues) to let me know what’s up.
17-
- [Send a pull request](https://github.com/dostonnabotov/quicksnip/pulls) with your changes.
16+
- [Open an Issue](https://github.com/dostonnabotov/quicksnip/issues) to let us know what’s up.
17+
- [Send a Pull Request](https://github.com/dostonnabotov/quicksnip/pulls) with your changes.
1818

1919
---
2020

2121
## Adding Snippets
2222

23-
### Adding to an Existing Category
23+
### Adding a New Snippet
2424

25-
1. **Find the language file:**
25+
To add a new code snippet:
2626

27-
Head over to the `/public/data` folder and locate the language file you need, like javascript.json or python.json
27+
1. **Navigate to the relevant folder:**
28+
29+
- Go to the `/snippets` folder in the root directory.
30+
- Locate the folder for the programming language of your snippet, such as `javascript` or `python`.
2831

29-
2. **Find the category:**
32+
2. **Choose the correct category:**
3033

31-
Look for the categoryName where your snippet belongs.
34+
- Within the language folder, find the relevant category folder for your snippet.
35+
- If no suitable category exists, refer to [Adding a New Category](#adding-a-new-category).
3236

33-
3. **Add your snippet** in this format:
37+
3. **Create a markdown file:**
3438

35-
```json
36-
{
37-
"title": "Name of the snippet",
38-
"description": "A short explanation of what the snippet does",
39-
"code": [
40-
"your code goes here",
41-
" this is a newline with a space"
42-
],
43-
"tags": ["tag1", "tag2", "tag3"],
44-
"author": "your_github_username"
45-
}
39+
- Create a new file with a `.md` extension.
40+
- Name the file appropriately, keeping it descriptive and concise.
41+
42+
4. **Add your snippet:**
43+
44+
- Use the following format to structure your snippet:
45+
46+
```md
47+
---
48+
title: Name of the snippet
49+
description: A short explanation of what the snippet does
50+
tags: tag1, tag2, tag3
51+
author: your-github-username
52+
---
53+
54+
// Your code here
4655
```
4756

4857
Here’s an example for JavaScript:
4958

50-
```json
51-
// javascript.json
52-
[
53-
{
54-
"categoryName": "Date and Time",
55-
"snippets": [
56-
{
57-
"title": "Format Date",
58-
"description": "Formats a date in 'YYYY-MM-DD' format.",
59-
"code": [
60-
"const formatDate = (date) => date.toISOString().split('T')[0];",
61-
"",
62-
"// Usage:",
63-
"console.log(formatDate(new Date())); // Output: '2024-12-10'"
64-
],
65-
"tags": ["javascript", "date", "format"],
66-
"author": "technoph1le"
67-
}
68-
]
69-
}
70-
]
7159
```
60+
---
61+
title: Format Date
62+
description: Formats a date in 'YYYY-MM-DD' format.
63+
author: dostonnabotov
64+
tags: javascript,date,format,utility
65+
---
7266
73-
### Adding a New Category
67+
const formatDate = (date) => date.toISOString().split('T')[0];
7468
75-
If your snippet doesn’t fit into any existing category, you can create a new one! Just make sure it’s unique and doesn’t overlap with others (e.g., don’t create separate categories for “Date” and “Time” when “Date and Time” works).
69+
// Usage:
70+
console.log(formatDate(new Date())); // Output: '2024-12-10'
71+
```
7672

77-
Use this format:
78-
79-
```json
80-
[
81-
{
82-
"categoryName": "New Category Name",
83-
"snippets": [
84-
{
85-
"title": "Name of the snippet",
86-
"description": "A short explanation of what it does",
87-
"code": [
88-
"your code goes here",
89-
" this is a newline with a space"
90-
],
91-
"tags": ["tag1", "tag2", "tag3"],
92-
"author": "your_github_username"
93-
}
94-
]
95-
}
96-
]
73+
5. **Use syntax highlighting:**
74+
- Enclose your code with triple backticks (```).
75+
- Specify the language after the first set of backticks for syntax highlighting.
76+
77+
![snippet code example in markdown file](https://github.com/user-attachments/assets/be650cfe-fd17-49e7-ae82-e1c88e30d4c9)
78+
79+
6. **Test your snippet:**
80+
- Ensure your code runs as expected.
81+
82+
Expected structure:
83+
84+
```txt
85+
snippets
86+
|- language
87+
|- category
88+
|- your-snippet-here.md
9789
```
9890

99-
### Adding a New Language
91+
### Editing a Existing Snippet
10092

101-
Want to include a new programming language? Here's what to do:
93+
If you’d like to refine or improve an existing snippet:
10294

103-
1. **Create a new file:**
95+
1. **Add a `contributors` field:**
10496

105-
In the `/public/data` folder, create a file named after the language (e.g., `go.json`).
97+
- Include your GitHub username under the `contributors` field in the metadata section.
10698

107-
2. **Add categories and snippets:**
99+
```md
100+
---
101+
title: Name of the snippet
102+
description: A short explanation of what the snippet does
103+
tags: tag1, tag2, tag3
104+
author: original-author
105+
contributors: your-github-username
106+
---
107+
108+
Updated code here
109+
```
110+
111+
2. **Credit all contributors:**
108112

109-
Follow the formats explained above.
113+
- If contributors already exist, add your username separated by a comma
110114

111-
3. **Update the `_index.json`:**
115+
```md
116+
contributors: contributor1, contributor2, your-github-username
117+
```
118+
119+
3. **Document changes:**
120+
121+
Clearly indicate what you updated and why in your pull request description.
122+
123+
We want to make sure that original author and contributor(s) are credited for their work.
124+
125+
126+
### Adding a New Category
127+
128+
If your snippet doesn’t fit into any existing category, you can create a new one! Just make sure it’s unique and doesn’t overlap with others (e.g., don’t create separate categories for “Date” and “Time” when “Date and Time” works).
129+
130+
1. **Create a new category folder:**
131+
132+
- In the relevant language directory, add a new folder.
133+
- Use a lowercase name with hyphens for separation (e.g., `file-handling`).
112134

113-
Add your new language like this:
135+
2. **Add snippets:**
114136

115-
```json
116-
[
117-
{
118-
"lang": "Go",
119-
"icon": "/icons/go.svg"
120-
}
121-
]
137+
- Follow the [Adding a New Snippet](#adding-a-new-snippet) instructions.
138+
139+
140+
Example structure:
141+
142+
```md
143+
/snippets
144+
|_ python
145+
|_ file-handling
146+
|_ list-manipulation
147+
|_ ....
122148
```
123149

150+
### Adding a New Language
151+
152+
If you want to introduce a new programming language, here's how to do it:
153+
154+
1. **Create a language folder:**
155+
156+
- Add a new folder under the `snippets` directory.
157+
- Name it after the language in lowercase (e.g., `go`, `ruby`).
158+
159+
2. **Add categories and snippets:**
160+
161+
- Follow the [Adding a New Snippet](#adding-a-new-snippet) and [Adding a New Category](#adding-a-new-category) guidelines.
162+
124163
4. **Include an icon:**
125164

126-
Upload a logo for your language into the `/public/icons` folder. Make sure the filename matches the one you used in `_index.json`. Icons should be 50x50px in `.svg` format.
165+
- Add an `icon.svg` file (50x50px) in the same language folder.
166+
- Use tools like [Resize SVG](https://www.iloveimg.com/resize-image/resize-svg) to ensure the correct size.
127167

128168
5. **Double-check your work:**
129169

130-
Test on your side and confirm if it works properly.
170+
- Verify that everything is structured correctly and displays as intended.
131171

132172
---
133173

README.md

+25-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Want to help make QuickSnip even better? You can contribute by:
1616

1717
- **Improving the Code**: Fix bugs, suggest new features, or optimize the project.
1818
- **Adding New Snippets**: Share your favorite snippets to grow the database.
19-
Be sure to check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file for detailed guidelines.
19+
20+
Be sure to check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file for detailed guidelines.
2021

2122
### Improving the code
2223

@@ -27,30 +28,36 @@ Got a feature idea or bug fix? Here's how you can contribute:
2728

2829
### Adding a Snippet
2930

30-
The snippets database is located in the `/public/data` folder.
31-
32-
If you’d like to add a snippet for an **existing language** and **category**, use the following format:
33-
34-
```json
35-
{
36-
"title": "Name of the snippet",
37-
"description": "A short explanation of what the snippet does",
38-
"code": [
39-
"your code goes here",
40-
" this is a newline with a space"
41-
],
42-
"tags": ["tag1", "tag2", "tag3"],
43-
"author": "your_github_username"
44-
}
31+
The snippets database is located in the `/snippets` folder.
32+
33+
1. Find the relevant language folder.
34+
35+
2. Locate the appropriate category folder for your snippet.
36+
37+
3. Create a markdown file and add your snippet using the following format:
38+
39+
```md
40+
---
41+
title: Name of the snippet
42+
description: A short explanation of what the snippet does
43+
tags: tag1, tag2, tag3
44+
author: your-github-username
45+
---
46+
47+
// Your code here
4548
```
4649

47-
For details about adding new categories or programming languages, check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file.
50+
Here's an example for JavaScript:
51+
52+
![code example in markdown file](https://github.com/user-attachments/assets/dba9fda3-76fe-4d92-b12a-8bc065286b90)
53+
54+
For more details about adding new categories or programming languages, check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file.
4855

4956
## Guidelines for Contributions
5057

5158
To keep things smooth and consistent, please:
5259

53-
- Use proper JSON formatting.
60+
- Follow the formatting rules described above.
5461
- Include all mandatory fields in the snippet.
5562
- Test your snippet to ensure it works as expected.
5663

0 commit comments

Comments
 (0)