Skip to content

Commit

Permalink
add new env keys to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
christinaroise committed Aug 26, 2024
1 parent 3898630 commit efed903
Showing 1 changed file with 44 additions and 34 deletions.
78 changes: 44 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ In addition to the primary Sanity Studio (accessible at http://localhost:3000/st

### Features of Shared Studio

Blog Posts: In the Shared Studio, you can create and manage Blog Posts. This content type allows for creating articles that can be displayed across different parts of the application.
Customer Cases: Customer Cases is another content type available in the Shared Studio, enabling you to showcase client stories or testimonials.
- Blog Posts: In the Shared Studio, you can create and manage Blog Posts. This content type allows for creating articles that can be displayed across different parts of the application.
- Customer Cases: Customer Cases is another content type available in the Shared Studio, enabling you to showcase client stories or testimonials.

Accessing Shared Studio

Studio URL: The Shared Studio is accessible at http://localhost:3000/shared.
Frontend Access: Content from the Shared Studio can be accessed on the frontend through API calls using sharedClient or loadSharedQuery.
- Studio URL: The Shared Studio is accessible at http://localhost:3000/shared.
- Frontend Access: Content from the Shared Studio can be accessed on the frontend through API calls using sharedClient or loadSharedQuery.

## Getting Started

Expand All @@ -46,12 +46,20 @@ To get started with Sankitty, follow these steps:
Ensure that the following environment variables are configured in your .env.local file:

```
# ENV KEYS FOR UNIQUE STUDIO
NEXT_PUBLIC_SANITY_PROJECT_ID=<Your Sanity Project ID>
NEXT_PUBLIC_SANITY_DATASET=<Your Sanity Dataset>
NEXT_PUBLIC_SANITY_API_VERSION=<Your Sanity API Version>
SANITY_API_TOKEN_DEV=<Your Sanity API Developer Token>
SANITY_API_TOKEN_PROD=<Your Sanity API Viewer Token>
# ENV KEYS FOR SHARED STUDIO
NEXT_PUBLIC_SANITY_SHARED_PROJECT_ID=<Your Sanity SHARED Project ID>
NEXT_PUBLIC_SANITY_SHARED_DATASET=<Your Sanity SHARED Dataset>
NEXT_PUBLIC_SANITY_SHARED_API_VERSION=<Your Sanity SHARED API Version>
SANITY_SHARED_API_TOKEN_DEV=<Your Sanity SHARED API Developer Token>
SANITY_SHARED_API_TOKEN_PROD=<Your Sanity SHARED API Viewer Token>
```

4. **Configure Sanity:**
Expand All @@ -61,6 +69,7 @@ To get started with Sankitty, follow these steps:

```
npm run dev
```

6. **View the Application**:
Expand Down Expand Up @@ -105,9 +114,9 @@ The `Site Settings` menu allows you to configure global settings for your site,

- **Setting the Landing Page**: The `Navigation Manager` allows editors to set the landing page for the site, which is crucial for determining the primary page visitors see upon arrival.
- **Adding Menu Items**: Within the `Navigation Manager`, editors can add items to various pre-defined menus:
- **Main Menu**: Add links and a single Call to Action (if needed) to the main menu, which appears at the top of the website. This helps visitors navigate to important sections.
- **Footer Menu**: Add items to the footer menu, which consists of different sections. Each section can contain either social media links, custom links, text, or images (e.g., logos).
- **Sidebar Menu**: Add links to the sidebar menu, which will appear on smaller screens to aid mobile navigation.
- **Main Menu**: Add links and a single Call to Action (if needed) to the main menu, which appears at the top of the website. This helps visitors navigate to important sections.
- **Footer Menu**: Add items to the footer menu, which consists of different sections. Each section can contain either social media links, custom links, text, or images (e.g., logos).
- **Sidebar Menu**: Add links to the sidebar menu, which will appear on smaller screens to aid mobile navigation.

#### Pages

Expand All @@ -121,10 +130,11 @@ To maintain consistency and efficiency, follow these steps when working on the p
1. Branching Strategy: Follow your team’s branching convention, such as feature/ or fix/ branches, to keep the git history clean and organized.

2. Adding New UI with Content:
- Define the Sanity schema for new content types.
- Implement the corresponding interface and payload structure in src/lib/payloads.
- Fetch the necessary data and create the UI component.
- Document and test the UI component in Storybook, using mock data for isolated development.

- Define the Sanity schema for new content types.
- Implement the corresponding interface and payload structure in src/lib/payloads.
- Fetch the necessary data and create the UI component.
- Document and test the UI component in Storybook, using mock data for isolated development.

### Using `fetchWithToken` for Custom Components in Sanity

Expand All @@ -141,29 +151,29 @@ import React, { useEffect, useState } from "react";
import { fetchWithToken } from "studio/lib/fetchWithToken";

const MyCustomComponent: React.FC = () => {
const [data, setData] = useState<any>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
const fetchData = async () => {
try {
const query = '*[_type == "myType"]'; // Replace with your GROQ query
const result = await fetchWithToken<any>(query);
setData(result);
} catch (err) {
console.error("Error fetching data:", err);
setError(err.message);
}
};

fetchData();
}, []);

if (error) {
return <div>Error: {error}</div>;
}

return <div>{JSON.stringify(data)}</div>; // Render your component's UI
const [data, setData] = useState<any>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
const fetchData = async () => {
try {
const query = '*[_type == "myType"]'; // Replace with your GROQ query
const result = await fetchWithToken<any>(query);
setData(result);
} catch (err) {
console.error("Error fetching data:", err);
setError(err.message);
}
};

fetchData();
}, []);

if (error) {
return <div>Error: {error}</div>;
}

return <div>{JSON.stringify(data)}</div>; // Render your component's UI
};

export default MyCustomComponent;
Expand Down

0 comments on commit efed903

Please sign in to comment.