From ec47881ae05b4bad60699cd1dc915e0ab353001e Mon Sep 17 00:00:00 2001 From: oedotme Date: Sat, 5 Nov 2022 16:37:48 +0200 Subject: [PATCH] docs: add solid-router basic example --- examples/solid-router/basic/.gitignore | 2 ++ examples/solid-router/basic/index.html | 13 ++++++++++++ examples/solid-router/basic/package.json | 21 +++++++++++++++++++ examples/solid-router/basic/src/main.tsx | 4 ++++ examples/solid-router/basic/src/pages/404.tsx | 3 +++ .../solid-router/basic/src/pages/_app.tsx | 15 +++++++++++++ .../solid-router/basic/src/pages/about.tsx | 3 +++ .../solid-router/basic/src/pages/index.tsx | 3 +++ examples/solid-router/basic/tsconfig.json | 21 +++++++++++++++++++ examples/solid-router/basic/vite.config.ts | 4 ++++ pnpm-lock.yaml | 17 +++++++++++++++ pnpm-workspace.yaml | 1 + 12 files changed, 107 insertions(+) create mode 100644 examples/solid-router/basic/.gitignore create mode 100644 examples/solid-router/basic/index.html create mode 100644 examples/solid-router/basic/package.json create mode 100644 examples/solid-router/basic/src/main.tsx create mode 100644 examples/solid-router/basic/src/pages/404.tsx create mode 100644 examples/solid-router/basic/src/pages/_app.tsx create mode 100644 examples/solid-router/basic/src/pages/about.tsx create mode 100644 examples/solid-router/basic/src/pages/index.tsx create mode 100644 examples/solid-router/basic/tsconfig.json create mode 100644 examples/solid-router/basic/vite.config.ts diff --git a/examples/solid-router/basic/.gitignore b/examples/solid-router/basic/.gitignore new file mode 100644 index 0000000..de4d1f0 --- /dev/null +++ b/examples/solid-router/basic/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules diff --git a/examples/solid-router/basic/index.html b/examples/solid-router/basic/index.html new file mode 100644 index 0000000..4925a0b --- /dev/null +++ b/examples/solid-router/basic/index.html @@ -0,0 +1,13 @@ + + + + + + Generouted - Basic example + + + +
+ + + diff --git a/examples/solid-router/basic/package.json b/examples/solid-router/basic/package.json new file mode 100644 index 0000000..346904f --- /dev/null +++ b/examples/solid-router/basic/package.json @@ -0,0 +1,21 @@ +{ + "name": "basic", + "version": "1.0.0", + "description": "Generated file-based routes for Solid Router and Vite basic example", + "author": "Omar Elhawary (https://omarelhawary.me)", + "license": "MIT", + "scripts": { + "dev": "vite dev --port 3000", + "build": "vite build" + }, + "dependencies": { + "@solidjs/router": "^0.5.0", + "generouted": "workspace:*", + "solid-js": "^1.6.1" + }, + "devDependencies": { + "typescript": "^4.8.3", + "vite": "^3.1.2", + "vite-plugin-solid": "^2.3.10" + } +} diff --git a/examples/solid-router/basic/src/main.tsx b/examples/solid-router/basic/src/main.tsx new file mode 100644 index 0000000..6b6ba49 --- /dev/null +++ b/examples/solid-router/basic/src/main.tsx @@ -0,0 +1,4 @@ +import { render } from 'solid-js/web' +import { Routes } from 'generouted/solid-router' + +render(Routes, document.getElementById('app') as HTMLElement) diff --git a/examples/solid-router/basic/src/pages/404.tsx b/examples/solid-router/basic/src/pages/404.tsx new file mode 100644 index 0000000..6e9fc90 --- /dev/null +++ b/examples/solid-router/basic/src/pages/404.tsx @@ -0,0 +1,3 @@ +export default function NotFound() { + return

404

+} diff --git a/examples/solid-router/basic/src/pages/_app.tsx b/examples/solid-router/basic/src/pages/_app.tsx new file mode 100644 index 0000000..e9592f9 --- /dev/null +++ b/examples/solid-router/basic/src/pages/_app.tsx @@ -0,0 +1,15 @@ +import { ParentProps } from 'solid-js' +import { A } from '@solidjs/router' + +export default function App(props: ParentProps) { + return ( +
+
+ Home + About +
+ +
{props.children}
+
+ ) +} diff --git a/examples/solid-router/basic/src/pages/about.tsx b/examples/solid-router/basic/src/pages/about.tsx new file mode 100644 index 0000000..5f9be08 --- /dev/null +++ b/examples/solid-router/basic/src/pages/about.tsx @@ -0,0 +1,3 @@ +export default function About() { + return

About - Basic

+} diff --git a/examples/solid-router/basic/src/pages/index.tsx b/examples/solid-router/basic/src/pages/index.tsx new file mode 100644 index 0000000..09a718b --- /dev/null +++ b/examples/solid-router/basic/src/pages/index.tsx @@ -0,0 +1,3 @@ +export default function Home() { + return

Home - Basic

+} diff --git a/examples/solid-router/basic/tsconfig.json b/examples/solid-router/basic/tsconfig.json new file mode 100644 index 0000000..2e84fbf --- /dev/null +++ b/examples/solid-router/basic/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "target": "es2017", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + "types": ["vite/client"] + }, + "include": ["./src"] +} diff --git a/examples/solid-router/basic/vite.config.ts b/examples/solid-router/basic/vite.config.ts new file mode 100644 index 0000000..a30e98c --- /dev/null +++ b/examples/solid-router/basic/vite.config.ts @@ -0,0 +1,4 @@ +import { defineConfig } from 'vite' +import solid from 'vite-plugin-solid' + +export default defineConfig({ plugins: [solid()] }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c2e6e6..01755cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,6 +162,23 @@ importers: typescript: 4.8.3 vite: 3.1.2 + examples/solid-router/basic: + specifiers: + '@solidjs/router': ^0.5.0 + generouted: workspace:* + solid-js: ^1.6.1 + typescript: ^4.8.3 + vite: ^3.1.2 + vite-plugin-solid: ^2.3.10 + dependencies: + '@solidjs/router': 0.5.0_solid-js@1.6.1 + generouted: link:../../.. + solid-js: 1.6.1 + devDependencies: + typescript: 4.8.3 + vite: 3.1.2 + vite-plugin-solid: 2.3.10_solid-js@1.6.1+vite@3.1.2 + packages: /@ampproject/remapping/2.2.0: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 85ce590..f52027f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - examples/react-location/* - examples/react-router/* + - examples/solid-router/*