Skip to content

Commit d980a52

Browse files
committed
Merge branch 'main' of github.com:aircodelabs/aircode
2 parents 2cb7188 + 0084406 commit d980a52

11 files changed

Lines changed: 76 additions & 10 deletions

File tree

docs/en/.vitepress/sidebar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const sidebar: DefaultTheme.Sidebar = {
4343
{ text: 'Send HTTP Request', link: '/guide/functions/http-request' },
4444
{ text: 'POST Parameters', link: '/guide/functions/post-params' },
4545
{ text: 'GET Parameters', link: '/guide/functions/get-params' },
46+
{ text: 'ESM Support', link: '/guide/functions/esm' },
4647
],
4748
},
4849
],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default [
22
{ text: 'Connect Siri to ChatGPT', link: 'https://aircode.cool/hpwdi7n719' },
3-
{ text: 'Build a Discord ChatGPT Bot', link: 'https://aircode.cool/zsgdima57c' },
4-
{ text: 'Build a Slack ChatGPT Bot', link: 'https://aircode.cool/vkx3j8c9q5' },
3+
{ text: 'Build Discord ChatGPT Bot', link: 'https://aircode.cool/zsgdima57c' },
4+
{ text: 'Build Slack ChatGPT App', link: 'https://aircode.cool/vkx3j8c9q5' },
55
];

docs/en/src/chatgpt/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ aside: false
44

55
# Build a ChatGPT Bot with JavaScript in Just 5 Minutes
66

