From 9df8655c23ba9f147b82694a15f0dc86b196f488 Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Sat, 4 Oct 2025 13:20:24 -0500 Subject: [PATCH 1/3] feat: add strapi addon --- frameworks/react-cra/add-ons/strapi/README.md | 14 +++++ .../strapi/assets/_dot_env.local.append | 2 + .../strapi/assets/src/lib/strapiClient.ts | 7 +++ .../strapi/assets/src/routes/demo/strapi.tsx | 57 ++++++++++++++++++ frameworks/react-cra/add-ons/strapi/info.json | 18 ++++++ .../react-cra/add-ons/strapi/package.json | 5 ++ .../react-cra/add-ons/strapi/small-logo.svg | 8 +++ frameworks/solid/add-ons/strapi/README.md | 14 +++++ .../strapi/assets/_dot_env.local.append | 2 + .../strapi/assets/src/lib/strapiClient.ts | 7 +++ .../strapi/assets/src/routes/demo/strapi.tsx | 58 +++++++++++++++++++ frameworks/solid/add-ons/strapi/info.json | 18 ++++++ frameworks/solid/add-ons/strapi/package.json | 5 ++ .../solid/add-ons/strapi/small-logo.svg | 8 +++ 14 files changed, 223 insertions(+) create mode 100644 frameworks/react-cra/add-ons/strapi/README.md create mode 100644 frameworks/react-cra/add-ons/strapi/assets/_dot_env.local.append create mode 100644 frameworks/react-cra/add-ons/strapi/assets/src/lib/strapiClient.ts create mode 100644 frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx create mode 100644 frameworks/react-cra/add-ons/strapi/info.json create mode 100644 frameworks/react-cra/add-ons/strapi/package.json create mode 100644 frameworks/react-cra/add-ons/strapi/small-logo.svg create mode 100644 frameworks/solid/add-ons/strapi/README.md create mode 100644 frameworks/solid/add-ons/strapi/assets/_dot_env.local.append create mode 100644 frameworks/solid/add-ons/strapi/assets/src/lib/strapiClient.ts create mode 100644 frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx create mode 100644 frameworks/solid/add-ons/strapi/info.json create mode 100644 frameworks/solid/add-ons/strapi/package.json create mode 100644 frameworks/solid/add-ons/strapi/small-logo.svg diff --git a/frameworks/react-cra/add-ons/strapi/README.md b/frameworks/react-cra/add-ons/strapi/README.md new file mode 100644 index 00000000..7cd4c70c --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/README.md @@ -0,0 +1,14 @@ +## Setting up Strapi + +The current setup shows an example of how to use Strapi with an articles collection which is part of the example structure & data. + +- Create a local running copy of the strapi admin + +```bash +pnpx create-strapi@latest my-strapi-project +cd my-strapi-project +pnpm dev +``` + +- Login and publish the example articles to see them on the strapi demo page. +- Set the `VITE_STRAPI_URL` environment variable in your `.env.local`. (For local it should be http://localhost:1337/api) diff --git a/frameworks/react-cra/add-ons/strapi/assets/_dot_env.local.append b/frameworks/react-cra/add-ons/strapi/assets/_dot_env.local.append new file mode 100644 index 00000000..d9791ecc --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/assets/_dot_env.local.append @@ -0,0 +1,2 @@ +# Strapi configuration +VITE_STRAPI_URL="http://localhost:1337/api" \ No newline at end of file diff --git a/frameworks/react-cra/add-ons/strapi/assets/src/lib/strapiClient.ts b/frameworks/react-cra/add-ons/strapi/assets/src/lib/strapiClient.ts new file mode 100644 index 00000000..0fd74d6b --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/assets/src/lib/strapiClient.ts @@ -0,0 +1,7 @@ +import { strapi } from "@strapi/client"; + +export const strapiClient = strapi({ + baseURL: import.meta.env.VITE_STRAPI_URL, +}); + +export const articles = strapiClient.collection("articles"); diff --git a/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx new file mode 100644 index 00000000..aeb36aba --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx @@ -0,0 +1,57 @@ +import { articles } from '@/lib/strapiClient' +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/demo/strapi')({ + component: RouteComponent, + loader: async () => { + const { data: strapiArticles } = await articles.find() + return strapiArticles + }, +}) + +function RouteComponent() { + const strapiArticles = Route.useLoaderData() + + return ( +
+

Strapi Articles

