Skip to content

Commit 7be9597

Browse files
authored
fix: fix links to reference docs (#40)
1 parent a196cd2 commit 7be9597

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

apps/sdk-explorer/src/components/ExampleAttributes.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import {LaunchIcon} from '@sanity/icons'
22
import {Badge, Box, Inline, Label, Stack} from '@sanity/ui'
33
import {type JSX} from 'react'
44

5-
import Hooks, {type HookReference} from './Hooks'
5+
import Hooks, {type HooksProps} from './Hooks'
66

77
const labelInset = '14ch'
88

9-
export interface ExampleAttributeProps {
10-
hooks: HookReference[]
9+
export type ExampleAttributeProps = HooksProps & {
1110
styling: 'Sanity UI' | 'Tailwind'
1211
}
1312

apps/sdk-explorer/src/components/ExampleCard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import styled from 'styled-components'
66

77
import ExampleAttributes, {type ExampleAttributeProps} from './ExampleAttributes'
88

9-
interface ExampleCardProps {
9+
type ExampleCardProps = ExampleAttributeProps & {
1010
description: string
11-
hooks: ExampleAttributeProps['hooks']
1211
img: string
13-
styling: ExampleAttributeProps['styling']
1412
title: string
1513
to: string
1614
}

apps/sdk-explorer/src/components/ExampleLayout.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import {type JSX} from 'react'
44
import ExampleAttributes, {type ExampleAttributeProps} from './ExampleAttributes'
55
import ViewCode from './ViewCode'
66

7-
interface ExampleLayoutProps {
7+
type ExampleLayoutProps = ExampleAttributeProps & {
88
children: React.ReactNode
99
title: string
1010
codeUrl: string
11-
hooks: ExampleAttributeProps['hooks']
12-
styling: ExampleAttributeProps['styling']
1311
summary: string
1412
}
1513

apps/sdk-explorer/src/components/Hooks.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
import {Badge, Box, Inline} from '@sanity/ui'
22
import {type JSX} from 'react'
33

4-
export interface HookReference {
4+
const baseUrl = 'https://sdk-docs.sanity.dev/functions/React_SDK.exports.'
5+
6+
const referenceLinks = {
7+
useDocuments: `${baseUrl}useDocuments.html`,
8+
usePaginatedDocuments: `${baseUrl}usePaginatedDocuments.html`,
9+
useProjection: `${baseUrl}useProjection.html`,
10+
useQuery: `${baseUrl}useQuery.html`,
11+
}
12+
13+
interface HookReference {
514
name: 'useDocuments' | 'usePaginatedDocuments' | 'useProjection' | 'useQuery'
6-
reference: `https://${string}`
15+
reference: (typeof referenceLinks)[keyof typeof referenceLinks]
716
}
817

918
// These consts can't begin with the word `use` or eslint yells at you for
1019
// passing around a 'hook' reference
1120

1221
const documents: HookReference = {
1322
name: 'useDocuments',
14-
reference: 'https://sdk-docs.sanity.dev/functions/sdk-react.index.useDocuments.html',
23+
reference: referenceLinks.useDocuments,
1524
}
1625

1726
const paginatedDocuments: HookReference = {
1827
name: 'usePaginatedDocuments',
19-
reference: 'https://sdk-docs.sanity.dev/functions/sdk-react.index.usePaginatedDocuments.html',
28+
reference: referenceLinks.usePaginatedDocuments,
2029
}
2130

2231
const projection: HookReference = {
2332
name: 'useProjection',
24-
reference: 'https://sdk-docs.sanity.dev/functions/sdk-react.index.useProjection.html',
33+
reference: referenceLinks.useProjection,
2534
}
2635

2736
const query: HookReference = {
2837
name: 'useQuery',
29-
reference: 'https://sdk-docs.sanity.dev/functions/sdk-react.index.useQuery.html',
38+
reference: referenceLinks.useQuery,
3039
}
3140

3241
export {documents, paginatedDocuments, projection, query}
3342

34-
interface HooksProps {
43+
export interface HooksProps {
3544
hooks: HookReference[]
3645
}
3746

0 commit comments

Comments
 (0)