@builder.io/sdk-qwik 0.0.33 → 0.0.35
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 +35 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Add Qwik SDK code to a particular route (such as `src/routes/index.tsx`)
|
|
|
32
32
|
```typscript
|
|
33
33
|
import { component$, Resource, useResource$ } from "@builder.io/qwik";
|
|
34
34
|
import { useLocation } from "@builder.io/qwik-city";
|
|
35
|
-
import { getContent, RenderContent, getBuilderSearchParams } from "@builder.io/sdk-qwik";
|
|
35
|
+
import { getContent, RenderContent, RegisteredComponent, getBuilderSearchParams } from "@builder.io/sdk-qwik";
|
|
36
36
|
|
|
37
37
|
export const BUILDER_PUBLIC_API_KEY = "YOUR_API_KEY_GOES_HERE"; // ggignore
|
|
38
38
|
export default component$(() => {
|
|
@@ -57,11 +57,45 @@ export default component$(() => {
|
|
|
57
57
|
model="page"
|
|
58
58
|
content={content}
|
|
59
59
|
apiKey={BUILDER_PUBLIC_API_KEY}
|
|
60
|
+
// Optional: pass in a custom component registry
|
|
61
|
+
// customComponents={CUSTOM_COMPONENTS}
|
|
60
62
|
/>
|
|
61
63
|
)}
|
|
62
64
|
/>
|
|
63
65
|
);
|
|
64
66
|
});
|
|
67
|
+
|
|
68
|
+
// OPTIONAL: need to add custom components to your Qwik app
|
|
69
|
+
|
|
70
|
+
export const MyFunComponent = component$((props: { text: string }) => {
|
|
71
|
+
const state = useStore({
|
|
72
|
+
count: 0,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
<h3>{props.text.toUpperCase()}</h3>
|
|
78
|
+
<p>{state.count}</p>
|
|
79
|
+
<button onClick$={() => state.count++}>Click me</button>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
85
|
+
{
|
|
86
|
+
component: MyFunComponent,
|
|
87
|
+
name: 'MyFunComponent',
|
|
88
|
+
builtIn: true,
|
|
89
|
+
inputs: [
|
|
90
|
+
{
|
|
91
|
+
name: 'text',
|
|
92
|
+
type: 'string',
|
|
93
|
+
defaultValue: 'Hello world',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
65
99
|
```
|
|
66
100
|
|
|
67
101
|
## Mitosis
|