+ + {strapiArticles && strapiArticles.length > 0 ? ( +
+ {strapiArticles.map((article: any) => ( +
+

+ {article.title || article.attributes?.title || 'Untitled'} +

+ + {(article.description || article.attributes?.description) && ( +

+ {article.description || article.attributes?.description} +

+ )} + + {(article.content || article.attributes?.content) && ( +

+ {article.content || article.attributes?.content} +

+ )} + + {(article.createdAt || article.attributes?.createdAt) && ( +

+ {new Date( + article.createdAt || article.attributes?.createdAt, + ).toLocaleDateString()} +

+ )} +
+ ))} +
+ ) : ( +

No articles found.

+ )} +
+ ) +} diff --git a/frameworks/react-cra/add-ons/strapi/info.json b/frameworks/react-cra/add-ons/strapi/info.json new file mode 100644 index 00000000..a9a3f0dd --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/info.json @@ -0,0 +1,18 @@ +{ + "name": "Strapi", + "description": "Use the Strapi CMS to manage your content.", + "link": "https://strapi.io/", + "phase": "add-on", + "type": "add-on", + "modes": [ + "file-router" + ], + "routes": [ + { + "url": "/demo/strapi", + "name": "Strapi", + "path": "src/routes/demo.strapi.tsx", + "jsName": "StrapiDemo" + } + ] +} \ No newline at end of file diff --git a/frameworks/react-cra/add-ons/strapi/package.json b/frameworks/react-cra/add-ons/strapi/package.json new file mode 100644 index 00000000..2f040cae --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@strapi/client": "^1.5.0" + } +} \ No newline at end of file diff --git a/frameworks/react-cra/add-ons/strapi/small-logo.svg b/frameworks/react-cra/add-ons/strapi/small-logo.svg new file mode 100644 index 00000000..58b47d87 --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/small-logo.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/frameworks/solid/add-ons/strapi/README.md b/frameworks/solid/add-ons/strapi/README.md new file mode 100644 index 00000000..7cd4c70c --- /dev/null +++ b/frameworks/solid/add-ons/strapi/README.md @@ -0,0 +1,14 @@ +## Setting up Strapi + +The current setup shows an example of how to use Strapi with an articles collection which is part of the example structure & data. + +- Create a local running copy of the strapi admin + +```bash +pnpx create-strapi@latest my-strapi-project +cd my-strapi-project +pnpm dev +``` + +- Login and publish the example articles to see them on the strapi demo page. +- Set the `VITE_STRAPI_URL` environment variable in your `.env.local`. (For local it should be http://localhost:1337/api) diff --git a/frameworks/solid/add-ons/strapi/assets/_dot_env.local.append b/frameworks/solid/add-ons/strapi/assets/_dot_env.local.append new file mode 100644 index 00000000..d9791ecc --- /dev/null +++ b/frameworks/solid/add-ons/strapi/assets/_dot_env.local.append @@ -0,0 +1,2 @@ +# Strapi configuration +VITE_STRAPI_URL="http://localhost:1337/api" \ No newline at end of file diff --git a/frameworks/solid/add-ons/strapi/assets/src/lib/strapiClient.ts b/frameworks/solid/add-ons/strapi/assets/src/lib/strapiClient.ts new file mode 100644 index 00000000..0fd74d6b --- /dev/null +++ b/frameworks/solid/add-ons/strapi/assets/src/lib/strapiClient.ts @@ -0,0 +1,7 @@ +import { strapi } from "@strapi/client"; + +export const strapiClient = strapi({ + baseURL: import.meta.env.VITE_STRAPI_URL, +}); + +export const articles = strapiClient.collection("articles"); diff --git a/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx new file mode 100644 index 00000000..1d02d265 --- /dev/null +++ b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx @@ -0,0 +1,58 @@ +import { articles } from '../../lib/strapiClient' +import { createFileRoute } from '@tanstack/solid-router' +import { Show, For } from 'solid-js' + +export const Route = createFileRoute('/demo/strapi')({ + component: RouteComponent, + loader: async () => { + const { data: strapiArticles } = await articles.find() + return strapiArticles + }, +}) + +function RouteComponent() { + const strapiArticles = Route.useLoaderData() + + return ( +
+

Strapi Articles

