Skip to content

Commit 9624a7e

Browse files
committed
feat(scripts): add a script to merge snippets in /public/snipppets folder
1 parent 301d665 commit 9624a7e

20 files changed

+534
-13
lines changed

package-lock.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7+
"prebuild": "tsx scripts/merge-snippets.ts",
78
"build": "next build",
89
"start": "next start",
910
"lint": "next lint",
@@ -47,6 +48,7 @@
4748
"eslint-config-next": "15.4.5",
4849
"pagefind": "^1.3.0",
4950
"tailwindcss": "^4",
51+
"tsx": "^4.20.5",
5052
"tw-animate-css": "^1.3.6",
5153
"typescript": "^5"
5254
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

public/snippets/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# IMPORTANT
2+
3+
### This folder is read-only. Do NOT modify this folder!

public/snippets/all.json

Lines changed: 182 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,182 @@
1-
[]
1+
[
2+
{
3+
"id": "shuffle-array",
4+
"category": "array-manipulation",
5+
"title": "Shuffle Array",
6+
"description": "Shuffles the items in an array.",
7+
"languages": [
8+
"js"
9+
],
10+
"contributors": [
11+
"loxt-nixo"
12+
],
13+
"tags": [
14+
"array",
15+
"shuffle",
16+
"random"
17+
]
18+
},
19+
{
20+
"id": "add-localstorage",
21+
"category": "data-handling",
22+
"title": "Add Item to localStorage",
23+
"description": "Stores a value in localStorage under the given key.",
24+
"languages": [
25+
"js"
26+
],
27+
"contributors": [
28+
"technoph1le"
29+
],
30+
"tags": [
31+
"localStorage",
32+
"storage",
33+
"memory"
34+
]
35+
},
36+
{
37+
"id": "number-to-currency",
38+
"category": "number-formatting",
39+
"title": "Convert Number to Currency",
40+
"description": "Converts a number to a currency format with a specific locale.",
41+
"languages": [
42+
"js"
43+
],
44+
"contributors": [
45+
"axorax"
46+
],
47+
"tags": [
48+
"number",
49+
"currency"
50+
]
51+
},
52+
{
53+
"id": "reverse-string",
54+
"category": "string-manipulation",
55+
"title": "Reverse String",
56+
"description": "Reverses the characters in a string.",
57+
"languages": [
58+
"js",
59+
"cpp",
60+
"py"
61+
],
62+
"contributors": [
63+
"technoph1le",
64+
"Vaibhav-kesarwani"
65+
],
66+
"tags": [
67+
"string",
68+
"reverse"
69+
]
70+
},
71+
{
72+
"id": "string-to-camel-case",
73+
"category": "string-manipulation",
74+
"title": "Convert String to Camel Case",
75+
"description": "Converts a given string into camelCase.",
76+
"languages": [
77+
"js",
78+
"java"
79+
],
80+
"contributors": [
81+
"aumirza",
82+
"Mcbencrafter"
83+
],
84+
"tags": [
85+
"string",
86+
"case"
87+
]
88+
},
89+
{
90+
"id": "string-to-param-case",
91+
"category": "string-manipulation",
92+
"title": "Convert String to Param Case",
93+
"description": "Converts a given string into param-case.",
94+
"languages": [
95+
"js",
96+
"java"
97+
],
98+
"contributors": [
99+
"aumirza",
100+
"Mcbencrafter"
101+
],
102+
"tags": [
103+
"string",
104+
"case"
105+
]
106+
},
107+
{
108+
"id": "string-to-pascal-case",
109+
"category": "string-manipulation",
110+
"title": "Convert String to Pascal Case",
111+
"description": "Converts a given string into PascalCase.",
112+
"languages": [
113+
"js",
114+
"java"
115+
],
116+
"contributors": [
117+
"aumirza",
118+
"Mcbencrafter"
119+
],
120+
"tags": [
121+
"string",
122+
"case"
123+
]
124+
},
125+
{
126+
"id": "string-to-snake-case",
127+
"category": "string-manipulation",
128+
"title": "Convert String to Snake Case",
129+
"description": "Converts a given string into snake_case.",
130+
"languages": [
131+
"js",
132+
"java"
133+
],
134+
"contributors": [
135+
"axorax",
136+
"Mcbencrafter"
137+
],
138+
"tags": [
139+
"string",
140+
"case"
141+
]
142+
},
143+
{
144+
"id": "string-to-title-case",
145+
"category": "string-manipulation",
146+
"title": "Convert String to Title Case",
147+
"description": "Converts a given string into Title Case.",
148+
"languages": [
149+
"js"
150+
],
151+
"contributors": [
152+
"aumirza"
153+
],
154+
"tags": [
155+
"string",
156+
"case"
157+
]
158+
},
159+
{
160+
"id": "truncate-sring",
161+
"category": "string-manipulation",
162+
"title": "Truncate String",
163+
"description": "Truncates a string after a specified length.",
164+
"languages": [
165+
"js",
166+
"java",
167+
"py"
168+
],
169+
"contributors": [
170+
"realvishalrana",
171+
"Mcbencrafter",
172+
"axorax",
173+
"MinerMinerMods"
174+
],
175+
"tags": [
176+
"string",
177+
"truncate",
178+
"mask",
179+
"hide"
180+
]
181+
}
182+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "shuffle-array",
3+
"category": "array-manipulation",
4+
"title": "Shuffle Array",
5+
"description": "Shuffles the items in an array.",
6+
"languages": [
7+
"js"
8+
],
9+
"contributors": [
10+
"loxt-nixo"
11+
],
12+
"tags": [
13+
"array",
14+
"shuffle",
15+
"random"
16+
],
17+
"snippets": {
18+
"js": "function shuffleArray(array) {\r\n for (let i = array.length - 1; i >= 0; i--) {\r\n const j = Math.floor(Math.random() * (i + 1));\r\n [array[i], array[j]] = [array[j], array[i]];\r\n }\r\n}\r\n\r\n// Usage:\r\nconst array = [1, 2, 3, 4, 5];\r\nshuffleArray(array); // Shuffles `array` in place"
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "add-localstorage",
3+
"category": "data-handling",
4+
"title": "Add Item to localStorage",
5+
"description": "Stores a value in localStorage under the given key.",
6+
"languages": [
7+
"js"
8+
],
9+
"contributors": [
10+
"technoph1le"
11+
],
12+
"tags": [
13+
"localStorage",
14+
"storage",
15+
"memory"
16+
],
17+
"snippets": {
18+
"js": "const addToLocalStorage = (key, value) => {\r\n localStorage.setItem(key, JSON.stringify(value));\r\n};\r\n\r\n// Usage:\r\naddToLocalStorage('user', { name: 'John', age: 30 });"
19+
}
20+
}

0 commit comments

Comments
 (0)