Skip to content

Commit 766e7b9

Browse files
committed
Update typedocs
1 parent 55e7f08 commit 766e7b9

13 files changed

Lines changed: 3507 additions & 2517 deletions

docs/reference/README.md

Lines changed: 13 additions & 2508 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Variables
2+
3+
<a id="navigationcontext"></a>
4+
5+
### NavigationContext
6+
7+
> `const` **NavigationContext**: `Context`\<[`NavigationContextProps`](types.md#navigationcontextprops)\>
8+
9+
Defined in: [components/Navigation.tsx:29](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/components/Navigation.tsx#L29)
10+
11+
***
12+
13+
<a id="navigationprovider"></a>
14+
15+
### NavigationProvider
16+
17+
> `const` **NavigationProvider**: `ForwardRefExoticComponent`\<[`NavigationProviderProps`](types.md#navigationproviderprops) & `RefAttributes`\<\{ `navigateTo`: `null` \| [`NavigateTo`](types.md#navigateto); \}\>\>
18+
19+
Defined in: [components/Navigation.tsx:53](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/components/Navigation.tsx#L53)
20+
21+
## Functions
22+
23+
<a id="navigationoutlet"></a>
24+
25+
### NavigationOutlet()
26+
27+
> **NavigationOutlet**(`__namedParameters`: [`NavigationOutletProps`](types.md#navigationoutletprops)): `Element`
28+
29+
Defined in: [components/Navigation.tsx:263](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/components/Navigation.tsx#L263)
30+
31+
#### Parameters
32+
33+
| Parameter | Type |
34+
| ------ | ------ |
35+
| `__namedParameters` | [`NavigationOutletProps`](types.md#navigationoutletprops) |
36+
37+
#### Returns
38+
39+
`Element`

docs/reference/hooks.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
## Functions
2+
3+
<a id="usesuperglue"></a>
4+
5+
### useSuperglue()
6+
7+
> **useSuperglue**(): [`SuperglueState`](types.md#supergluestate)
8+
9+
Defined in: [hooks/index.ts:17](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/index.ts#L17)
10+
11+
A lightweight hook that grabs the superglue state from the store.
12+
13+
#### Returns
14+
15+
[`SuperglueState`](types.md#supergluestate)
16+
17+
***
18+
19+
<a id="useflash"></a>
20+
21+
### useFlash()
22+
23+
> **useFlash**\<`T`\>(): `T`
24+
25+
Defined in: [hooks/index.ts:31](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/index.ts#L31)
26+
27+
A hook that returns the current flash state from the store.
28+
Flash is cleared automatically on every visit.
29+
30+
Pass a type parameter to narrow the flash shape:
31+
32+
```ts
33+
const flash = useFlash<{ notice?: string; alert?: string }>()
34+
```
35+
36+
#### Type Parameters
37+
38+
| Type Parameter | Default type |
39+
| ------ | ------ |
40+
| `T` | [`FlashState`](types.md#flashstate) |
41+
42+
#### Returns
43+
44+
`T`
45+
46+
***
47+
48+
<a id="usesetflash"></a>
49+
50+
### useSetFlash()
51+
52+
> **useSetFlash**(): \{ `setFlash`: (`flash`: [`FlashState`](types.md#flashstate)) => `void`; `clearFlash`: (`key?`: `string`) => `void`; \}
53+
54+
Defined in: [hooks/index.ts:47](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/index.ts#L47)
55+
56+
A hook that returns functions to set and clear flash messages
57+
on the client side.
58+
59+
```ts
60+
const { setFlash, clearFlash } = useSetFlash()
61+
62+
setFlash({ notice: 'Saved!' })
63+
clearFlash('notice')
64+
clearFlash() // clears all
65+
```
66+
67+
#### Returns
68+
69+
\{ `setFlash`: (`flash`: [`FlashState`](types.md#flashstate)) => `void`; `clearFlash`: (`key?`: `string`) => `void`; \}
70+
71+
| Name | Type | Defined in |
72+
| ------ | ------ | ------ |
73+
| `setFlash()` | (`flash`: [`FlashState`](types.md#flashstate)) => `void` | [hooks/index.ts:64](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/index.ts#L64) |
74+
| `clearFlash()` | (`key?`: `string`) => `void` | [hooks/index.ts:64](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/index.ts#L64) |
75+
76+
## References
77+
78+
<a id="usecontent"></a>
79+
80+
### useContent
81+
82+
Re-exports [useContent](hooks.useContent.md#usecontent)
83+
84+
***
85+
86+
<a id="unproxy"></a>
87+
88+
### unproxy
89+
90+
Re-exports [unproxy](hooks.useContent.md#unproxy)
91+
92+
***
93+
94+
<a id="usefragment"></a>
95+
96+
### useFragment
97+
98+
Re-exports [useFragment](index.md#usefragment)
99+
100+
***
101+
102+
<a id="tofragmentref"></a>
103+
104+
### toFragmentRef
105+
106+
Re-exports [toFragmentRef](index.md#tofragmentref)
107+
108+
***
109+
110+
<a id="useupdatefragment"></a>
111+
112+
### useUpdateFragment
113+
114+
Re-exports [useUpdateFragment](hooks.useUpdateFragment.md#useupdatefragment)
115+
116+
***
117+
118+
<a id="useupdatecontent"></a>
119+
120+
### useUpdateContent
121+
122+
Re-exports [useUpdateContent](index.md#useupdatecontent)
123+
124+
***
125+
126+
<a id="usestreamsource"></a>
127+
128+
### useStreamSource
129+
130+
Re-exports [useStreamSource](hooks.useStreamSource.md#usestreamsource)

docs/reference/hooks.useContent.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
## Functions
2+
3+
<a id="usecontent"></a>
4+
5+
### useContent()
6+
7+
#### Call Signature
8+
9+
> **useContent**\<`T`\>(): `T`
10+
11+
Defined in: [hooks/useContent.tsx:52](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/useContent.tsx#L52)
12+
13+
Returns a proxy for accessing your page's content e.g, `index.json.props`,
14+
`show.json.props`, etc.
15+
16+
```js
17+
{
18+
data: {
19+
body: {
20+
cart: {__id: 'user_cart'}
21+
},
22+
footer: {title: "welcome"}},
23+
},
24+
fragments: {user_cart: {total: 100}}
25+
}
26+
```
27+
28+
The proxy will lazily and automatically resolve any `FragmentRef`s making it
29+
as easy as
30+
31+
```
32+
const data = useContent()
33+
const total = data.body.cart.total
34+
```
35+
36+
The hook will also automatically tracks fragment dependencies and triggers
37+
re-renders only when accessed fragments change.
38+
39+
##### Type Parameters
40+
41+
| Type Parameter | Default type | Description |
42+
| ------ | ------ | ------ |
43+
| `T` | [`JSONMappable`](types.md#jsonmappable) | The data type being accessed (defaults to JSONMappable) |
44+
45+
##### Returns
46+
47+
`T`
48+
49+
Reactive proxy to page data
50+
51+
##### Example
52+
53+
```tsx
54+
// Access current page data
55+
const page = useContent()
56+
57+
// Access a specific page's data by key
58+
const posts = useContent('/posts')
59+
```
60+
61+
#### Call Signature
62+
63+
> **useContent**\<`T`\>(`pageKey?`: `string`): `undefined` \| `T`
64+
65+
Defined in: [hooks/useContent.tsx:57](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/useContent.tsx#L57)
66+
67+
##### Type Parameters
68+
69+
| Type Parameter | Default type |
70+
| ------ | ------ |
71+
| `T` | [`JSONMappable`](types.md#jsonmappable) |
72+
73+
##### Parameters
74+
75+
| Parameter | Type | Description |
76+
| ------ | ------ | ------ |
77+
| `pageKey?` | `string` | Optional page key to access a specific page's data. When omitted, returns data for the current page. |
78+
79+
##### Returns
80+
81+
`undefined` \| `T`
82+
83+
***
84+
85+
<a id="unproxy"></a>
86+
87+
### unproxy()
88+
89+
> **unproxy**\<`T`\>(`proxy`: `T`): [`Unproxy`](types.md#unproxy)\<`T`\>
90+
91+
Defined in: [hooks/useContent.tsx:127](https://github.com/thoughtbot/superglue/blob/38ea0f22384ca668ffa28ead0054dc09a0f39366/superglue/lib/hooks/useContent.tsx#L127)
92+
93+
Extracts the underlying state from an [useContent](#usecontent) proxy
94+
95+
#### Type Parameters
96+
97+
| Type Parameter |
98+
| ------ |
99+
| `T` |
100+
101+
#### Parameters
102+
103+
| Parameter | Type |
104+
| ------ | ------ |
105+
| `proxy` | `T` |
106+
107+
#### Returns
108+
109+
[`Unproxy`](types.md#unproxy)\<`T`\>

0 commit comments

Comments
 (0)