Skip to content

Commit

Permalink
use notes for posts
Browse files Browse the repository at this point in the history
  • Loading branch information
drewlyton committed Feb 8, 2024
1 parent 271695e commit 04abffb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/data/sanityClient.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export function getPostsByTag(tags: string[]) {
const tagsFilters = tags.map((t) => `"${t}" in tags[]->title`).join(" || ");
return `*[_type == "post" ${
tagsFilters.length ? `&& ${tagsFilters}` : ""
}]{_id, title, description, mainImage, tags[]->{title}, "slug": slug.current}`;
}]{_id, 'title': coalesce(note->title, title), description, mainImage, tags[]->{title}, "slug": slug.current}`;
}

export function getAllPosts() {
return `*[_type == "post"]{_id, title, description, mainImage, tags[]->{title}, "slug": slug.current, publishedAt}`;
return `*[_type == "post"]{_id, 'title': coalesce(note->title, title), description, mainImage, tags[]->{title}, "slug": slug.current, publishedAt}`;
}

export function getPostsFeed() {
return `*[_type == "post"]{_id, title, description, mainImage, tags[]->{title}, "slug": slug.current, linkedinPost, author->{...}, publishedAt}| order(publishedAt desc)`;
return `*[_type == "post"]{_id, 'title': coalesce(note->title, title), description, mainImage, tags[]->{title}, "slug": slug.current, linkedinPost, author->{...}, publishedAt}| order(publishedAt desc)`;
}

export function getPostBySlug(slug: string) {
return `*[_type == "post" && slug.current match "${slug}" ][0]{_id, title, description, mainImage, tags[]->{title}, "slug": slug.current, body, author->{...}, publishedAt}`;
return `*[_type == "post" && slug.current match "${slug}" ][0]{_id, 'title': coalesce(note->title, title), description, mainImage, tags[]->{title}, "slug": slug.current, 'body': coalesce(note->body, body), author->{...}, publishedAt}`;
}

0 comments on commit 04abffb

Please sign in to comment.