create-qwik 0.0.108 → 0.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -19
- package/create-qwik.cjs +3 -0
- package/index.cjs +121 -0
- package/package.json +11 -7
- package/starters/apps/base/.prettierignore +6 -0
- package/starters/apps/base/README.md +41 -16
- package/starters/apps/base/gitignore +4 -6
- package/starters/apps/base/package.json +20 -23
- package/starters/apps/base/public/favicon.svg +1 -0
- package/starters/apps/base/src/entry.preview.tsx +6 -0
- package/starters/apps/base/src/entry.ssr.tsx +7 -5
- package/starters/apps/base/src/routes/service-worker.ts +9 -0
- package/starters/apps/base/tsconfig.json +5 -4
- package/starters/apps/base/vite.config.ts +3 -6
- package/starters/apps/blank/package.json +2 -15
- package/starters/apps/blank/src/components/header/header.css +37 -0
- package/starters/apps/blank/src/components/header/header.tsx +34 -0
- package/starters/apps/blank/src/components/icons/qwik.tsx +32 -0
- package/starters/apps/blank/src/components/router-head/router-head.tsx +43 -0
- package/starters/apps/blank/src/global.css +70 -3
- package/starters/apps/blank/src/root.tsx +17 -9
- package/starters/apps/blank/src/routes/index.tsx +81 -0
- package/starters/apps/{qwik-city → blank}/src/routes/layout.tsx +4 -6
- package/starters/apps/documentation-site/package.json +9 -0
- package/starters/apps/{qwik-city → documentation-site}/src/components/breadcrumbs/breadcrumbs.css +0 -0
- package/starters/apps/{qwik-city → documentation-site}/src/components/breadcrumbs/breadcrumbs.tsx +0 -0
- package/starters/apps/{qwik-city → documentation-site}/src/components/footer/footer.css +1 -1
- package/starters/apps/{qwik-city → documentation-site}/src/components/footer/footer.tsx +13 -6
- package/starters/apps/documentation-site/src/components/header/header.css +34 -0
- package/starters/apps/documentation-site/src/components/header/header.tsx +26 -0
- package/starters/apps/documentation-site/src/components/icons/qwik.tsx +20 -0
- package/starters/apps/{qwik-city → documentation-site}/src/components/menu/menu.css +0 -0
- package/starters/apps/{qwik-city → documentation-site}/src/components/menu/menu.tsx +5 -5
- package/starters/apps/documentation-site/src/components/on-this-page/on-this-page.css +33 -0
- package/starters/apps/documentation-site/src/components/on-this-page/on-this-page.tsx +62 -0
- package/starters/apps/documentation-site/src/components/router-head/router-head.tsx +43 -0
- package/starters/apps/documentation-site/src/global.css +66 -0
- package/starters/apps/documentation-site/src/root.tsx +26 -0
- package/starters/apps/documentation-site/src/routes/about-us/index.md +15 -0
- package/starters/apps/documentation-site/src/routes/docs/advanced/index.md +11 -0
- package/starters/apps/documentation-site/src/routes/docs/docs.css +22 -0
- package/starters/apps/documentation-site/src/routes/docs/getting-started/index.md +13 -0
- package/starters/apps/documentation-site/src/routes/docs/index.md +22 -0
- package/starters/apps/documentation-site/src/routes/docs/layout.tsx +25 -0
- package/starters/apps/documentation-site/src/routes/docs/menu.md +21 -0
- package/starters/apps/documentation-site/src/routes/index.tsx +89 -0
- package/starters/apps/documentation-site/src/routes/layout.tsx +15 -0
- package/starters/apps/library/package.json +1 -0
- package/starters/apps/{qwik-city → library}/tsconfig.json +1 -4
- package/starters/apps/library/vite.config.ts +1 -6
- package/create-qwik +0 -107
- package/index.js +0 -22
- package/starters/apps/base/public/favicon.ico +0 -0
- package/starters/apps/base/src/root.tsx +0 -14
- package/starters/apps/blank/src/components/app/app.tsx +0 -54
- package/starters/apps/blank/src/components/logo/logo.tsx +0 -16
- package/starters/apps/blank/src/entry.express.tsx +0 -59
- package/starters/apps/blank/src/entry.ssr.tsx +0 -15
- package/starters/apps/perf.prod/package.json +0 -22
- package/starters/apps/perf.prod/src/components/app/app.tsx +0 -189
- package/starters/apps/perf.prod/src/entry.express.tsx +0 -59
- package/starters/apps/perf.prod/src/entry.ssr.tsx +0 -15
- package/starters/apps/perf.prod/src/global.css +0 -3
- package/starters/apps/perf.prod/src/root.tsx +0 -18
- package/starters/apps/qwik-city/package.json +0 -19
- package/starters/apps/qwik-city/public/_headers +0 -2
- package/starters/apps/qwik-city/public/favicon.ico +0 -0
- package/starters/apps/qwik-city/public/favicons/android-chrome-192x192.png +0 -0
- package/starters/apps/qwik-city/public/favicons/android-chrome-256x256.png +0 -0
- package/starters/apps/qwik-city/public/favicons/apple-touch-icon.png +0 -0
- package/starters/apps/qwik-city/public/favicons/favicon.svg +0 -1
- package/starters/apps/qwik-city/public/logos/qwik-logo.svg +0 -1
- package/starters/apps/qwik-city/public/logos/qwik.svg +0 -1
- package/starters/apps/qwik-city/src/components/counter/counter.tsx +0 -19
- package/starters/apps/qwik-city/src/components/head/analytics.tsx +0 -13
- package/starters/apps/qwik-city/src/components/head/head.tsx +0 -34
- package/starters/apps/qwik-city/src/components/head/social.tsx +0 -10
- package/starters/apps/qwik-city/src/components/header/header.css +0 -46
- package/starters/apps/qwik-city/src/components/header/header.tsx +0 -36
- package/starters/apps/qwik-city/src/global.css +0 -24
- package/starters/apps/qwik-city/src/root.tsx +0 -16
- package/starters/apps/qwik-city/src/routes/about-us/index.tsx +0 -17
- package/starters/apps/qwik-city/src/routes/api/[org]/[user].json/index.ts +0 -15
- package/starters/apps/qwik-city/src/routes/api/api.css +0 -14
- package/starters/apps/qwik-city/src/routes/api/data.json/index.ts +0 -9
- package/starters/apps/qwik-city/src/routes/api/index@api.tsx +0 -34
- package/starters/apps/qwik-city/src/routes/api/layout-api.tsx +0 -37
- package/starters/apps/qwik-city/src/routes/blog/[...slug]/index.tsx +0 -36
- package/starters/apps/qwik-city/src/routes/blog/index.md +0 -7
- package/starters/apps/qwik-city/src/routes/blog/layout.tsx +0 -21
- package/starters/apps/qwik-city/src/routes/dashboard/dashboard.css +0 -14
- package/starters/apps/qwik-city/src/routes/dashboard/index.tsx +0 -15
- package/starters/apps/qwik-city/src/routes/dashboard/layout!.tsx +0 -44
- package/starters/apps/qwik-city/src/routes/dashboard/profile/index.tsx +0 -15
- package/starters/apps/qwik-city/src/routes/dashboard/settings/index.tsx +0 -15
- package/starters/apps/qwik-city/src/routes/docs/[category]/[id]/index.tsx +0 -23
- package/starters/apps/qwik-city/src/routes/docs/docs.css +0 -10
- package/starters/apps/qwik-city/src/routes/docs/getting-started/index.md +0 -44
- package/starters/apps/qwik-city/src/routes/docs/index.tsx +0 -14
- package/starters/apps/qwik-city/src/routes/docs/layout!.tsx +0 -31
- package/starters/apps/qwik-city/src/routes/docs/menu.md +0 -11
- package/starters/apps/qwik-city/src/routes/docs/overview/index.md +0 -7
- package/starters/apps/qwik-city/src/routes/index.tsx +0 -16
- package/starters/apps/qwik-city/src/routes/products/[id]/index.tsx +0 -123
- package/starters/apps/qwik-city/vite.config.ts +0 -17
- package/starters/features/prettier/.prettierignore +0 -23
- package/starters/features/prettier/package.json +0 -10
- package/starters/features/react/package.json +0 -26
- package/starters/features/react/src/entry.ssr.tsx +0 -11
- package/starters/features/react/src/react/app.tsx +0 -14
- package/starters/features/tailwindcss/package.json +0 -8
- package/starters/features/tailwindcss/postcss.config.cjs +0 -6
- package/starters/features/tailwindcss/src/global.css +0 -3
- package/starters/features/tailwindcss/tailwind.config.cjs +0 -7
- package/starters/servers/cloudflare-pages/.node-version +0 -1
- package/starters/servers/cloudflare-pages/README.md +0 -17
- package/starters/servers/cloudflare-pages/functions/[[path]].ts +0 -5
- package/starters/servers/cloudflare-pages/package.json +0 -18
- package/starters/servers/cloudflare-pages/public/_headers +0 -2
- package/starters/servers/cloudflare-pages/src/entry.cloudflare.tsx +0 -4
- package/starters/servers/express/README.md +0 -9
- package/starters/servers/express/package.json +0 -11
- package/starters/servers/express/src/entry.express.tsx +0 -31
- package/starters/servers/netlify-edge/.node-version +0 -1
- package/starters/servers/netlify-edge/README.md +0 -39
- package/starters/servers/netlify-edge/netlify.toml +0 -10
- package/starters/servers/netlify-edge/package.json +0 -19
- package/starters/servers/netlify-edge/public/_headers +0 -2
- package/starters/servers/netlify-edge/src/entry.netlify.ts +0 -6
- package/starters/servers/netlify-edge/tsconfig.json +0 -17
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { component$, Slot, useStyles$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
import styles from './api.css?inline';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Named layout `foo`
|
|
7
|
-
* Any index files named `index@foo.tsx` will use this layout
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export default component$(() => {
|
|
11
|
-
useStyles$(styles);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div class="api">
|
|
15
|
-
<aside class="api-menu">
|
|
16
|
-
<h2>API</h2>
|
|
17
|
-
<ul>
|
|
18
|
-
<li>
|
|
19
|
-
<a href="/api/builder.io/oss.json">Org/User</a>
|
|
20
|
-
</li>
|
|
21
|
-
<li>
|
|
22
|
-
<a href="/api/data.json">Data</a>
|
|
23
|
-
</li>
|
|
24
|
-
</ul>
|
|
25
|
-
</aside>
|
|
26
|
-
<section class="api-content">
|
|
27
|
-
<Slot />
|
|
28
|
-
</section>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export const head: DocumentHead = ({ pathname }) => {
|
|
34
|
-
return {
|
|
35
|
-
title: `API: ${pathname}`,
|
|
36
|
-
};
|
|
37
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { component$, Resource } from '@builder.io/qwik';
|
|
2
|
-
import { useEndpoint, DocumentHead, RequestHandler } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
const resource = useEndpoint<typeof onGet>();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<div>
|
|
9
|
-
<Resource
|
|
10
|
-
value={resource}
|
|
11
|
-
onResolved={(blog) => (
|
|
12
|
-
<>
|
|
13
|
-
<h1>{blog.blogTitle}</h1>
|
|
14
|
-
<p>{blog.blogContent}</p>
|
|
15
|
-
</>
|
|
16
|
-
)}
|
|
17
|
-
/>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const onGet: RequestHandler<EndpointData> = async ({ params, url }) => {
|
|
23
|
-
return {
|
|
24
|
-
blogTitle: `Blog: ${params.slug}`,
|
|
25
|
-
blogContent: `${params.slug}, ${url.pathname}`,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const head: DocumentHead<EndpointData> = ({ data }) => {
|
|
30
|
-
return { title: data?.blogTitle };
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export interface EndpointData {
|
|
34
|
-
blogTitle: string;
|
|
35
|
-
blogContent: string;
|
|
36
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { component$, Slot } from '@builder.io/qwik';
|
|
2
|
-
|
|
3
|
-
export default component$(() => {
|
|
4
|
-
return (
|
|
5
|
-
<div>
|
|
6
|
-
<section class="blog-content">
|
|
7
|
-
<Slot />
|
|
8
|
-
</section>
|
|
9
|
-
<aside class="blog-menu">
|
|
10
|
-
<ul>
|
|
11
|
-
<li>
|
|
12
|
-
<a href="/blog/what-is-resumability">What Is Resumability?</a>
|
|
13
|
-
</li>
|
|
14
|
-
<li>
|
|
15
|
-
<a href="/blog/serializing-props">Serializing Props</a>
|
|
16
|
-
</li>
|
|
17
|
-
</ul>
|
|
18
|
-
</aside>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
return (
|
|
6
|
-
<div>
|
|
7
|
-
<h1>Dashboard</h1>
|
|
8
|
-
<p>Welcome to the dashboard.</p>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const head: DocumentHead = {
|
|
14
|
-
title: 'Home',
|
|
15
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { component$, Slot, useStyles$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
import Footer from '../../components/footer/footer';
|
|
4
|
-
import Header from '../../components/header/header';
|
|
5
|
-
import styles from './dashboard.css?inline';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `layout!` means this is the top level layout. Because of the
|
|
9
|
-
* `!` at the end of the filename, it stops at this layout and does
|
|
10
|
-
* not keep crawling up the directories making more nested layouts.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export default component$(() => {
|
|
14
|
-
useStyles$(styles);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div>
|
|
18
|
-
<Header />
|
|
19
|
-
<main class="dashboard">
|
|
20
|
-
<aside class="dashboard-menu">
|
|
21
|
-
<h5>Dashboard Menu</h5>
|
|
22
|
-
<ul>
|
|
23
|
-
<li>
|
|
24
|
-
<a href="/dashboard/profile">Profile</a>
|
|
25
|
-
</li>
|
|
26
|
-
<li>
|
|
27
|
-
<a href="/dashboard/settings">Settings</a>
|
|
28
|
-
</li>
|
|
29
|
-
</ul>
|
|
30
|
-
</aside>
|
|
31
|
-
<section class="dashboard-content">
|
|
32
|
-
<Slot />
|
|
33
|
-
</section>
|
|
34
|
-
</main>
|
|
35
|
-
<Footer />
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const head: DocumentHead = ({ head }) => {
|
|
41
|
-
return {
|
|
42
|
-
title: `Dashboard ${head.title}`,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
return (
|
|
6
|
-
<div>
|
|
7
|
-
<h1>Profile</h1>
|
|
8
|
-
<p>My Profile</p>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const head: DocumentHead = {
|
|
14
|
-
title: 'Profile',
|
|
15
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
return (
|
|
6
|
-
<div>
|
|
7
|
-
<h1>Settings</h1>
|
|
8
|
-
<p>My Settings</p>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const head: DocumentHead = {
|
|
14
|
-
title: 'Settings',
|
|
15
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import { useLocation, DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
const { pathname, params } = useLocation();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<div>
|
|
9
|
-
<h1>
|
|
10
|
-
Docs: {params.category} {params.id}
|
|
11
|
-
</h1>
|
|
12
|
-
<p>pathname: {pathname}</p>
|
|
13
|
-
<p>category: {params.category}</p>
|
|
14
|
-
<p>id: {params.id}</p>
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const head: DocumentHead = ({ params }) => {
|
|
20
|
-
return {
|
|
21
|
-
title: `${params.category} ${params.id}`,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Getting Started
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Getting Started
|
|
6
|
-
|
|
7
|
-
## Creating an app using the CLI
|
|
8
|
-
|
|
9
|
-
The first step is to create an application. Qwik comes with a CLI that allows you to create a basic working skeleton of an application. We will use the CLI to create a Todo sample app, and we will use that application to do a walk-through of Qwik so that you can familiarize yourself with it.
|
|
10
|
-
|
|
11
|
-
## Running in development
|
|
12
|
-
|
|
13
|
-
Once the application is download.
|
|
14
|
-
|
|
15
|
-
1. Change into the directory created by the `npm create qwik@latest`.
|
|
16
|
-
|
|
17
|
-
```shell
|
|
18
|
-
cd qwik-todo
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
2. Install NPM modules:
|
|
22
|
-
|
|
23
|
-
```shell
|
|
24
|
-
npm install
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
3. Invoke the dev server
|
|
28
|
-
|
|
29
|
-
```shell
|
|
30
|
-
npm start
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
4. You should see a server running with your To-do application
|
|
34
|
-
|
|
35
|
-
```shell
|
|
36
|
-
vite v2.8.6 dev server running at:
|
|
37
|
-
|
|
38
|
-
> Local: http://localhost:3000/
|
|
39
|
-
> Network: use `--host` to expose
|
|
40
|
-
|
|
41
|
-
ready in 157ms.
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
5. Visit http://localhost:3000/ to explore the To-do app.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
return (
|
|
6
|
-
<div>
|
|
7
|
-
<h1>Welcome to the Docs!</h1>
|
|
8
|
-
</div>
|
|
9
|
-
);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const head: DocumentHead = {
|
|
13
|
-
title: 'Welcome!',
|
|
14
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { component$, Slot, useStyles$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
import { Breadcrumbs } from '../../components/breadcrumbs/breadcrumbs';
|
|
4
|
-
import Footer from '../../components/footer/footer';
|
|
5
|
-
import Header from '../../components/header/header';
|
|
6
|
-
import { Menu } from '../../components/menu/menu';
|
|
7
|
-
import styles from './docs.css?inline';
|
|
8
|
-
|
|
9
|
-
export default component$(() => {
|
|
10
|
-
useStyles$(styles);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div class="docs full-screen">
|
|
14
|
-
<Header />
|
|
15
|
-
<main>
|
|
16
|
-
<Menu />
|
|
17
|
-
<section class="docs-content">
|
|
18
|
-
<Breadcrumbs />
|
|
19
|
-
<Slot />
|
|
20
|
-
<Footer />
|
|
21
|
-
</section>
|
|
22
|
-
</main>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const head: DocumentHead = ({ head }) => {
|
|
28
|
-
return {
|
|
29
|
-
title: `Docs: ${head.title}`,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Overview
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Overview
|
|
6
|
-
|
|
7
|
-
Qwik is a new kind of web framework that can deliver instant loading web applications at any size or complexity. Your sites and apps can boot with less than 1kb of JS (_including_ your code, regardless of complexity), and achieve unheard of performance at scale.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { component$ } from '@builder.io/qwik';
|
|
2
|
-
import type { DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
return (
|
|
6
|
-
<div>
|
|
7
|
-
<h1>Welcome to Qwik City</h1>
|
|
8
|
-
|
|
9
|
-
<p>The meta-framework for Qwik.</p>
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export const head: DocumentHead = {
|
|
15
|
-
title: 'Welcome to Qwik City',
|
|
16
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Resource, component$ } from '@builder.io/qwik';
|
|
2
|
-
import { useEndpoint, useLocation, RequestHandler, DocumentHead } from '@builder.io/qwik-city';
|
|
3
|
-
|
|
4
|
-
export default component$(() => {
|
|
5
|
-
const { params } = useLocation();
|
|
6
|
-
|
|
7
|
-
const resource = useEndpoint<typeof onGet>();
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
<Resource
|
|
12
|
-
value={resource}
|
|
13
|
-
onPending={() => <p>Loading</p>}
|
|
14
|
-
onResolved={(product) => {
|
|
15
|
-
if (product == null) {
|
|
16
|
-
return <h1>Product "{params.id}" not found</h1>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<h1>Product: {product.productId}</h1>
|
|
22
|
-
<p>Price: {product.price}</p>
|
|
23
|
-
<p>{product.description}</p>
|
|
24
|
-
</>
|
|
25
|
-
);
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
|
-
<p>(Artificial response delay of 250ms)</p>
|
|
30
|
-
|
|
31
|
-
<hr />
|
|
32
|
-
|
|
33
|
-
<ul>
|
|
34
|
-
<li>
|
|
35
|
-
<a href="/products/jacket">Jacket</a>
|
|
36
|
-
</li>
|
|
37
|
-
<li>
|
|
38
|
-
<a href="/products/hat">Hat</a>
|
|
39
|
-
</li>
|
|
40
|
-
<li>
|
|
41
|
-
<a href="/products/shirt">T-Shirt (Redirect to /products/tshirt)</a>
|
|
42
|
-
</li>
|
|
43
|
-
<li>
|
|
44
|
-
<a href="/products/hoodie">Hoodie (404 Not Found)</a>
|
|
45
|
-
</li>
|
|
46
|
-
</ul>
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const head: DocumentHead<EndpointData> = ({ data }) => {
|
|
52
|
-
if (!data) {
|
|
53
|
-
return {
|
|
54
|
-
title: `Product not found`,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
title: `Product ${data.productId}, ${data.price}`,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const onGet: RequestHandler<EndpointData> = async ({ params, response }) => {
|
|
63
|
-
// Serverside Endpoint
|
|
64
|
-
// During SSR, this method is called directly on the server and returns the data object
|
|
65
|
-
// On the client, this same data can be requested with fetch() at the same URL, but also
|
|
66
|
-
// requires the "accept: application/json" request header.
|
|
67
|
-
|
|
68
|
-
if (params.id === 'shirt') {
|
|
69
|
-
// Redirect, which will skip any rendering and the server will immediately redirect
|
|
70
|
-
throw response.redirect('/products/tshirt');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// artificially slow database call
|
|
74
|
-
const productData = await loadProduct(params.id);
|
|
75
|
-
if (!productData) {
|
|
76
|
-
// Product data not found, but the data is still
|
|
77
|
-
// given to the renderer to decide how to render
|
|
78
|
-
response.status = 404;
|
|
79
|
-
return productData;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Found the product data
|
|
83
|
-
// This same data is passed to the head() function
|
|
84
|
-
// and in the component$() it can be access with useEndpoint()
|
|
85
|
-
response.headers.set('Cache-Control', 'no-cache, no-store, no-fun');
|
|
86
|
-
return productData;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// our pretty awesome function to load product data
|
|
90
|
-
const loadProduct = (productId: string) => {
|
|
91
|
-
return new Promise<ProductData | null>((resolve) =>
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
const productPrice = PRODUCT_DB[productId];
|
|
94
|
-
if (productPrice) {
|
|
95
|
-
// awesome product database found product data
|
|
96
|
-
const productData: ProductData = {
|
|
97
|
-
productId,
|
|
98
|
-
price: productPrice,
|
|
99
|
-
description: `Product description here.`,
|
|
100
|
-
};
|
|
101
|
-
resolve(productData);
|
|
102
|
-
} else {
|
|
103
|
-
// awesome product database did not find product data
|
|
104
|
-
resolve(null);
|
|
105
|
-
}
|
|
106
|
-
}, 250)
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// Our pretty awesome database of prices
|
|
111
|
-
const PRODUCT_DB: Record<string, string> = {
|
|
112
|
-
hat: '$21.96',
|
|
113
|
-
jacket: '$48.96',
|
|
114
|
-
tshirt: '$18.96',
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
type EndpointData = ProductData | null;
|
|
118
|
-
|
|
119
|
-
interface ProductData {
|
|
120
|
-
productId: string;
|
|
121
|
-
price: string;
|
|
122
|
-
description: string;
|
|
123
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { qwikVite } from '@builder.io/qwik/optimizer';
|
|
3
|
-
import { qwikCity } from '@builder.io/qwik-city/vite';
|
|
4
|
-
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
5
|
-
/* VITE_IMPORTS */
|
|
6
|
-
|
|
7
|
-
export default defineConfig(() => {
|
|
8
|
-
return {
|
|
9
|
-
/* VITE_CONFIG */
|
|
10
|
-
plugins: [
|
|
11
|
-
qwikCity(),
|
|
12
|
-
qwikVite(/* VITE_QWIK */),
|
|
13
|
-
tsconfigPaths(),
|
|
14
|
-
/* VITE_PLUGINS */
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
**/*.log
|
|
2
|
-
**/.DS_Store
|
|
3
|
-
*.
|
|
4
|
-
.vscode/settings.json
|
|
5
|
-
.history
|
|
6
|
-
.yarn
|
|
7
|
-
dist
|
|
8
|
-
dist-dev
|
|
9
|
-
etc
|
|
10
|
-
external
|
|
11
|
-
node_modules
|
|
12
|
-
temp
|
|
13
|
-
tsc-out
|
|
14
|
-
tsdoc-metadata.json
|
|
15
|
-
target
|
|
16
|
-
output
|
|
17
|
-
rollup.config.js
|
|
18
|
-
build
|
|
19
|
-
.cache
|
|
20
|
-
.vscode
|
|
21
|
-
.rollup.cache
|
|
22
|
-
dist
|
|
23
|
-
tsconfig.tsbuildinfo
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "Use React components into your Qwik app",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"fmt": "prettier --write .",
|
|
5
|
-
"fmt.check": "prettier --check ."
|
|
6
|
-
},
|
|
7
|
-
"devDependencies": {
|
|
8
|
-
"@builder.io/qwik-react": "0.0.100",
|
|
9
|
-
"@emotion/react": "11.9.3",
|
|
10
|
-
"@emotion/server": "11.4.0",
|
|
11
|
-
"@emotion/styled": "11.9.3",
|
|
12
|
-
"@mui/material": "5.8.6",
|
|
13
|
-
"@types/react": "18.0.14",
|
|
14
|
-
"@types/react-dom": "18.0.5",
|
|
15
|
-
"react": "18.2.0",
|
|
16
|
-
"react-dom": "18.2.0"
|
|
17
|
-
},
|
|
18
|
-
"__qwik__": {
|
|
19
|
-
"priority": -1,
|
|
20
|
-
"vite": {
|
|
21
|
-
"VITE_IMPORTS": "import { qwikReact } from '@builder.io/qwik-react';",
|
|
22
|
-
"VITE_CONFIG": "",
|
|
23
|
-
"VITE_PLUGINS": "qwikReact(),"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RenderOptions } from '@builder.io/qwik/server';
|
|
2
|
-
import { renderToString } from '@builder.io/qwik-react';
|
|
3
|
-
import { manifest } from '@qwik-client-manifest';
|
|
4
|
-
import Root from './root';
|
|
5
|
-
|
|
6
|
-
export default function (opts: RenderOptions) {
|
|
7
|
-
return renderToString(<Root />, {
|
|
8
|
-
manifest,
|
|
9
|
-
...opts,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource react */
|
|
2
|
-
|
|
3
|
-
import { qwikify$ } from '@builder.io/qwik-react';
|
|
4
|
-
import { Button } from '@mui/material';
|
|
5
|
-
|
|
6
|
-
export function ReactCmp() {
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
<Button>Button</Button>
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ReactRoot = /*#__PURE__*/ qwikify$(ReactCmp);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
16
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
## Cloudflare Pages
|
|
2
|
-
|
|
3
|
-
Cloudflare's [wrangler](https://github.com/cloudflare/wrangler) CLI can be used to preview a production build locally. To start a local server, run:
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
npm run serve
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Then visit [http://localhost:8787/](http://localhost:8787/)
|
|
10
|
-
|
|
11
|
-
### Deployments
|
|
12
|
-
|
|
13
|
-
[Cloudflare Pages](https://pages.cloudflare.com/) are deployable through their [Git provider integrations](https://developers.cloudflare.com/pages/platform/git-integration/).
|
|
14
|
-
|
|
15
|
-
If you don't already have an account, then [create a Cloudflare account here](https://dash.cloudflare.com/sign-up/pages). Next go to your dashboard and follow the [Cloudflare Pages deployment guide](https://developers.cloudflare.com/pages/framework-guides/deploy-anything/).
|
|
16
|
-
|
|
17
|
-
Within the projects "Settings" for "Build and deployments", the "Build command" should be `npm run build`, and the "Build output directory" should be set to `dist`.
|