Skip to content

Commit 059d705

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

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-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: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,46 @@ function generateProjectName() {
1313
return `${adj}-${obj}.js`;
1414
}
1515

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

0 commit comments

Comments
 (0)