Skip to content

Commit bae2b76

Browse files
committed
more fixes
1 parent d86cbbc commit bae2b76

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

apps/docs/src/routes/_docs/komponenter/$slug.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import { Alertbox, Content } from '@obosbbl/grunnmuren-react';
33
import { createFileRoute, notFound } from '@tanstack/react-router';
44
import type * as props from 'component-props';
55
import { defineQuery } from 'groq';
6+
import type { COMPONENT_QUERYResult } from 'sanity.types';
67
import { sanityFetch } from '@/lib/sanity';
78
import { AnchorHeading } from '@/ui/anchor-heading';
89
import { PropsTable } from '@/ui/props-table';
9-
import { ResourceLink, ResourceLinks } from '@/ui/resource-links';
10+
import {
11+
ResourceLink,
12+
type ResourceLinkProps,
13+
ResourceLinks,
14+
} from '@/ui/resource-links';
1015
import { SanityContent } from '@/ui/sanity-content';
1116
import { ScrollToTop } from '@/ui/scroll-to-top';
1217
import { TableOfContentsNav } from '@/ui/table-of-contents-nav';
@@ -29,22 +34,22 @@ const COMPONENT_QUERY = defineQuery(
2934

3035
export const Route = createFileRoute('/_docs/komponenter/$slug')({
3136
component: Page,
32-
loader: async ({ params }) => {
37+
loader: async ({ params }): Promise<{ data: COMPONENT_QUERYResult }> => {
3338
const res = await sanityFetch({
3439
query: COMPONENT_QUERY,
3540
params: { slug: params.slug },
3641
});
3742

38-
if (res.data == null) {
43+
if (res.data === null) {
3944
throw notFound();
4045
}
4146

42-
return { data: res.data };
47+
return res;
4348
},
4449
});
4550

4651
function Page() {
47-
const { data } = Route.useLoaderData();
52+
const { data } = Route.useLoaderData() || {};
4853

4954
const _ghLink = data.resourceLinks?.find(
5055
(link) => link.linkType === 'github',
@@ -61,7 +66,12 @@ function Page() {
6166
{data.resourceLinks?.map(
6267
({ url, linkType = 'other', text, _key }) =>
6368
url && (
64-
<ResourceLink key={_key} type={linkType} href={url} text={text} />
69+
<ResourceLink
70+
key={_key}
71+
type={linkType as ResourceLinkProps['type']}
72+
href={url}
73+
text={text}
74+
/>
6575
),
6676
)}
6777
</ResourceLinks>

apps/docs/src/routes/_docs/komponenter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Route = createFileRoute('/_docs/komponenter/')({
1717
{ name: 'description', content: 'Grunnmuren sine komponenter' },
1818
],
1919
}),
20-
loader: () => sanityFetch({ query: COMPONENTS_INDEX_QUERY }),
20+
loader: async () => await sanityFetch({ query: COMPONENTS_INDEX_QUERY }),
2121
});
2222

2323
function Page() {

0 commit comments

Comments
 (0)