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

v3 - multi-workspace config #596

Merged
merged 1 commit into from
Sep 11, 2024
Merged
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
Binary file added public/sharedStudioIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/studioIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions sanity.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This configuration is used to for the Sanity Studio that’s mounted on the routes:
* - `/app/studio/[[...index]]/page.tsx`
* - `/app/studioShared/[[...index]]/page.tsx`
*/

import { defineConfig } from "sanity";
import sharedStudioConfig from "./studioShared/studioConfig";
import studioConfig from "./studio/studioConfig";

export default defineConfig([studioConfig, sharedStudioConfig]);
2 changes: 1 addition & 1 deletion src/app/shared/[[...index]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { NextStudio } from "next-sanity/studio";

import config from "../../../../studioShared/sanity.config";
import config from "sanity.config";

export default function StudioPage() {
return <NextStudio config={config} />;
Expand Down
2 changes: 1 addition & 1 deletion src/app/studio/[[...index]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { NextStudio } from "next-sanity/studio";

import config from "../../../../studio/sanity.config";
import config from "sanity.config";

export default function StudioPage() {
return <NextStudio config={config} />;
Expand Down
17 changes: 0 additions & 17 deletions studio/components/CustomToolMenu.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions studio/components/studioIcon/StudioIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styles from "./studioIcon.module.css";
import Image from "next/image";

const StudioIcon = ({ variant }: { variant: "studio" | "shared" }) => {
return (
<Image
alt={"Studio Icon"}
width={540}
height={540}
className={styles.icon}
src={variant === "studio" ? "/studioIcon.png" : "/sharedStudioIcon.png"}
/>
);
};

export default StudioIcon;
5 changes: 5 additions & 0 deletions studio/components/studioIcon/studioIcon.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.icon {
width: 100%;
height: 100%;
object-fit: contain;
}
23 changes: 10 additions & 13 deletions studio/sanity.config.ts → studio/studioConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
/**
* This configuration is used to for the Sanity Studio that’s mounted on the `/app/studio/[[...index]]/page.tsx` route
*/

import { visionTool } from "@sanity/vision";
import { defineConfig, StudioToolMenu } from "sanity";
import { presentationTool } from "sanity/presentation";
import { structureTool } from "sanity/structure";

// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import { apiVersion, dataset, projectId } from "./env";
import { schema } from "./schema";
import deskStructure from "./schemas/deskStructure";
import CustomToolMenu from "./components/CustomToolMenu";
import { WorkspaceOptions } from "sanity";
import StudioIcon from "./components/studioIcon/StudioIcon";

export default defineConfig({
const config: WorkspaceOptions = {
name: "studio",
title: "Studio",
subtitle: "Our Own Space",
icon: () => <StudioIcon variant={"studio"} />,
basePath: "/studio",
projectId,
dataset,
// Add and edit the content schema in the './studio/schema' folder
schema,
studio: {
components: {
toolMenu: CustomToolMenu,
},
},
plugins: [
structureTool({
structure: deskStructure,
Expand All @@ -39,4 +34,6 @@ export default defineConfig({
},
}),
],
});
};

export default config;
16 changes: 0 additions & 16 deletions studioShared/sanity.config.ts

This file was deleted.

19 changes: 19 additions & 0 deletions studioShared/studioConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { dataset, projectId } from "./env";
import { schema } from "./schema";
import { structureTool } from "sanity/structure";
import { WorkspaceOptions } from "sanity";
import StudioIcon from "../studio/components/studioIcon/StudioIcon";

const config: WorkspaceOptions = {
name: "sharedStudio",
title: "Shared Studio",
subtitle: "Sharing is Caring!",
icon: () => <StudioIcon variant={"shared"} />,
basePath: "/shared",
projectId,
dataset,
schema,
plugins: [structureTool()],
};

export default config;