Skip to content

Commit 5dbb7e0

Browse files
committed
Add more information in new page (#176)
* Change News's position * Optimize new page
1 parent 38e1c26 commit 5dbb7e0

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

app/Nav.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export function Nav() {
6868
<SafeLink href="/docs" className={cn(styles.link, isSelected("/docs") && styles.selectedLink, "ml-3")}>
6969
Docs
7070
</SafeLink>
71+
<SafeLink href="/examples" className={cn(styles.link, isSelected("/examples") && styles.selectedLink)}>
72+
Examples
73+
</SafeLink>
7174
<a
7275
href="https://recho.dev/news"
7376
target="_blank"
@@ -76,9 +79,6 @@ export function Nav() {
7679
>
7780
News
7881
</a>
79-
<SafeLink href="/examples" className={cn(styles.link, isSelected("/examples") && styles.selectedLink)}>
80-
Examples
81-
</SafeLink>
8282
</div>
8383
{/* Mobile navigation */}
8484
<div className={cn("md:hidden relative")} ref={dropdownRef}>
@@ -98,6 +98,13 @@ export function Nav() {
9898
>
9999
Docs
100100
</SafeLink>
101+
<SafeLink
102+
href="/examples"
103+
className={cn(styles.dropdownItem, isSelected("/examples") && styles.dropdownItemSelected)}
104+
onClick={() => setDropdownOpen(false)}
105+
>
106+
Examples
107+
</SafeLink>
101108
<a
102109
href="https://recho.dev/news"
103110
className={cn(styles.dropdownItem, isSelected("/news") && styles.dropdownItemSelected)}
@@ -107,13 +114,6 @@ export function Nav() {
107114
>
108115
News
109116
</a>
110-
<SafeLink
111-
href="/examples"
112-
className={cn(styles.dropdownItem, isSelected("/examples") && styles.dropdownItemSelected)}
113-
onClick={() => setDropdownOpen(false)}
114-
>
115-
Examples
116-
</SafeLink>
117117
</div>
118118
)}
119119
</div>

app/SafeLink.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {useSyncExternalStore} from "react";
33
import {useRouter} from "next/navigation";
44
import {isDirtyStore, countStore} from "./store.js";
5+
import Link from "next/link";
56

67
export function SafeLink({href, children, className, onClick, ...props}) {
78
const router = useRouter();
@@ -24,8 +25,8 @@ export function SafeLink({href, children, className, onClick, ...props}) {
2425
};
2526

2627
return (
27-
<a href={href} onClick={handleClick} className={className} {...props}>
28+
<Link href={href} onClick={handleClick} className={className} {...props}>
2829
{children}
29-
</a>
30+
</Link>
3031
);
3132
}

app/api.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,49 @@ function generateProjectName() {
1313
return `${adj}-${obj}.js`;
1414
}
1515

16+
const DEFAULT_CONTENT = `
17+
/**
18+
* Welcome to Recho Notebook!
19+
* A reactive editor for algorithms and ASCII art.
20+
*/
21+
22+
// 1. You can call echo(value) to echo output inline as comments, which allows
23+
// you to better understand the code by "seeing" every manipulation in-situ.
24+
25+
const text = echo("dog");
26+
27+
const words = echo(text.split(""));
28+
29+
echo(words.reverse().join(""));
30+
31+
// 2. You can also call recho.interval(ms) to create data-driven animations,
32+
// which can help you find the minimalism of ASCII art is fascinating!
33+
34+
const x = recho.interval(100);
35+
36+
echo("🚗💨".padStart(40 - (x % 40)));
37+
38+
// 3. Inputs are also supported, which can help you create interactive
39+
// notebooks. Click the buttons to see what happens!
40+
41+
const x1 = recho.number(10, {min: 0, max: 40, step: 1});
42+
43+
//➜ "(๑•̀ㅂ•́)و✧"
44+
echo("~".repeat(x1) + "(๑•̀ㅂ•́)و✧");
45+
46+
// Refer to the links (cmd/ctrl + click) to learn more about Recho Notebook:
47+
// - Docs: https://recho.dev/notebook/docs
48+
// - Examples: https://recho.dev/notebook/examples
49+
// - Github: https://github.com/recho-dev/notebook
50+
`;
51+
1652
export function createNotebook() {
1753
return {
1854
id: generate(),
1955
title: generateProjectName(),
2056
created: null,
2157
updated: null,
22-
content: `echo("Hello, world!");`,
58+
content: DEFAULT_CONTENT.trimStart(),
2359
autoRun: true,
2460
runtime: DEFAULT_RUNTIME,
2561
};

0 commit comments

Comments
 (0)