7-
Build a ChatGPT bot in just 5 minutes with this comprehensive tutorial. [简体中文版](https://docs-cn.aircode.io/chatgpt/)
7+
Build a ChatGPT bot in just 5 minutes with this comprehensive tutorial.
88

99
## Choose a tutorial to enter, includes all source code, free hosting.
1010

docs/en/src/guide/functions/esm.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ESM Support {#intro}
2+
3+
AirCode supports Node.js's ECMAScript Modules (ESM). You can directly use ESM syntax in files with the `.mjs` extension.
4+
5+
ESM syntax provides convenience in the following scenarios:
6+
1. Using `import` / `export` statements for importing and exporting modules, providing clearer dependency relationships.
7+
2. More compliant with the ECMAScript specification, consistent with front-end JavaScript modularization, facilitating code sharing between the server and the front end.
8+
3. And more...
9+
10+
## Create .mjs Files {#create}
11+
12+
In your project, you can directly create a file with the `.mjs` extension, such as `main.mjs`. In `.mjs` files, you can normally use ESM syntax, and can debug and deploy like files with the `.js` extension.
13+
14+
For example, create a file named `main.mjs`, the default code is as follows:
15+
16+
```js
17+
// @see https://docs.aircode.io/guide/functions/
18+
import aircode from 'aircode';
19+
20+
export default async function (params, context) {
21+
console.log('Received params:', params);
22+
return {
23+
message: 'Hi, AirCode.',
24+
};
25+
};
26+
```
27+
28+
Click **Debug**, and you will see the output `Hi, AirCode` in the **Response** section.
29+
30+
## More Information {#more}
31+
32+
For more information about ECMAScript Modules (ESM) and `.mjs` files, please refer to [Node.js Documentation - ECMAScript Modules](https://nodejs.org/api/esm.html).

docs/zh-cn/.vitepress/sidebar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const sidebar: DefaultTheme.Sidebar = {
4343
{ text: '发送 HTTP 请求', link: '/guide/functions/http-request' },
4444
{ text: '获取 POST 参数', link: '/guide/functions/post-params' },
4545
{ text: '获取 GET 参数', link: '/guide/functions/get-params' },
46+
{ text: 'ESM 支持', link: '/guide/functions/esm'},
4647
// { text: '获取请求头和方法', link: '/guide/functions/request-header-and-method' },
4748
// { text: '设置返回头和状态码', link: '/guide/functions/response-header-and-code' },
4849
// { text: '私有函数', link: '/guide/functions/private' },

docs/zh-cn/.vitepress/tutorial-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export default [
33
{ text: '开发飞书 ChatGPT 机器人', link: 'https://aircode.cool/q4y1msdim4' },
44
{ text: '开发钉钉 ChatGPT 机器人', link: 'https://aircode.cool/xspb3by9fs' },
55
{ text: '开发企业微信 ChatGPT 应用', link: 'https://aircode.cool/54fhemjpk2' },
6-
{ text: '开发 Slack ChatGPT 机器人', link: 'https://aircode.cool/zx85v6ac4s' },
7-
{ text: '开发 Discord ChatGPT 机器人', link: 'https://aircode.cool/uumhsex1uc' },
6+
{ text: '开发 Slack ChatGPT 应用', link: 'https://aircode.cool/zx85v6ac4s' },
7+
{ text: '开发 Discord ChatGPT Bot', link: 'https://aircode.cool/uumhsex1uc' },
88
];

docs/zh-cn/src/chatgpt/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ aside: false
44

55
# 5 分钟用 JavaScript 接入 ChatGPT 手把手教程
66

7-
仅需 5 分钟,快速开发一个 ChatGPT 机器人,下面为全部教程。 [English Version](https://docs.aircode.io/chatgpt/)
7+
仅需 5 分钟,快速开发一个 ChatGPT 机器人,下面为全部教程。
88

99
## 选择一个教程进入(含全部源码,免费托管)
1010

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ESM 支持 {#intro}
2+
3+
AirCode 支持 Node.js 的 ECMAScript 模块 (ESM),你可以在 `.mjs` 后缀名的文件中直接使用 ESM 语法。
4+
5+
ESM 语法为你在以下场景提供便利:
6+
1. 利用 `import` / `export` 语句对模块进行导入导出,提供更清晰的依赖关系。
7+
3. 更加符合 ECMAScript 规范,与前端 JavaScript 模块化方式一致,方便进行服务器与前端的代码共享。
8+
4. 更多……
9+
10+
## 创建 .mjs 文件 {#create}
11+
12+
在你的项目中,你可以直接创建一个 `.mjs` 后缀名的文件,例如 `main.mjs`。在 `.mjs` 文件中,你可以正常使用 ESM 语法,且可像 `.js` 后缀名的文件一样进行调试和部署。
13+
14+
例如,创建一个名为 `main.mjs` 的文件,默认的代码如下:
15+
16+
```js
17+
// @see https://docs.aircode.io/guide/functions/
18+
import aircode from 'aircode';
19+
20+
export default async function (params, context) {
21+
console.log('Received params:', params);
22+
return {
23+
message: 'Hi, AirCode.',
24+
};
25+
};
26+
```
27+
28+
点击 **Debug**,你就会在 **Response** 栏看到 `Hi AirCode` 的输出。
29+
30+
## 更多信息 {#more}
31+
32+
关于 ECMAScript 模块 (ESM) 和 `.mjs` 文件的更多信息,请参考 [Node.js 文档 - ECMAScript Modules](https://nodejs.org/api/esm.html)

docs/zh-cn/src/help/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
1. 我们的 [GitHub 仓库](https://github.com/aircodelabs/aircode),可以提 issue 或者直接贡献代码
88
2. 直接发邮件给我们 support@aircode.io
99
3. 我们的 [Discord 讨论区](https://discord.com/invite/XrMVdYdEuY)
10-
4. 我们的[飞书用户群](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=6dem4ab3-d523-4562-9c63-9fb46d565b10),点击链接或扫描下面的二维码加入
10+
4. 我们的[飞书用户群](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=988pd70a-e66a-49bd-9eac-09acba329491),点击链接或扫描下面的二维码加入
1111

12-
<img src="../public/_images/help/feishu.png" width="160px" style="margin-left:30px;"/>
12+
<img src="/_images/help/feishu2.png" width="160px" style="margin-left:30px;"/>
1313

1414
5. 我们的微信群,微信扫描下面的二维码加入
1515

16-
<img src="../public/_images/help/weixin.png" width="160px" style="margin-left:30px;"/>
16+
<img src="/_images/help/weixin.png" width="160px" style="margin-left:30px;"/>
1717

1818
6. 我们的钉钉群,钉钉扫描下面的二维码加入
1919

20-
<img src="../public/_images/help/dingding.png" width="160px" style="margin-left:30px;"/>
20+
<img src="/_images/help/dingding.png" width="160px" style="margin-left:30px;"/>
2121

3.45 KB
Loading

0 commit comments

Comments
 (0)