Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
joshamaju authored Apr 19, 2024
1 parent b840792 commit 64c8785
Showing 1 changed file with 14 additions and 93 deletions.
107 changes: 14 additions & 93 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,27 @@
# MPA
# @stack54/cli

🚧 [WIP]
## Installation

## ✨ Features

- Hot reload
- HTML asset bundling
- Typed environment variables
- Templates with Svelte and Markdown

## Configuration

```ts
import { defineConfig } from "vite";
import mpa from "stack54/vite";

export default defineConfig({
plugins: [
mpa({
/* ...config */
}),
],
});
```

### API

- `publicEnvPrefix`: default `PUBLIC\_`
- `extensions`: default `.svelte`, `.svx`
- `serverEntry`: default src/entry.{js,ts,mjs,mts}
- `preprocess`: [documentation](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#preprocess)
- `compilerOptions`: [documentation](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#compileroptions)

## Routing

```ts
import { Hono } from "hono";

const router = new Hono();

router.get("/", (ctx) => ctx.html(view("about")));
```

### Nested router

```ts
import { Hono } from "hono";

const router = new Hono();

// nested
const nested = new Hono();
nested.get("/", (ctx) => ctx.html(view("about")));
// nested

router.route("*", nested);
```bash
npm i -g @stack54/cli
```

## Rendering

To render a component/template, include `ssr` query in file import i.e
## Usage

```ts
import { renderToString } from "stack54/render";
import About from "./views/about.svelte?ssr";
### Create a new project

renderToString(
About.render({
/* props */
})
);

// or

renderToString(About, {
/* props */
});
```bash
stack54 new <project-name>
```

Or

```ts
import { makeFactory, resolveComponent } from "stack54/render";
### Generate controller

const templates = import.meta.glob("./views/**/*.page.svelte", {
query: { ssr: true },
eager: true,
});

export const view = makeFactory((name) => {
return resolveComponent(`./views/${name}.svelte`, templates);
});

view("about", {
/* props */
});
```bash
stack54 make controller <controller-name>
```

## Limitations

- Cannot use dynamic import types in templates i.e
### Generate view

```ts
export let prop: import("some-module").Type;
```bash
stack54 make view <view-name>
```

0 comments on commit 64c8785

Please sign in to comment.