Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions civet.dev/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ hx --health civet

## Starter Templates

- [Astro, esbuild, NextJS, Farm, Rolldown, Rollup, Vite, and Webpack](https://github.com/DanielXMoore/Civet/blob/main/integration/unplugin-examples)
- [Astro, esbuild, NextJS, Farm, Rolldown, Rollup, SolidStart, Vite, and Webpack](https://github.com/DanielXMoore/Civet/blob/main/integration/unplugin-examples)
- [Solid](https://github.com/edemaine/civet-solid-vite-template) ([older](https://github.com/orenelbaum/solid-civet-template))
- [SolidStart](https://github.com/orenelbaum/solid-start-civet-template)
- [SolidStart](https://github.com/DanielXMoore/Civet/blob/main/integration/unplugin-examples/solid-start) ([older](https://github.com/orenelbaum/solid-start-civet-template))
- [p5.js](https://codesandbox.io/p/sandbox/drawing-points-civet-2tk4jq)

## Linters
Expand Down
2 changes: 2 additions & 0 deletions integration/unplugin-examples/solid-start/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vinxi
.output
20 changes: 20 additions & 0 deletions integration/unplugin-examples/solid-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SolidStart + Civet

A minimal [SolidStart](https://start.solidjs.com/) app with Civet routes in
the filesystem router (`src/routes/index.civet` page and
`src/routes/api/answer.civet` API route).

The two pieces of configuration that make this work (see `app.config.ts`):

- `extensions: ["civet"]` — includes `.civet` files in the route scan
(SolidStart also forwards this to `vite-plugin-solid` so it compiles the
JSX in compiled Civet output).
- the Civet vite plugin with `ts: "civet"` (or `"esbuild"` / `"tsc"`).
`ts: "preserve"` does not work here: nothing downstream strips TypeScript
syntax from `.civet` modules in vinxi-based frameworks.

```bash
pnpm dev # development server
pnpm build # production build
pnpm start # serve the production build
```
17 changes: 17 additions & 0 deletions integration/unplugin-examples/solid-start/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "@solidjs/start/config";
import civetVitePlugin from "@danielx/civet/vite";

export default defineConfig({
// Include .civet files in the filesystem router's route scan
extensions: ["civet"],
vite: {
plugins: [
civetVitePlugin({
// Compile to plain JS + JSX; vite-plugin-solid compiles the JSX.
// (`ts: "preserve"` doesn't work here: nothing downstream strips
// TypeScript syntax from .civet modules in vinxi-based frameworks.)
ts: "civet",
}),
],
},
});
21 changes: 21 additions & 0 deletions integration/unplugin-examples/solid-start/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "civet-example-solid-start",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "vinxi build",
"dev": "vinxi dev",
"start": "vinxi start"
},
"dependencies": {
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.15.3",
"@solidjs/start": "^1.3.2",
"solid-js": "^1.9.13",
"vinxi": "^0.5.11"
},
"devDependencies": {
"@danielx/civet": "workspace:*"
}
}
11 changes: 11 additions & 0 deletions integration/unplugin-examples/solid-start/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js";

export default function App() {
return (
<Router root={(props) => <Suspense>{props.children}</Suspense>}>
<FileRoutes />
</Router>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
16 changes: 16 additions & 0 deletions integration/unplugin-examples/solid-start/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
<StartServer
document={({ assets, children, scripts }) => (
<html lang="en">
<head>{assets}</head>
<body>
<div id="app">{children}</div>
{scripts}
</body>
</html>
)}
/>
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { json } from "@solidjs/router"

export GET := => json { answer: 6 * 7 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
count := 6 * 7

export default function Home()
<h1>Hello from a Civet route! The answer is {count}.</h1>
Loading
Loading