-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from drewlyton/sanity-upgrade
Sanity upgrade
- Loading branch information
Showing
26 changed files
with
15,569 additions
and
8,897 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
legacy-peer-deps=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.17.0 | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createClient } from "@sanity/client"; | ||
|
||
export const sanity = createClient({ | ||
projectId: "xpnntlnd", | ||
dataset: "production", | ||
useCdn: process.env.NODE_ENV === "production", // set to `false` to bypass the edge cache | ||
apiVersion: "2023-05-03", // use current date (YYYY-MM-DD) to target the latest API version | ||
token: process.env.SANITY_TOKEN // Only if you want to update content with the client | ||
}); | ||
|
||
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}`; | ||
} | ||
|
||
export function getAllPosts() { | ||
return `*[_type == "post"]{_id, title, description, mainImage, tags[]->{title}, "slug": slug.current}`; | ||
} | ||
|
||
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}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type Author = { | ||
name: string; | ||
bio: string; | ||
image: { | ||
asset: { | ||
_ref: string; | ||
}; | ||
}; | ||
}; | ||
|
||
export type Image = { | ||
asset: { | ||
_ref: string; | ||
}; | ||
}; | ||
|
||
export type Tag = { title: string; description: string }; | ||
|
||
export type Post = { | ||
_id: string; | ||
title: string; | ||
description: string; | ||
body: string; | ||
slug: string; | ||
mainImage: Image; | ||
author: Author; | ||
publishedAt: string; | ||
tags: Tag[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import imageUrlBuilder from "@sanity/image-url"; | ||
import { createClient } from "@sanity/client"; | ||
|
||
const sanity = createClient({ | ||
projectId: "xpnntlnd", | ||
dataset: "production", | ||
useCdn: process.env.NODE_ENV === "production", // set to `false` to bypass the edge cache | ||
apiVersion: "2023-05-03" // use current date (YYYY-MM-DD) to target the latest API version | ||
}); | ||
|
||
export const imageBuilder = imageUrlBuilder(sanity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.