+ + 0} + fallback={

No articles found.

} + > +
+ + {(article) => ( +
+

+ {article.title || article.attributes?.title || 'Untitled'} +

+ + {(article.description || article.attributes?.description) && ( +

+ {article.description || article.attributes?.description} +

+ )} + + {(article.content || article.attributes?.content) && ( +

+ {article.content || article.attributes?.content} +

+ )} + + {(article.createdAt || article.attributes?.createdAt) && ( +

+ {new Date( + article.createdAt || article.attributes?.createdAt, + ).toLocaleDateString()} +

+ )} +
+ )} +
+
+
+
+ ) +} diff --git a/frameworks/solid/add-ons/strapi/info.json b/frameworks/solid/add-ons/strapi/info.json new file mode 100644 index 00000000..a9a3f0dd --- /dev/null +++ b/frameworks/solid/add-ons/strapi/info.json @@ -0,0 +1,18 @@ +{ + "name": "Strapi", + "description": "Use the Strapi CMS to manage your content.", + "link": "https://strapi.io/", + "phase": "add-on", + "type": "add-on", + "modes": [ + "file-router" + ], + "routes": [ + { + "url": "/demo/strapi", + "name": "Strapi", + "path": "src/routes/demo.strapi.tsx", + "jsName": "StrapiDemo" + } + ] +} \ No newline at end of file diff --git a/frameworks/solid/add-ons/strapi/package.json b/frameworks/solid/add-ons/strapi/package.json new file mode 100644 index 00000000..2f040cae --- /dev/null +++ b/frameworks/solid/add-ons/strapi/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@strapi/client": "^1.5.0" + } +} \ No newline at end of file diff --git a/frameworks/solid/add-ons/strapi/small-logo.svg b/frameworks/solid/add-ons/strapi/small-logo.svg new file mode 100644 index 00000000..58b47d87 --- /dev/null +++ b/frameworks/solid/add-ons/strapi/small-logo.svg @@ -0,0 +1,8 @@ + + + + + + + + From 85c7e0b4d00a805683dfaa14fb327e94fff2ab77 Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Sat, 4 Oct 2025 13:57:40 -0500 Subject: [PATCH 2/3] feat: improve styling with dark theme --- .../strapi/assets/src/routes/demo/strapi.tsx | 81 ++++++++++-------- .../src/routes/demo/strapi_.$articleId.tsx | 78 +++++++++++++++++ .../strapi/assets/src/routes/demo/strapi.tsx | 83 +++++++++++-------- .../src/routes/demo/strapi_.$articleId.tsx | 78 +++++++++++++++++ 4 files changed, 248 insertions(+), 72 deletions(-) create mode 100644 frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx create mode 100644 frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx diff --git a/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx index aeb36aba..bb9fc896 100644 --- a/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx +++ b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi.tsx @@ -1,5 +1,5 @@ import { articles } from '@/lib/strapiClient' -import { createFileRoute } from '@tanstack/react-router' +import { createFileRoute, Link } from '@tanstack/react-router' export const Route = createFileRoute('/demo/strapi')({ component: RouteComponent, @@ -13,45 +13,54 @@ function RouteComponent() { const strapiArticles = Route.useLoaderData() return ( -
-

Strapi Articles

+
+
+

+ + Strapi + {' '} + Articles +

