Skip to content

Commit 8ac66aa

Browse files
committed
feat: 增加Nextjs模板
1 parent ee9ad85 commit 8ac66aa

File tree

12 files changed

+1065
-94
lines changed

12 files changed

+1065
-94
lines changed

README.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222

2323
Custom Template Generator is a VS Code extension designed to streamline your development process by automating the creation of repetitive file structures. It's particularly useful for developers who frequently create components or modules with a consistent file structure.
2424

25+
It includes common Next.js file types (such as page, layout, template, error, not-found, route, global-error, middleware, etc.) to accelerate Next.js application development.
26+
27+
## Table of Contents
28+
29+
- [Introduction](#introduction)
30+
- [Use Case Example](#use-case-example)
31+
- [Features](#features)
32+
- [Installation](#installation)
33+
- [Usage](#usage)
34+
- [1. Using Next.js Templates (Currently only supports App Router)](#1-using-nextjs-templates-currently-only-supports-app-router)
35+
- [2. Using Custom Templates](#2-using-custom-templates)
36+
- [1. Configuring Templates](#1-configuring-templates)
37+
- [2. Creating Structure](#2-creating-structure)
38+
2539
### Use Case Example
2640

2741
Imagine you're developing a React application and often need to create new components. Each component typically requires:
@@ -38,10 +52,13 @@ Avatar/
3852
└── Avatar.tsx
3953
```
4054

55+
Manually creating this structure for each new component can be time-consuming. This extension allows you to create a template for this structure and generate it with just a few clicks, saving valuable development time.
56+
4157
## Features
4258

4359
- Quickly create custom file and folder structures
4460
- Configure and manage reusable templates
61+
- Built-in Next.js templates (more frameworks will be supported in the future)
4562
- Support for placeholders in file names and contents
4663

4764
## Installation
@@ -53,14 +70,48 @@ Avatar/
5370

5471
## Usage
5572

56-
### 1. Configuring Templates
73+
### 1. Using Next.js Templates (Currently only supports App Router)
74+
75+
#### 1. Demo
76+
77+
<div align="center">
78+
<img src="https://github.com/yuhang1995/custom-template-generator/raw/HEAD/assets/nextjs-demo.svg" alt="Logo" width="150" />
79+
</div>
80+
81+
<br>
82+
83+
> Submenu Explanation:
84+
>
85+
> - `App Router`: Create a Next.js page with customizable files, default creates Page, Layout, Loading, Error
86+
> - `Custom Structure`: Quickly add desired files in an existing folder, optional files include: Page, Layout, Loading, Error, NotFound, Middleware, Global Error, Route
87+
> - `Page`: Create a page.tsx file
88+
> - `Loading`: Create a loading.tsx file
89+
> - `Layout`: Create a layout.tsx file
90+
> - `Template`: Create a template.tsx file
91+
> - `Error`: Create an error.tsx file
92+
> - `Not Found`: Create a not-found.tsx file
93+
> - `Middleware`: Create a middleware.ts file
94+
> - `Global Error`: Create a global-error.tsx file
95+
> - `Route`: Create a route.ts file
96+
> - `Default`: Create a default.tsx file
97+
98+
#### 2. Using Custom Templates
99+
100+
1. Open VS Code
101+
2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
102+
3. Search for "Custom Template Generator"
103+
4. Click the "Install" button
104+
105+
### 2. Using Custom Templates
106+
107+
#### 1. Configuring Templates
57108

58109
1. Open the command palette (Ctrl+Shift+P or Cmd+Shift+P)
59110
2. Type "Configure Custom Templates" and select the command
60111
3. In the opened settings page, configure the `customTemplateGenerator.templates` setting
61112
4. Add your templates, each template should have `name` and `files` properties
62113

63-
#### Example
114+
##### Example
64115

65116
```json
66117
"customTemplateGenerator.templates": [
@@ -80,7 +131,7 @@ Avatar/
80131
]
81132
```
82133

83-
### 2. Creating Structure
134+
#### 2. Creating Structure
84135

85136
1. Right-click in the folder to open the context menu
86137
2. Click `Create Custom Structure`

README.zh-CN.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222

2323
自定义模板生成器是一个 VS Code 扩展,旨在通过自动化创建重复性文件结构来简化您的开发过程。它对于经常需要创建具有一致文件结构的组件或模块的开发者特别有用。
2424

25+
内置Nextjs常见文件类型(如page、layout、template、error、not-found、route、global-error、middleware等)来加速Next.js应用程序的开发。
26+
27+
## 目录
28+
29+
- [简介](#简介)
30+
- [使用场景示例](#使用场景示例)
31+
- [功能](#功能)
32+
- [安装](#安装)
33+
- [使用方法](#使用方法)
34+
- [一、使用Nextjs模板(目前仅支持App Router)](#一使用nextjs模板目前仅支持app-router)
35+
- [二、使用自定义模板](#二使用自定义模板)
36+
- [1、配置模板](#1配置模板)
37+
- [2、创建结构](#2创建结构)
38+
2539
### 使用场景示例
2640

2741
想象一下,您正在开发一个 React 应用,经常需要创建新的组件。每个组件通常需要:
@@ -44,6 +58,7 @@
4458

4559
- 快速创建自定义文件和文件夹结构
4660
- 配置和管理可重用的模板
61+
- 内置Nextjs模板(未来会支持更多框架)
4762
- 支持文件名和内容中的占位符
4863

4964
## 安装
@@ -55,14 +70,50 @@
5570

5671
## 使用方法
5772

58-
### 1、配置模板
73+
### 一、使用Nextjs模板(目前仅支持App Router)
74+
75+
#### 1、使用演示
76+
77+
<div align="center">
78+
<img src="https://github.com/yuhang1995/custom-template-generator/raw/HEAD/assets/nextjs-demo.svg" alt="Logo" width="150" />
79+
</div>
80+
81+
<br>
82+
83+
> 子菜单说明:
84+
>
85+
> - `App Router`:创建一个Nextjs页面,可自定义需要的文件,默认创建Page、Layout、Loading、Error
86+
> - `Custom Structure`:在已有文件夹中快速添加想要的文件,可选文件有:Page、Layout、Loading、Error、NotFound、Middleware、Global Error、Route
87+
> - `Page`:创建一个page.tsx文件
88+
> - `Loading`:创建一个loading.tsx文件
89+
> - `Layout`:创建一个layout.tsx文件
90+
> - `Template`:创建一个template.tsx文件
91+
> - `Error`:创建一个error.tsx文件
92+
> - `Not Found`:创建一个not-found.tsx文件
93+
> - `Middleware`:创建一个middleware.ts文件
94+
> - `Global Error`:创建一个global-error.tsx文件
95+
> - `Route`:创建一个route.ts文件
96+
> - `Default`:创建一个default.tsx文件
97+
98+
99+
#### 2、自定义模板
100+
101+
1. 打开 VS Code
102+
2. 转到扩展视图 (Ctrl+Shift+X 或 Cmd+Shift+X)
103+
3. 搜索 "custom-template-generator"
104+
4. 点击 "安装" 按钮
105+
106+
107+
### 二、使用自定义模板
108+
109+
#### 1、配置模板
59110

60111
1. 打开命令面板 (Ctrl+Shift+P 或 Cmd+Shift+P)
61112
2. 输入 "Configure Custom Templates" 并选择该命令
62113
3. 在打开的设置页面中,配置 `customTemplateGenerator.templates` 设置
63114
4. 添加您的模板,每个模板应包含 `name``files` 属性
64115

65-
#### 示例
116+
##### 示例
66117

67118
```json
68119
"customTemplateGenerator.templates": [
@@ -82,9 +133,9 @@
82133
]
83134
```
84135

85-
### 2、创建结构
136+
#### 2、创建结构
86137

87-
1. 在文件夹中右键打开菜单
138+
1. 在工作区文件夹中右键打开菜单
88139
2. 点击 `Create Custom Structure`
89-
3. 在打开的设置页面中,选择您想要的模板
140+
3. 选择您想要的模板
90141
4. 输入组件名称,然后按 `Enter` 确认

assets/nextjs-demo.gif

1.73 MB
Loading

package-lock.json

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

0 commit comments

Comments
 (0)