|
1 | | -# VersaTiles Playground |
| 1 | +# VersaTiles Playground |
2 | 2 |
|
3 | | -A playground to show how to use [VersaTiles](https://versatiles.org) in a web frontend. |
| 3 | +A web-based playground demonstrating how to use [VersaTiles](https://versatiles.org) in a frontend environment. |
4 | 4 |
|
5 | | -Every example is built with the free **[LiveCodes](https://github.com/live-codes/livecodes)** editor and automatically deployed to GitHub Pages: |
| 5 | +This project uses the free [LiveCodes](https://github.com/live-codes/livecodes) editor and is automatically deployed via GitHub Pages: |
| 6 | +👉 https://versatiles.org/playground/ |
6 | 7 |
|
7 | | -> **Live demo:** https://versatiles.org/playground/ |
| 8 | +⸻ |
8 | 9 |
|
9 | | ---- |
10 | | - |
11 | | -## Repository Structure |
| 10 | +## 📁 Repository Structure |
12 | 11 |
|
13 | 12 | ```text |
14 | | -/ |
15 | | -├── .github/workflows/ # CI pipeline that builds & deploys the playground |
16 | | -├── examples/ # JSON exports of individual LiveCodes examples |
17 | | -└── index.html # Landing page listing all examples |
| 13 | +├─ .github/workflows/ # CI pipeline for building & deploying the playground |
| 14 | +├─ docs/ # Output directory for the generated website |
| 15 | +├─ playground/ # Source examples for the playground |
| 16 | +│ ├─ toc.ts # Table of contents listing all available examples |
| 17 | +│ └─ $name/ # Individual example directory (replace $name with actual example name) |
| 18 | +│ ├─ code.html # LiveCodes HTML snippet |
| 19 | +│ └─ text.md # Markdown explanation for the example |
| 20 | +└─ src/ # Source code for the generator and dev server |
| 21 | + ├─ generate.ts # Script to build all example pages |
| 22 | + ├─ dev.ts # Development server |
| 23 | + ├─ lib/ # Shared utility code |
| 24 | + └─ templates/ # Embedded JS templates (ETA format) |
| 25 | + ├─ index.eta # Template for the index page |
| 26 | + └─ page.eta # Template for individual example pages |
18 | 27 | ``` |
19 | 28 |
|
20 | | ---- |
21 | | - |
22 | | -## 🚀 Add a New Example |
23 | | - |
24 | | -> Below, replace `<NAME>` with a short kebab‑case identifier for your example. |
25 | | -
|
26 | | -1. **Open LiveCodes** at https://versatiles.org/playground/livecodes and create your example. |
27 | | - Need help? Check the [LiveCodes docs](https://livecodes.io/docs/features/). |
28 | | -2. **Export the project** via `Menu → Project → Export → Export Project (JSON)` and save it as `examples/<NAME>.json` in this repo. |
29 | | -3. **Link it** in `index.html` by adding a line like: |
| 29 | +⸻ |
30 | 30 |
|
31 | | - ```html |
32 | | - <ul> |
33 | | - … |
34 | | - <li><a href="examples/<NAME>">Short description of your example</a></li> |
35 | | - </ul> |
36 | | - ``` |
| 31 | +## 🚀 Usage |
37 | 32 |
|
38 | | -4. **Commit & push** (or open a PR). The GitHub Actions workflow will build and deploy the updated playground. |
39 | | - Once the workflow succeeds, your example will be listed at: |
40 | | - `https://versatiles.org/playground/`. |
| 33 | +### Build the Playground |
41 | 34 |
|
42 | | ---- |
| 35 | +To generate all web pages from the examples: |
43 | 36 |
|
44 | | -## 🔄 Update an Existing Example |
45 | | - |
46 | | -1. Open an example in LiveCodes. |
47 | | -2. Make your changes. |
48 | | -3. Re‑export the project (JSON) and overwrite `examples/<NAME>.json`. |
49 | | -4. Commit & push. The site will redeploy automatically. |
50 | | - |
51 | | ---- |
| 37 | +```bash |
| 38 | +deno task build |
| 39 | +``` |
52 | 40 |
|
53 | | -## ⚙️ How it works |
| 41 | +### Run in Development Mode |
54 | 42 |
|
55 | | -- **LiveCodes** is a 100 % client‑side playground. It can open a project JSON provided via the `?config=` query parameter. |
56 | | -- Our **GitHub Actions** workflow builda a new page on every push to `main` and adds: |
| 43 | +To start a local development server: |
57 | 44 |
|
58 | | - 1. LiveCodes. |
59 | | - 2. all `examples/*.json` |
60 | | - 3. `index.html`. |
| 45 | +```bash |
| 46 | +deno task dev |
| 47 | +``` |
61 | 48 |
|
62 | | -- Because everything happens in the browser, **no backend** is required. |
63 | 49 |
|
64 | | ---- |
| 50 | +⸻ |
65 | 51 |
|
66 | | -## 📄 License |
| 52 | +## 📄 License |
67 | 53 |
|
68 | | -[MIT](LICENSE) |
| 54 | +This project is licensed under the [MIT License](./LICENSE). |
0 commit comments