- {strapiArticles && strapiArticles.length > 0 ? ( -
- {strapiArticles.map((article: any) => ( -
-

- {article.title || article.attributes?.title || 'Untitled'} -

+ {strapiArticles && strapiArticles.length > 0 ? ( +
+ {strapiArticles.map((article) => ( + +
+

+ {article.title || 'Untitled'} +

- {(article.description || article.attributes?.description) && ( -

- {article.description || article.attributes?.description} -

- )} + {article.description && ( +

+ {article.description} +

+ )} - {(article.content || article.attributes?.content) && ( -

- {article.content || article.attributes?.content} -

- )} + {article.content && ( +

+ {article.content} +

+ )} - {(article.createdAt || article.attributes?.createdAt) && ( -

- {new Date( - article.createdAt || article.attributes?.createdAt, - ).toLocaleDateString()} -

- )} -
- ))} -
- ) : ( -

No articles found.

- )} + {article.createdAt && ( +

+ {new Date(article.createdAt).toLocaleDateString()} +

+ )} +
+ + ))} +
+ ) : ( +

No articles found.

+ )} +
) } diff --git a/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx new file mode 100644 index 00000000..9f8a589a --- /dev/null +++ b/frameworks/react-cra/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx @@ -0,0 +1,78 @@ +import { articles } from '@/lib/strapiClient' +import { createFileRoute, Link } from '@tanstack/react-router' + +export const Route = createFileRoute('/demo/strapi_/$articleId')({ + component: RouteComponent, + loader: async ({ params }) => { + const { data: article } = await articles.findOne(params.articleId) + return article + }, +}) + +function RouteComponent() { + const article = Route.useLoaderData() + + return ( +
+
+ + + + + Back to Articles + + +
+

+ {article?.title || 'Untitled'} +

+ + {article?.createdAt && ( +

+ Published on{' '} + {new Date(article?.createdAt).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + })} +

+ )} + + {article?.description && ( +
+

+ Description +

+

+ {article?.description} +

+
+ )} + + {article?.content && ( +
+

+ Content +

+
+ {article?.content} +
+
+ )} +
+
+
+ ) +} diff --git a/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx index 1d02d265..d979d22f 100644 --- a/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx +++ b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi.tsx @@ -1,5 +1,5 @@ import { articles } from '../../lib/strapiClient' -import { createFileRoute } from '@tanstack/solid-router' +import { createFileRoute, Link } from '@tanstack/solid-router' import { Show, For } from 'solid-js' export const Route = createFileRoute('/demo/strapi')({ @@ -14,45 +14,56 @@ function RouteComponent() { const strapiArticles = Route.useLoaderData() return ( -
-

Strapi Articles

+
+
+

+ + Strapi + {' '} + Articles +

- 0} - fallback={

No articles found.

} - > -
- - {(article) => ( -
-

- {article.title || article.attributes?.title || 'Untitled'} -

+ 0} + fallback={

No articles found.

} + > +
+ + {(article) => ( + +
+

+ {article.title || 'Untitled'} +

- {(article.description || article.attributes?.description) && ( -

- {article.description || article.attributes?.description} -

- )} + {article.description && ( +

+ {article.description} +

+ )} - {(article.content || article.attributes?.content) && ( -

- {article.content || article.attributes?.content} -

- )} + {article.content && ( +

+ {article.content} +

+ )} - {(article.createdAt || article.attributes?.createdAt) && ( -

- {new Date( - article.createdAt || article.attributes?.createdAt, - ).toLocaleDateString()} -

- )} -
- )} -
-
-
+ {article.createdAt && ( +

+ {new Date(article.createdAt).toLocaleDateString()} +

+ )} +
+ + )} +
+
+
+
) } diff --git a/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx new file mode 100644 index 00000000..81ef1e24 --- /dev/null +++ b/frameworks/solid/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx @@ -0,0 +1,78 @@ +import { articles } from '../../lib/strapiClient' +import { createFileRoute, Link } from '@tanstack/solid-router' + +export const Route = createFileRoute('/demo/strapi_/$articleId')({ + component: RouteComponent, + loader: async ({ params }) => { + const { data: article } = await articles.findOne(params.articleId) + return article + }, +}) + +function RouteComponent() { + const article = Route.useLoaderData() + + return ( +
+
+ + + + + Back to Articles + + +
+

+ {article()?.title || 'Untitled'} +

+ + {article()?.createdAt && ( +

+ Published on{' '} + {new Date( + article()?.createdAt || article()?.attributes?.createdAt, + ).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + })} +

+ )} + + {article()?.description && ( +
+

+ Description +

+

+ {article()?.description || article()?.attributes?.description} +

+
+ )} + + {article()?.content && ( +
+

Content

+
+ {article()?.content} +
+
+ )} +
+
+
+ ) +} From f55f6a7174177dbbcff0b405c7ae722a051db677 Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Sat, 4 Oct 2025 14:09:46 -0500 Subject: [PATCH 3/3] fix: solid fouc on load --- frameworks/solid/add-ons/start/assets/src/router.tsx.ejs | 2 -- frameworks/solid/project/base/src/routes/__root.tsx.ejs | 5 +++++ .../solid/tests/snapshots/solid/solid-cr-ts-start-npm.json | 4 ++-- frameworks/solid/tests/snapshots/solid/solid-fr-ts-npm.json | 2 +- .../solid/tests/snapshots/solid/solid-fr-ts-tw-npm.json | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs b/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs index 053ebdf5..e6395c9a 100644 --- a/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs +++ b/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs @@ -3,8 +3,6 @@ import { createRouter } from '@tanstack/solid-router' // Import the generated route tree import { routeTree } from './routeTree.gen' -import './styles.css' - // Create a new router instance export const getRouter = () => { const router = createRouter({ diff --git a/frameworks/solid/project/base/src/routes/__root.tsx.ejs b/frameworks/solid/project/base/src/routes/__root.tsx.ejs index 2811160e..d579ba9f 100644 --- a/frameworks/solid/project/base/src/routes/__root.tsx.ejs +++ b/frameworks/solid/project/base/src/routes/__root.tsx.ejs @@ -12,7 +12,12 @@ import "@fontsource/inter" <%- init %> <% } } %> +import styleCss from "../styles.css?url"; + export const Route = createRootRouteWithContext()({ + head: () => ({ + links: [{ rel: "stylesheet", href: styleCss }], + }), shellComponent: RootComponent, }) diff --git a/frameworks/solid/tests/snapshots/solid/solid-cr-ts-start-npm.json b/frameworks/solid/tests/snapshots/solid/solid-cr-ts-start-npm.json index 83985fda..ca5f6dd3 100644 --- a/frameworks/solid/tests/snapshots/solid/solid-cr-ts-start-npm.json +++ b/frameworks/solid/tests/snapshots/solid/solid-cr-ts-start-npm.json @@ -7,8 +7,8 @@ "/public/manifest.json": "{\n \"short_name\": \"TanStack App\",\n \"name\": \"Create TanStack App Sample\",\n \"icons\": [\n {\n \"src\": \"favicon.ico\",\n \"sizes\": \"64x64 32x32 24x24 16x16\",\n \"type\": \"image/x-icon\"\n },\n {\n \"src\": \"logo192.png\",\n \"type\": \"image/png\",\n \"sizes\": \"192x192\"\n },\n {\n \"src\": \"logo512.png\",\n \"type\": \"image/png\",\n \"sizes\": \"512x512\"\n }\n ],\n \"start_url\": \".\",\n \"display\": \"standalone\",\n \"theme_color\": \"#000000\",\n \"background_color\": \"#ffffff\"\n}\n", "/public/robots.txt": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\nDisallow:\n", "/src/components/Header.tsx": "import { Link } from '@tanstack/solid-router'\n\nimport { createSignal } from 'solid-js'\nimport {\n ChevronDown,\n ChevronRight,\n Globe,\n Home,\n Layers,\n Menu,\n X,\n} from 'lucide-solid'\n\nexport default function Header() {\n const [isOpen, setIsOpen] = createSignal(false)\n const [groupedExpanded, setGroupedExpanded] = createSignal<\n Record\n >({})\n\n return (\n <>\n
\n setIsOpen(true)}\n class=\"p-2 hover:bg-gray-700 rounded-lg transition-colors\"\n aria-label=\"Open menu\"\n >\n \n \n

