-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeblocks.json
More file actions
30 lines (30 loc) · 1.28 KB
/
codeblocks.json
File metadata and controls
30 lines (30 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
"blocks": [
{
"id": "react-component",
"title": "React Functional Component",
"description": "Basic React functional component template",
"code": "import React from 'react';\n\ninterface Props {\n // Define your props here\n}\n\nconst ComponentName: React.FC<Props> = ({ }) => {\n return (\n <div>\n {/* Your JSX here */}\n </div>\n );\n};\n\nexport default ComponentName;",
"language": "typescript",
"tags": [
"react",
"component",
"typescript"
],
"category": "react"
},
{
"id": "api-route",
"title": "Next.js API Route",
"description": "Basic Next.js API route template",
"code": "import type { NextApiRequest, NextApiResponse } from \"next\";\n\nexport default function handler(\n req: NextApiRequest,\n res: NextApiResponse\n) {\n switch (req.method) {\n case \"GET\":\n res.status(200).json({ message: \"GET request\" });\n break;\n case \"POST\":\n res.status(200).json({ message: \"POST request\" });\n break;\n default:\n res.status(405).json({ error: \"Method not allowed\" });\n }\n}",
"language": "typescript",
"tags": [
"nextjs",
"api",
"typescript"
],
"category": "api"
}
]
}