-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsanity.query.ts
136 lines (127 loc) · 2.44 KB
/
sanity.query.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { groq } from "next-sanity";
import client from "./sanity.client";
export async function getProfile() {
return client.fetch(
groq`*[_type == "profile"]{
_id,
fullName,
headline,
profileImage {
"image": asset->url,
"lqip": asset->metadata.lqip,
alt,
},
shortBio,
location,
fullBio,
email,
"resumeURL": resumeURL.asset->url,
socialLinks,
usage
}`
);
}
export async function getJob() {
return client.fetch(
groq`*[_type == "job"] | order(_createdAt desc){
_id,
name,
jobTitle,
"logo": logo.asset->url,
url,
description,
startDate,
endDate,
}`
);
}
export async function getProjects() {
return client.fetch(
groq`*[_type == "project"] | order(_createdAt desc){
_id,
name,
"slug": slug.current,
tagline,
"logo": logo.asset->url,
}`
);
}
export async function getSingleProject(slug: string) {
return client.fetch(
groq`*[_type == "project" && slug.current == $slug][0]{
_id,
name,
projectUrl,
coverImage {
"image": asset->url,
"lqip": asset->metadata.lqip,
alt,
},
tagline,
description
}`,
{ slug }
);
}
// Reusable post fields
const postField = groq`
_id,
_createdAt,
title,
"slug": slug.current,
description,
coverImage {
"image": asset->url,
"lqip": asset->metadata.lqip,
alt,
},
featured,
isPublished
`;
export async function getPosts() {
return client.fetch(
groq`*[_type == "Post"] | order(_createdAt desc){
${postField},
date,
"author": author-> {
name,
photo,
twitterUrl
},
body,
}`
);
}
export async function getFeaturedPosts() {
return client.fetch(
groq`*[_type == "Post" && featured == true] {
${postField}
}`
);
}
export async function getSinglePost(slug: string) {
return client.fetch(
groq`*[_type == "Post" && slug.current == $slug][0]{
${postField},
_updatedAt,
canonicalLink,
date,
tags,
"author": author-> {
name,
photo {
"image": asset->url,
alt
},
twitterUrl
},
body,
}`,
{ slug }
);
}
export async function getHeroes() {
return client.fetch(
groq`*[_type == "heroe"] | order(_createdAt asc) { _id, _createdAt, name, url, met }`
);
}