\n \n \n \n

\n
\n\n \n
\n

Navigation

\n setIsOpen(false)}\n class=\"p-2 hover:bg-gray-800 rounded-lg transition-colors\"\n aria-label=\"Close menu\"\n >\n \n \n
\n\n \n \n \n )\n}\n", - "/src/router.tsx": "import { createRouter } from '@tanstack/solid-router'\n\n// Import the generated route tree\nimport { routeTree } from './routeTree.gen'\n\nimport './styles.css'\n\n// Create a new router instance\nexport const getRouter = () => {\n const router = createRouter({\n routeTree,\n scrollRestoration: true,\n })\n return router\n}\n", - "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport Header from '../components/Header'\n\nexport const Route = createRootRouteWithContext()({\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n
\n\n \n \n\n \n \n )\n}\n", + "/src/router.tsx": "import { createRouter } from '@tanstack/solid-router'\n\n// Import the generated route tree\nimport { routeTree } from './routeTree.gen'\n\n// Create a new router instance\nexport const getRouter = () => {\n const router = createRouter({\n routeTree,\n scrollRestoration: true,\n })\n return router\n}\n", + "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport Header from '../components/Header'\n\nimport styleCss from '../styles.css?url'\n\nexport const Route = createRootRouteWithContext()({\n head: () => ({\n links: [{ rel: 'stylesheet', href: styleCss }],\n }),\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n
\n\n \n \n\n \n \n )\n}\n", "/src/routes/demo.start.server-funcs.tsx": "import * as fs from 'fs'\nimport { createFileRoute, useRouter } from '@tanstack/solid-router'\nimport { createServerFn } from '@tanstack/solid-start'\n\nconst filePath = 'count.txt'\n\nasync function readCount() {\n return parseInt(\n await fs.promises.readFile(filePath, 'utf-8').catch(() => '0'),\n )\n}\n\nconst getCount = createServerFn({\n method: 'GET',\n}).handler(() => {\n return readCount()\n})\n\nconst updateCount = createServerFn({ method: 'POST' })\n .inputValidator((d: number) => d)\n .handler(async ({ data }) => {\n const count = await readCount()\n await fs.promises.writeFile(filePath, `${count + data}`)\n })\n\nexport const Route = createFileRoute('/demo/start/server-funcs')({\n component: Home,\n loader: async () => await getCount(),\n})\n\nfunction Home() {\n const router = useRouter()\n const state = Route.useLoaderData()\n\n return (\n
\n {\n updateCount({ data: 1 }).then(() => {\n router.invalidate()\n })\n }}\n class=\"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded\"\n >\n Add 1 to {state}?\n \n
\n )\n}\n", "/src/routes/index.tsx": "import { createFileRoute } from '@tanstack/solid-router'\n\nimport {\n Zap,\n Server,\n Route as RouteIcon,\n Shield,\n Waves,\n Sparkles,\n} from 'lucide-solid'\n\nexport const Route = createFileRoute('/')({\n component: App,\n})\n\nfunction App() {\n const features = [\n {\n icon: ,\n title: 'Powerful Server Functions',\n description:\n 'Write server-side code that seamlessly integrates with your client components. Type-safe, secure, and simple.',\n },\n {\n icon: ,\n title: 'Flexible Server Side Rendering',\n description:\n 'Full-document SSR, streaming, and progressive enhancement out of the box. Control exactly what renders where.',\n },\n {\n icon: ,\n title: 'API Routes',\n description:\n 'Build type-safe API endpoints alongside your application. No separate backend needed.',\n },\n {\n icon: ,\n title: 'Strongly Typed Everything',\n description:\n 'End-to-end type safety from server to client. Catch errors before they reach production.',\n },\n {\n icon: ,\n title: 'Full Streaming Support',\n description:\n 'Stream data from server to client progressively. Perfect for AI applications and real-time updates.',\n },\n {\n icon: ,\n title: 'Next Generation Ready',\n description:\n 'Built from the ground up for modern web applications. Deploy anywhere JavaScript runs.',\n },\n ]\n\n return (\n
\n
\n
\n
\n
\n \n

\n TANSTACK{' '}\n \n START\n \n

\n
\n

\n The framework for next generation AI applications\n

\n

\n Full-stack framework powered by TanStack Router for React and Solid.\n Build modern applications with server functions, streaming, and type\n safety.\n

\n
\n \n Documentation\n \n

\n Begin your TanStack Start journey by editing{' '}\n \n /src/routes/index.tsx\n \n

\n
\n
\n
\n\n
\n
\n {features.map((feature, index) => (\n \n
{feature.icon}
\n

\n {feature.title}\n

\n

{feature.description}

\n
\n ))}\n
\n \n
\n )\n}\n", "/src/styles.css": "@import \"tailwindcss\";\n\nbody {\n @apply m-0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\",\n \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\",\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\",\n monospace;\n}\n", diff --git a/frameworks/solid/tests/snapshots/solid/solid-fr-ts-npm.json b/frameworks/solid/tests/snapshots/solid/solid-fr-ts-npm.json index 381efe9e..23c6031d 100644 --- a/frameworks/solid/tests/snapshots/solid/solid-fr-ts-npm.json +++ b/frameworks/solid/tests/snapshots/solid/solid-fr-ts-npm.json @@ -8,7 +8,7 @@ "/public/robots.txt": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\nDisallow:\n", "/src/App.css": ".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}", "/src/main.tsx": "import { RouterProvider, createRouter } from '@tanstack/solid-router'\nimport { render } from 'solid-js/web'\n\nimport { routeTree } from './routeTree.gen'\nimport './styles.css'\n\nconst router = createRouter({\n routeTree,\n defaultPreload: 'intent',\n scrollRestoration: true,\n defaultPreloadStaleTime: 0,\n})\n\ndeclare module '@tanstack/solid-router' {\n interface Register {\n router: typeof router\n }\n}\n\nfunction App() {\n return (\n <>\n \n \n )\n}\n\nconst rootElement = document.getElementById('app')\nif (rootElement) {\n render(() => , rootElement)\n}\n", - "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nexport const Route = createRootRouteWithContext()({\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n \n \n\n \n \n )\n}\n", + "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport styleCss from '../styles.css?url'\n\nexport const Route = createRootRouteWithContext()({\n head: () => ({\n links: [{ rel: 'stylesheet', href: styleCss }],\n }),\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n \n \n\n \n \n )\n}\n", "/src/routes/index.tsx": "import * as Solid from 'solid-js'\nimport { createFileRoute } from '@tanstack/solid-router'\n\nimport logo from '../logo.svg'\n\nexport const Route = createFileRoute('/')({\n component: IndexComponent,\n})\n\nfunction IndexComponent() {\n return (\n
\n
\n \n

\n Edit src/routes/index.tsx and save to reload.\n

\n \n Learn Solid\n \n \n Learn TanStack\n \n
\n
\n )\n}\n", "/src/styles.css": "@import \"tailwindcss\";\n\nbody {\n @apply m-0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\",\n \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\",\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\",\n monospace;\n}\n", "README.md": "Welcome to your new TanStack app! \n\n# Getting Started\n\nTo run this application:\n\n```bash\nnpm install\nnpm run start\n```\n\n# Building For Production\n\nTo build this application for production:\n\n```bash\nnpm run build\n```\n\n## Styling\n\nThis project uses [Tailwind CSS](https://tailwindcss.com/) for styling.\n\n\n\n## Routing\nThis project uses [TanStack Router](https://tanstack.com/router). The initial setup is a file based router. Which means that the routes are managed as files in `src/routes`.\n\n### Adding A Route\n\nTo add a new route to your application just add another a new file in the `./src/routes` directory.\n\nTanStack will automatically generate the content of the route file for you.\n\nNow that you have two routes you can use a `Link` component to navigate between them.\n\n### Adding Links\n\nTo use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/solid-router`.\n\n```tsx\nimport { Link } from \"@tanstack/solid-router\";\n```\n\nThen anywhere in your JSX you can use it like so:\n\n```tsx\nAbout\n```\n\nThis will create a link that will navigate to the `/about` route.\n\nMore information on the `Link` component can be found in the [Link documentation](https://tanstack.com/router/v1/docs/framework/solid/api/router/linkComponent).\n\n### Using A Layout\n\nIn the File Based Routing setup the layout is located in `src/routes/__root.tsx`. Anything you add to the root route will appear in all the routes. The route content will appear in the JSX where you use the `` component.\n\nHere is an example layout that includes a header:\n\n```tsx\nimport { Outlet, createRootRoute } from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport { Link } from \"@tanstack/solid-router\";\n\nexport const Route = createRootRoute({\n component: () => (\n <>\n
\n \n
\n \n \n \n ),\n})\n```\n\nThe `` component is not required so you can remove it if you don't want it in your layout.\n\nMore information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/routing-concepts#layouts).\n\n## Data Fetching\n\nThere are multiple ways to fetch data in your application. You can use TanStack Query to fetch data from a server. But you can also use the `loader` functionality built into TanStack Router to load the data for a route before it's rendered.\n\nFor example:\n\n```tsx\nconst peopleRoute = createRoute({\n getParentRoute: () => rootRoute,\n path: \"/people\",\n loader: async () => {\n const response = await fetch(\"https://swapi.dev/api/people\");\n return response.json() as Promise<{\n results: {\n name: string;\n }[];\n }>;\n },\n component: () => {\n const data = peopleRoute.useLoaderData();\n return (\n
    \n {data.results.map((person) => (\n
  • {person.name}
  • \n ))}\n
\n );\n },\n});\n```\n\nLoaders simplify your data fetching logic dramatically. Check out more information in the [Loader documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#loader-parameters).\n\n# Demo files\n\nFiles prefixed with `demo` can be safely deleted. They are there to provide a starting point for you to play around with the features you've installed.\n\n\n\n# Learn More\n\nYou can learn more about all of the offerings from TanStack in the [TanStack documentation](https://tanstack.com).\n", diff --git a/frameworks/solid/tests/snapshots/solid/solid-fr-ts-tw-npm.json b/frameworks/solid/tests/snapshots/solid/solid-fr-ts-tw-npm.json index 3226b0cc..7d7acbed 100644 --- a/frameworks/solid/tests/snapshots/solid/solid-fr-ts-tw-npm.json +++ b/frameworks/solid/tests/snapshots/solid/solid-fr-ts-tw-npm.json @@ -7,7 +7,7 @@ "/public/manifest.json": "{\n \"short_name\": \"TanStack App\",\n \"name\": \"Create TanStack App Sample\",\n \"icons\": [\n {\n \"src\": \"favicon.ico\",\n \"sizes\": \"64x64 32x32 24x24 16x16\",\n \"type\": \"image/x-icon\"\n },\n {\n \"src\": \"logo192.png\",\n \"type\": \"image/png\",\n \"sizes\": \"192x192\"\n },\n {\n \"src\": \"logo512.png\",\n \"type\": \"image/png\",\n \"sizes\": \"512x512\"\n }\n ],\n \"start_url\": \".\",\n \"display\": \"standalone\",\n \"theme_color\": \"#000000\",\n \"background_color\": \"#ffffff\"\n}\n", "/public/robots.txt": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\nDisallow:\n", "/src/main.tsx": "import { RouterProvider, createRouter } from '@tanstack/solid-router'\nimport { render } from 'solid-js/web'\n\nimport { routeTree } from './routeTree.gen'\nimport './styles.css'\n\nconst router = createRouter({\n routeTree,\n defaultPreload: 'intent',\n scrollRestoration: true,\n defaultPreloadStaleTime: 0,\n})\n\ndeclare module '@tanstack/solid-router' {\n interface Register {\n router: typeof router\n }\n}\n\nfunction App() {\n return (\n <>\n \n \n )\n}\n\nconst rootElement = document.getElementById('app')\nif (rootElement) {\n render(() => , rootElement)\n}\n", - "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nexport const Route = createRootRouteWithContext()({\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n \n \n\n \n \n )\n}\n", + "/src/routes/__root.tsx": "import {\n HeadContent,\n Outlet,\n Scripts,\n createRootRouteWithContext,\n} from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport styleCss from '../styles.css?url'\n\nexport const Route = createRootRouteWithContext()({\n head: () => ({\n links: [{ rel: 'stylesheet', href: styleCss }],\n }),\n shellComponent: RootComponent,\n})\n\nfunction RootComponent() {\n return (\n <>\n \n\n \n \n\n \n \n )\n}\n", "/src/routes/index.tsx": "import * as Solid from 'solid-js'\nimport { createFileRoute } from '@tanstack/solid-router'\n\nimport logo from '../logo.svg'\n\nexport const Route = createFileRoute('/')({\n component: IndexComponent,\n})\n\nfunction IndexComponent() {\n return (\n
\n
\n \n

\n Edit src/routes/index.tsx and save to reload.\n

\n \n Learn Solid\n \n \n Learn TanStack\n \n
\n
\n )\n}\n", "/src/styles.css": "@import \"tailwindcss\";\n\nbody {\n @apply m-0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\",\n \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\",\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\",\n monospace;\n}\n", "README.md": "Welcome to your new TanStack app! \n\n# Getting Started\n\nTo run this application:\n\n```bash\nnpm install\nnpm run start\n```\n\n# Building For Production\n\nTo build this application for production:\n\n```bash\nnpm run build\n```\n\n## Styling\n\nThis project uses [Tailwind CSS](https://tailwindcss.com/) for styling.\n\n\n\n## Routing\nThis project uses [TanStack Router](https://tanstack.com/router). The initial setup is a file based router. Which means that the routes are managed as files in `src/routes`.\n\n### Adding A Route\n\nTo add a new route to your application just add another a new file in the `./src/routes` directory.\n\nTanStack will automatically generate the content of the route file for you.\n\nNow that you have two routes you can use a `Link` component to navigate between them.\n\n### Adding Links\n\nTo use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/solid-router`.\n\n```tsx\nimport { Link } from \"@tanstack/solid-router\";\n```\n\nThen anywhere in your JSX you can use it like so:\n\n```tsx\nAbout\n```\n\nThis will create a link that will navigate to the `/about` route.\n\nMore information on the `Link` component can be found in the [Link documentation](https://tanstack.com/router/v1/docs/framework/solid/api/router/linkComponent).\n\n### Using A Layout\n\nIn the File Based Routing setup the layout is located in `src/routes/__root.tsx`. Anything you add to the root route will appear in all the routes. The route content will appear in the JSX where you use the `` component.\n\nHere is an example layout that includes a header:\n\n```tsx\nimport { Outlet, createRootRoute } from '@tanstack/solid-router'\nimport { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'\n\nimport { Link } from \"@tanstack/solid-router\";\n\nexport const Route = createRootRoute({\n component: () => (\n <>\n
\n \n
\n \n \n \n ),\n})\n```\n\nThe `` component is not required so you can remove it if you don't want it in your layout.\n\nMore information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/routing-concepts#layouts).\n\n## Data Fetching\n\nThere are multiple ways to fetch data in your application. You can use TanStack Query to fetch data from a server. But you can also use the `loader` functionality built into TanStack Router to load the data for a route before it's rendered.\n\nFor example:\n\n```tsx\nconst peopleRoute = createRoute({\n getParentRoute: () => rootRoute,\n path: \"/people\",\n loader: async () => {\n const response = await fetch(\"https://swapi.dev/api/people\");\n return response.json() as Promise<{\n results: {\n name: string;\n }[];\n }>;\n },\n component: () => {\n const data = peopleRoute.useLoaderData();\n return (\n
    \n {data.results.map((person) => (\n
  • {person.name}
  • \n ))}\n
\n );\n },\n});\n```\n\nLoaders simplify your data fetching logic dramatically. Check out more information in the [Loader documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#loader-parameters).\n\n# Demo files\n\nFiles prefixed with `demo` can be safely deleted. They are there to provide a starting point for you to play around with the features you've installed.\n\n\n\n# Learn More\n\nYou can learn more about all of the offerings from TanStack in the [TanStack documentation](https://tanstack.com).\n",