Skip to content

Commit 90f9be8

Browse files
committed
Highlight code
1 parent d487a23 commit 90f9be8

File tree

9 files changed

+120
-32
lines changed

9 files changed

+120
-32
lines changed

docs/guide/index.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# AIScript
1+
# AIScript
2+
3+
```rust
4+
// Define a function that takes a prompt and returns a response
5+
fn generate_response(prompt: string) -> string {
6+
// Call the AI model to generate a response
7+
let response = ai.generate({
8+
model: "gpt-4",
9+
prompt: prompt,
10+
max_tokens: 100
11+
});
12+
13+
return response;
14+
}
15+
16+
// Example usage
17+
let result = generate_response("Tell me a joke");
18+
print(result);
19+
```

docs/public/rspress-dark-logo.png

-6.15 KB
Binary file not shown.

docs/public/rspress-icon.png

-100 KB
Binary file not shown.

docs/public/rspress-light-logo.png

-6.23 KB
Binary file not shown.

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"preview": "rspress preview"
1212
},
1313
"dependencies": {
14+
"react-syntax-highlighter": "^15.6.1"
1415
},
1516
"devDependencies": {
1617
"@biomejs/biome": "^1.9.4",

theme/components/Landingpage/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { BackgroundImage } from '../background-image';
22
import { Hero } from '../hero';
3+
import CodeDemo from '../code-demo';
34
import styles from './index.module.scss';
45

56
import { useCallback } from 'react';
67
import { useNavigate } from 'rspress/runtime';
78

9+
const demoCode = `// Define a function that takes a prompt and returns a response
10+
fn generate_response(prompt: string) -> string {
11+
// Call the AI model to generate a response
12+
let response = ai.generate({
13+
model: "gpt-4",
14+
prompt: prompt,
15+
max_tokens: 100
16+
});
17+
18+
return response;
19+
}
20+
21+
// Example usage
22+
let result = generate_response("Tell me a joke");
23+
print(result);`;
24+
825
const LandingPage = () => {
926
const navigate = useNavigate();
1027
const onClickGetStarted = useCallback(() => {
@@ -16,12 +33,12 @@ const LandingPage = () => {
1633
<BackgroundImage />
1734
<Hero
1835
showStars
19-
// title="AIScript"
2036
subTitle="The next generation language for human and AI."
2137
getStartedButtonText='getStarted'
2238
githubURL="https://github.com/aiscriptdev/aiscript"
2339
onClickGetStarted={onClickGetStarted}
2440
/>
41+
<CodeDemo code={demoCode} filename='main.ai' />
2542
</div>
2643
);
2744
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.codeDemo {
2+
margin: 2rem auto;
3+
max-width: 800px;
4+
padding: 1rem;
5+
}
6+
7+
.filename {
8+
font-family: 'Fira Code', monospace;
9+
font-size: 0.9rem;
10+
color: #d4d4d4;
11+
background-color: #1e1e1e;
12+
padding: 0.5rem 1rem;
13+
border-top-left-radius: 8px;
14+
border-top-right-radius: 8px;
15+
border-bottom: 1px solid #333;
16+
opacity: 0.8;
17+
}
18+
19+
.codeContainer {
20+
background-color: #1e1e1e;
21+
border-radius: 8px;
22+
border-top-left-radius: 0;
23+
border-top-right-radius: 0;
24+
overflow: auto;
25+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
26+
27+
&:has(+ .filename) {
28+
border-top-left-radius: 0;
29+
border-top-right-radius: 0;
30+
}
31+
}
32+
33+
.pre {
34+
margin: 0;
35+
padding: 1.5rem;
36+
}
37+
38+
.code {
39+
font-family: 'Fira Code', monospace;
40+
font-size: 0.9rem;
41+
line-height: 1.5;
42+
color: #d4d4d4;
43+
display: block;
44+
white-space: pre;
45+
}

0 commit comments

Comments
 (0)