Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try using Sanity perspectives for the cmsPreview flag #1140

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/common/sanity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ export const sanityLanguageId = (locale: string): string => {

export const project = "ajwvhvgo";
export const dataset = flags.cmsPreview ? "apps-preview" : "apps";
const perspective = flags.cmsPreview ? "previewDrafts" : "published";

const queryUrl = (query: string): string => {
return `https://${project}.apicdn.sanity.io/v1/data/query/${dataset}?query=${encodeURIComponent(
return `https://${project}.${
flags.cmsPreview ? "api" : "apicdn"
}.sanity.io/v2021-03-25/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent(
query
)}`;
};
2 changes: 1 addition & 1 deletion src/documentation/ideas/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const fetchIdeas = async (languageId: string): Promise<Idea[]> =>

const ideasQuery = (languageId: string): string => {
return `
*[_type == "pythonIdeasConfig" && language == "${languageId}" && !(_id in path("drafts.**"))][0]{
*[_type == "pythonIdeasConfig" && language == "${languageId}"][0]{
pythonIdeasOrder[]->{
_id, name, language, compatibility, image, slug,
content[] {
Expand Down
4 changes: 2 additions & 2 deletions src/documentation/mapping/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export const fetchMappingData = async (): Promise<ApiReferenceMap> =>

const mappingQuery = (): string => {
return `
*[_type == "pythonModule" && !(_id in path("drafts.**"))]{
*[_type == "pythonModule"]{
pythonModuleName,
pythonModuleItem[] {
pythonAlternativeContentLink,
pythonApiEntry,
referenceLink {
_type == "reference" =>^-> {
_type == "reference" =>@-> {
slug
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/documentation/reference/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getTopicAndEntry = (
// This is necessary for the client-side search index.
const toolkitQuery = (languageId: string): string => {
return `
*[_type == "toolkit" && language == "${languageId}" && (slug.current == "explore" || slug.current == "reference") && !(_id in path("drafts.**"))]{
*[_type == "toolkit" && language == "${languageId}" && (slug.current == "explore" || slug.current == "reference")]{
id, name, description, language,
contents[]->{
name, slug, compatibility, subtitle, image,
Expand Down
2 changes: 1 addition & 1 deletion src/workbench/WelcomeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const WelcomeDialog = ({ isOpen, onClose }: WelcomeDialogProps) => {
};
const query = (): string => {
return `
*[_id == "pythonEditorConfig" && !(_id in path("drafts.**"))]{
*[_id == "pythonEditorConfig"]{
welcomeVideo
}`;
};
Expand Down