new example

This commit is contained in:
Luca Casonato
2021-05-08 12:57:33 +02:00
parent cfb99ef326
commit f42fff1a31
6 changed files with 65 additions and 14 deletions
+4 -1
View File
@@ -1,3 +1,6 @@
> :warning: DO NOT USE. THIS DOES NOT WORK, and is just a POC for JIT JS
> bundling.
# fresh
Preact, but super edgy.
@@ -25,7 +28,7 @@ To install, run the following command. This will add `fresh` CLI to your PATH.
Make sure to have Deno 1.9.1 or later installed.
```sh
deno install -A -f https://deno.land/x/fresh/cli.ts
deno install -A -f --no-check https://deno.land/x/fresh/cli.ts
```
## Getting started
+22
View File
@@ -0,0 +1,22 @@
# fresh project
### Usage
Install deployctl:
```
deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -r -f https://deno.land/x/deploy/deployctl.ts
```
Start the project:
```
deployctl run --no-check --watch server.ts
```
After adding, removing, or moving a page in the `pages` directory, run:
```
fresh routes
```
+9 -10
View File
@@ -1,12 +1,11 @@
import { h, PageProps, useState } from "../deps.ts";
import { h } from "../deps.ts";
export default function Home(props: PageProps) {
const [counter, setCounter] = useState(0);
return (
<div>
Hello {props.params.name}! {counter}{" "}
<button onClick={() => setCounter(counter + 1)}>+1</button>
</div>
);
interface Props {
params: {
name: string;
};
}
export default function Greet(props: Props) {
return <div>Hello {props.params.name}</div>;
}
+20 -3
View File
@@ -1,5 +1,22 @@
import { h } from "../deps.ts";
import { h, useState } from "../deps.ts";
export default function Home(props: {}) {
return <div>Hello World!</div>;
export default function Home() {
return (
<div>
<p>
Welcome to `fresh`. Try update this message in the ./pages/index.tsx
file, and refresh.
</p>
<Counter />
</div>
);
}
function Counter() {
const [count, setCount] = useState(0);
return <div>
<p>{count}</p>
<button onClick={() => setCount(count - 1)}>-1</button>
<button onClick={() => setCount(count + 1)}>+1</button>
</div>;
}
+4
View File
@@ -1,3 +1,7 @@
// DO NOT EDIT. This file is generated by `fresh`.
// This file SHOULD be checked into source version control.
// To update this file, run `fresh routes`.
import { setup } from "../server.ts";
import * as $0 from "./pages/[name].tsx";
+6
View File
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
}
}