Skip to content

Commit 2e377e5

Browse files
authored
Merge branch 'main' into feature-framer
2 parents 647633c + f1f3b6a commit 2e377e5

File tree

250 files changed

+9019
-7973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+9019
-7973
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/src/ @psychlone77 @saminjay
88

99
# Snippets maintainers
10-
/public/data @Mathys-Gasnier
10+
/snippets @Mathys-Gasnier
1111

1212

1313
# ---------- What is a maintainer ----------

.github/workflows/check-snippets.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Checks snippets syntax
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'snippets/**'
7+
8+
jobs:
9+
check-snippets:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 22
24+
25+
- name: Check if snippets are formated correctly
26+
uses: int128/comment-action@v1
27+
with:
28+
run: node utils/checkSnippetFormatting.js # Run the script located in the utils/ folder
29+
post-on-failure: |
30+
## :x: Snippet Format Error
31+
${run.output}

.github/workflows/consolidate-snippets.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Consolidate JSON Files
33
on:
44
push:
55
paths:
6-
- "public/data/**"
6+
- "snippets/**"
77

88
permissions:
99
contents: write
@@ -14,25 +14,25 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818

1919
- name: Set up Node.js
20-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: "16"
22+
node-version: 22
2323

2424
- name: Install dependencies
2525
run: |
2626
npm install
2727
28-
- name: Consolidate JSON files
28+
- name: Consolidate Snippets
2929
run: |
30-
node utils/consolidate.js # Run the script located in the utils/ folder
30+
node utils/consolidateSnippets.js # Run the script located in the utils/ folder
3131
3232
- name: Commit and push changes
3333
run: |
3434
git config --global user.name "GitHub Action"
3535
git config --global user.email "[email protected]"
36-
git add public/consolidated/all_snippets.json
36+
git add public/consolidated/*
3737
git commit -m "Update consolidated snippets"
3838
git push

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
*.tsbuildinfo
1415

1516
# Editor directories and files
1617
.vscode/*

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
npm run lint
2+
npm run build

CONTRIBUTING.md

Lines changed: 123 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,121 +13,165 @@ 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/sass-template/issues) to let me know what’s up.
17-
- [Send a pull request](https://github.com/dostonnabotov/sass-template/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+
```lang
55+
// Your code here
4656
```
57+
````
4758

4859
Here’s an example for JavaScript:
4960

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-
]
61+
````md
62+
---
63+
title: Format Date
64+
description: Formats a date in 'YYYY-MM-DD' format.
65+
author: dostonnabotov
66+
tags: javascript,date,format
67+
---
68+
69+
```js
70+
const formatDate = (date) => date.toISOString().split('T')[0];
71+
72+
// Usage:
73+
console.log(formatDate(new Date())); // Output: '2024-12-10'
7174
```
75+
````
7276

73-
### Adding a New Category
77+
5. **Use syntax highlighting:**
78+
- Enclose your code with triple backticks (```).
79+
- Specify the language after the first set of backticks for syntax highlighting.
7480

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).
81+
6. **Test your snippet:**
82+
- Ensure your code runs as expected.
83+
84+
Expected file structure:
7685

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-
]
86+
```md
87+
/snippets
88+
|- language
89+
|- category-name
90+
|- your-snippet-here.md
9791
```
9892

99-
### Adding a New Language
93+
### Editing a Existing Snippet
10094

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

103-
1. **Create a new file:**
97+
1. **Add a `contributors` field:**
10498

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

107-
2. **Add categories and snippets:**
101+
````md
102+
---
103+
title: Name of the snippet
104+
description: A short explanation of what the snippet does
105+
tags: tag1, tag2, tag3
106+
author: original-author
107+
contributors: your-github-username
108+
---
108109

109-
Follow the formats explained above.
110+
```
111+
Updated code here
112+
```
113+
````
110114

111-
3. **Update the `_index.json`:**
115+
2. **Credit all contributors:**
112116

113-
Add your new language like this:
117+
- If contributors already exist, add your username separated by a comma
114118

115-
```json
116-
[
117-
{
118-
"lang": "Go",
119-
"icon": "/icons/go.svg"
120-
}
121-
]
119+
```md
120+
contributors: contributor1, contributor2, your-github-username
122121
```
123122

123+
3. **Document changes:**
124+
125+
Clearly indicate what you updated and why in your pull request description.
126+
127+
We want to make sure that original author and contributor(s) are credited for their work.
128+
129+
130+
### Adding a New Category
131+
132+
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).
133+
134+
1. **Create a new category folder:**
135+
136+
- In the relevant language directory, add a new folder.
137+
- Use a lowercase name with hyphens for separation (e.g., `file-handling`).
138+
139+
2. **Add snippets:**
140+
141+
- Follow the [Adding a New Snippet](#adding-a-new-snippet) instructions.
142+
143+
144+
Example structure:
145+
146+
```md
147+
/snippets
148+
|- python
149+
|- file-handling
150+
|- list-manipulation
151+
|- ....
152+
```
153+
154+
### Adding a New Language
155+
156+
If you want to introduce a new programming language, here's how to do it:
157+
158+
1. **Create a language folder:**
159+
160+
- Add a new folder under the `snippets` directory.
161+
- Name it after the language in lowercase (e.g., `go`, `ruby`).
162+
163+
2. **Add categories and snippets:**
164+
165+
- Follow the [Adding a New Snippet](#adding-a-new-snippet) and [Adding a New Category](#adding-a-new-category) guidelines.
166+
124167
4. **Include an icon:**
125168

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.
169+
- Add an `icon.svg` file (50x50px) in the same language folder.
170+
- Use tools like [Resize SVG](https://www.iloveimg.com/resize-image/resize-svg) to ensure the correct size.
127171

128172
5. **Double-check your work:**
129173

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

132176
---
133177

0 commit comments

Comments
 (0)