Skip to content

Commit eab53c8

Browse files
committed
Addition to initial fix - fix links in the page-builders Info section
1 parent ad411b4 commit eab53c8

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

nextjs-app/sanity.types.ts

+9-20
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export type SettingsQueryResult = {
505505
};
506506
} | null;
507507
// Variable: getPageQuery
508-
// Query: *[_type == 'page' && slug.current == $slug][0]{ _id, _type, name, slug, heading, subheading, "pageBuilder": pageBuilder[]{ ..., _type == "callToAction" => { ..., link { ..., _type == "link" => { "page": page->slug.current, "post": post->slug.current } }, } }, }
508+
// Query: *[_type == 'page' && slug.current == $slug][0]{ _id, _type, name, slug, heading, subheading, "pageBuilder": pageBuilder[]{ ..., _type == "callToAction" => { ..., link { ..., _type == "link" => { "page": page->slug.current, "post": post->slug.current } }, } }, }
509509
export type GetPageQueryResult = {
510510
_id: string;
511511
_type: "page";
@@ -571,7 +571,7 @@ export type GetPageQueryResult = {
571571
export type AllPostsQueryResult = Array<{
572572
_id: string;
573573
status: "draft" | "published";
574-
title: string | "Untitled";
574+
title: string;
575575
slug: string;
576576
excerpt: string | null;
577577
coverImage: {
@@ -609,7 +609,7 @@ export type AllPostsQueryResult = Array<{
609609
export type MorePostsQueryResult = Array<{
610610
_id: string;
611611
status: "draft" | "published";
612-
title: string | "Untitled";
612+
title: string;
613613
slug: string;
614614
excerpt: string | null;
615615
coverImage: {
@@ -643,7 +643,7 @@ export type MorePostsQueryResult = Array<{
643643
} | null;
644644
}>;
645645
// Variable: postQuery
646-
// Query: *[_type == "post" && slug.current == $slug] [0] { content[]{ ..., markDefs[]{ ..., link { ..., _type == "link" => { "page": page->slug.current, "post": post->slug.current } } } }, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{firstName, lastName, picture}, }
646+
// Query: *[_type == "post" && slug.current == $slug] [0] { content[]{ ..., markDefs[]{ ..., _type == "link" => { "page": page->slug.current, "post": post->slug.current } } }, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{firstName, lastName, picture}, }
647647
export type PostQueryResult = {
648648
content: Array<{
649649
children?: Array<{
@@ -657,30 +657,19 @@ export type PostQueryResult = {
657657
markDefs: Array<{
658658
linkType?: "href" | "page" | "post";
659659
href?: string;
660-
page?: {
661-
_ref: string;
662-
_type: "reference";
663-
_weak?: boolean;
664-
[internalGroqTypeReferenceTo]?: "page";
665-
};
666-
post?: {
667-
_ref: string;
668-
_type: "reference";
669-
_weak?: boolean;
670-
[internalGroqTypeReferenceTo]?: "post";
671-
};
660+
page: string | null;
661+
post: string | null;
672662
openInNewTab?: boolean;
673663
_type: "link";
674664
_key: string;
675-
link: null;
676665
}> | null;
677666
level?: number;
678667
_type: "block";
679668
_key: string;
680669
}> | null;
681670
_id: string;
682671
status: "draft" | "published";
683-
title: string | "Untitled";
672+
title: string;
684673
slug: string;
685674
excerpt: string | null;
686675
coverImage: {
@@ -729,10 +718,10 @@ import "@sanity/client";
729718
declare module "@sanity/client" {
730719
interface SanityQueries {
731720
"*[_type == \"settings\"][0]": SettingsQueryResult;
732-
"\n *[_type == 'page' && slug.current == $slug][0]{\n _id,\n _type,\n name,\n slug,\n heading,\n subheading,\n \"pageBuilder\": pageBuilder[]{\n ...,\n _type == \"callToAction\" => {\n ...,\n \n link {\n ...,\n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n }\n,\n }\n },\n }\n": GetPageQueryResult;
721+
"\n *[_type == 'page' && slug.current == $slug][0]{\n _id,\n _type,\n name,\n slug,\n heading,\n subheading,\n \"pageBuilder\": pageBuilder[]{\n ...,\n _type == \"callToAction\" => {\n ...,\n \n link {\n ...,\n \n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n\n }\n,\n }\n },\n }\n": GetPageQueryResult;
733722
"\n *[_type == \"post\" && defined(slug.current)] | order(date desc, _updatedAt desc) {\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": AllPostsQueryResult;
734723
"\n *[_type == \"post\" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": MorePostsQueryResult;
735-
"\n *[_type == \"post\" && slug.current == $slug] [0] {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n link {\n ...,\n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n }\n\n }\n },\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": PostQueryResult;
724+
"\n *[_type == \"post\" && slug.current == $slug] [0] {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n\n }\n },\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": PostQueryResult;
736725
"\n *[_type == \"post\" && defined(slug.current)]\n {\"slug\": slug.current}\n": PostPagesSlugsResult;
737726
"\n *[_type == \"page\" && defined(slug.current)]\n {\"slug\": slug.current}\n": PagesSlugsResult;
738727
}

nextjs-app/sanity/lib/queries.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ export const getPageQuery = defineQuery(`
3838
"pageBuilder": pageBuilder[]{
3939
...,
4040
_type == "callToAction" => {
41-
...,
4241
${linkFields},
43-
}
42+
},
43+
_type == "infoSection" => {
44+
content[]{
45+
...,
46+
markDefs[]{
47+
...,
48+
${linkReference}
49+
}
50+
}
51+
},
4452
},
4553
}
4654
`);

0 commit comments

Comments
 (0)