Skip to content

Commit 8c550f6

Browse files
committed
example
1 parent 9d1a9cf commit 8c550f6

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

docs/en/guide/docs/contact/example.mdx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,35 @@ title: Example
33
---
44

55
```tsx
6-
import { Script } from "scripting";
6+
import { Script } from "scripting"
77

88
async function run() {
9-
console.present().then(() => {
10-
Script.exit();
11-
});
12-
13-
console.log("Start to fetch contacts");
14-
try {
15-
const contacts = await Contact.fetchAllContacts();
16-
17-
const first = contacts.at(0);
18-
19-
if (!first) {
20-
console.log("No contacts found");
21-
} else {
22-
console.log("There are " + contacts.length + " contacts");
23-
24-
const name = [first.givenName, first.familyName].join(" ");
25-
26-
console.log("First contact name: " + name);
27-
}
28-
} catch (e) {
29-
console.error(e);
9+
console.present().then(() => {
10+
Script.exit()
11+
})
12+
13+
console.log("Start to fetch contacts")
14+
try {
15+
const contacts = await Contact.fetchAllContacts()
16+
17+
const first = contacts.at(0)
18+
19+
if (!first) {
20+
console.log("No contacts found")
21+
} else {
22+
console.log("There are " + contacts.length + " contacts")
23+
24+
const name = [
25+
first.givenName,
26+
first.familyName
27+
].join(" ")
28+
29+
console.log("First contact name: " + name)
3030
}
31+
} catch (e) {
32+
console.error(e)
33+
}
3134
}
3235

33-
run();
36+
run()
3437
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "rspress build",
77
"dev": "rspress dev",
88
"preview": "rspress preview",
9-
"generate-mdx": "node scripts/generate-example-mdx.js"
9+
"gen-example": "bun scripts/gen-example.js"
1010
},
1111
"dependencies": {
1212
"rspress": "^1.40.2"

0 commit comments

Comments
 (0)