From 985b7359bbb5d604ffb112459c85069a0dd3136a Mon Sep 17 00:00:00 2001
From: Grace <145345672+microbit-grace@users.noreply.github.com>
Date: Tue, 26 Mar 2024 14:27:45 +0000
Subject: [PATCH] Parameterise Sanity config (#1158)
Retain the current default. The intent is to allow folks to provide alternative content.
See https://github.com/microbit-foundation/python-editor-v3/issues/1148
---
.env | 3 +++
src/common/sanity.ts | 6 ++++--
src/documentation/common/DocumentationContent.test.tsx | 2 +-
src/documentation/ideas/content.ts | 9 +--------
src/setupTests.ts | 3 +++
src/vite.d.ts | 3 +++
6 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/.env b/.env
index e10a70f1c..f60921e48 100644
--- a/.env
+++ b/.env
@@ -1,3 +1,6 @@
VITE_VERSION=$npm_package_version
VITE_NAME=$npm_package_name
VITE_FULL_URL=/
+VITE_SANITY_PROJECT=ajwvhvgo
+VITE_SANITY_DATASET=apps
+VITE_SANITY_PREVIEW_DATASET=apps-preview
\ No newline at end of file
diff --git a/src/common/sanity.ts b/src/common/sanity.ts
index 99f7b3330..c8edad7eb 100644
--- a/src/common/sanity.ts
+++ b/src/common/sanity.ts
@@ -87,8 +87,10 @@ export const sanityLanguageId = (locale: string): string => {
return `${parts[0]}-${parts[1].toUpperCase()}`;
};
-export const project = "ajwvhvgo";
-export const dataset = flags.cmsPreview ? "apps-preview" : "apps";
+export const project = import.meta.env.VITE_SANITY_PROJECT;
+export const dataset = flags.cmsPreview
+ ? import.meta.env.VITE_SANITY_PREVIEW_DATASET
+ : import.meta.env.VITE_SANITY_DATASET;
const queryUrl = (query: string): string => {
return `https://${project}.apicdn.sanity.io/v1/data/query/${dataset}?query=${encodeURIComponent(
diff --git a/src/documentation/common/DocumentationContent.test.tsx b/src/documentation/common/DocumentationContent.test.tsx
index cbacaf281..9bbf2c87e 100644
--- a/src/documentation/common/DocumentationContent.test.tsx
+++ b/src/documentation/common/DocumentationContent.test.tsx
@@ -67,7 +67,7 @@ describe("DocumentationContent", () => {
const view = render(