Skip to content

Commit f76379a

Browse files
Update template to pass sanity's template validator (#46)
* Update template to pass sanity's template validator * bump packages. * Update 'app' to 'sveltekit-app' for consistency
1 parent ce8356b commit f76379a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+14480
-9095
lines changed

.github/workflows/validate.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Validate Template
2+
on: push
3+
4+
jobs:
5+
validate:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- name: Validate Sanity Template
10+
uses: sanity-io/[email protected]
11+
with:
12+
repository: ${{ github.repository }}

.gitignore

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
node_modules
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# misc
10+
.DS_Store
11+
*.pem
12+
13+
# debug
14+
npm-debug.log*
15+
yarn-debug.log*
16+
yarn-error.log*
17+
18+
# env files
19+
.env*
20+
!.env.template
21+
!.env.*.template
22+
23+
# vercel
24+
.vercel
25+
26+
# typescript
27+
*.tsbuildinfo
28+
next-env.d.ts

README.md

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,91 @@
1-
# A minimal SvelteKit site with Sanity Studio
1+
# Clean SvelteKit + Sanity app
22

3-
This starter uses [SvelteKit](https://kit.svelte.dev/) for the frontend and [Sanity](https://sanity.io/) to handle its content.
3+
This template includes a [SvelteKit](https://svelte.dev/docs/kit/introduction) app with a [Sanity Studio](https://www.sanity.io/) – an open-source React application that connects to your Sanity project’s hosted dataset. The Studio is configured locally and can then be deployed for content collaboration.
44

5-
## Featuring
5+
## Features
66

7-
- How to fetch content as data from [the Sanity Content Lake](https://www.sanity.io/docs/datastore)
8-
- How to render block content with [Portable Text](https://www.sanity.io/docs/presenting-block-text)
9-
- A [Sanity Studio](https://www.sanity.io/docs/sanity-studio) to create and edit content
10-
- Visual editing with live updates through [Presentation](https://www.sanity.io/docs/presentation)
11-
- How to crop and render images with [Sanity Image URLs](https://www.sanity.io/docs/image-url)
7+
- Fetch content seamlessly with [Sanity Content Lake](https://www.sanity.io/docs/datastore).
8+
- Render beautiful block content using [Portable Text](https://www.sanity.io/docs/presenting-block-text).
9+
- Manage and create content with the intuitive [Sanity Studio](https://www.sanity.io/docs/sanity-studio).
10+
- Live visual editing through [Sanity's Presentation tools](https://www.sanity.io/docs/presentation).
11+
- Advanced image cropping and rendering via [Sanity Image URLs](https://www.sanity.io/docs/image-url).
1212

13-
> **Note**
14-
>
15-
> This starter features an `/app` and a `/studio` folder. The `/app` folder contains the frontend code, and the `/studio` folder contains the Sanity Studio code.
16-
>
17-
> It is configured as a monorepo using [pnpm workspaces](https://pnpm.io/workspaces), but you can treat these directories as separate projects if you prefer.
13+
## Demo
1814

19-
## Prerequisities
15+
https://sanity-template-sveltekit-clean.sanity.build
2016

21-
- [Node.js](https://nodejs.org/en/) (v14.18 or later)
22-
- [Sanity CLI](https://www.sanity.io/docs/getting-started-with-sanity-cli) (optional)
17+
## Getting Started
2318

24-
## Getting started
19+
### Install the template
2520

26-
Run the following commands to prepare both applications, each step should be executed from the **root directory**:
21+
#### 1. Initialize template with Sanity CLI
2722

28-
1. Install dependencies.
23+
Run the command in your Terminal to initialize this template on your local computer.
2924

30-
```sh
31-
pnpm install
25+
See the documentation if you are [having issues with the CLI](https://www.sanity.io/help/cli-errors).
26+
27+
```shell
28+
npm create sanity@latest -- --template sanity-template-sveltekit-clean
3229
```
3330

34-
2. Select or create a Sanity project and dataset, and output the details to a `.env` file.
31+
#### 2. Run the application and Sanity Studio
32+
33+
Navigate to the template directory using `cd <your app name>`, and start the development servers by running the following command
3534

36-
```sh
37-
cd studio && pnpm sanity init --env .env
35+
```shell
36+
npm run dev
3837
```
3938

40-
3. [Generate a token](https://www.sanity.io/docs/http-auth#4c21d7b829fe) with read permissions for use in the next step.
39+
#### 3. Open the app and sign in to the Studio
4140

42-
```sh
43-
pnpm sanity manage
44-
```
41+
Open the SvelteKit app running locally in your browser on [http://localhost:5173](http://localhost:5173).
4542

46-
4. Copy the example app `.env` file and populate it with the required values.
43+
Open the Studio running locally in your browser on [http://localhost:3333](http://localhost:3333). You should now see a screen prompting you to log in to the Studio. Use the same service (Google, GitHub, or email) that you used when you logged in to the CLI.
4744

48-
```sh
49-
cp ./app/.env.example ./app/.env
50-
```
45+
### Adding content with Sanity
46+
47+
#### 1. Publish your first document
48+
49+
The template comes pre-defined with a schema containing a `Post` document type.
50+
51+
From the Studio, click "+ Create" and select the `Post` document type. Go ahead and create and publish the document.
52+
53+
Your content should now appear in your SvelteKit app ([http://localhost:5173](http://localhost:5173)) as well as in the Studio on the "Presentation" Tab
54+
55+
#### 2. Extending the Sanity schema
56+
57+
The schema for the `Post` document type is defined in the `studio/src/schemaTypes/post.ts` file. You can [add more document types](https://www.sanity.io/docs/schema-types) to the schema to suit your needs.
58+
59+
### Deploying your application and inviting editors
60+
61+
#### 1. Deploy Sanity Studio
62+
63+
Your SvelteKit frontend (`/sveltekit-app`) and Sanity Studio (`/studio`) are still only running on your local computer. It's time to deploy and get it into the hands of other content editors.
5164

52-
5. Start the development servers:
65+
Back in your Studio directory (`/studio`), run the following command to deploy your Sanity Studio.
5366

54-
```sh
55-
pnpm dev
67+
```shell
68+
npx sanity deploy
5669
```
5770

58-
- Your SvelteKit app should now be running on [http://localhost:5173/](http://localhost:5173/).
59-
- Your Studio should now be running on [http://localhost:3333/](http://localhost:3333/).
71+
#### 2. Deploy SvelteKit app to Vercel
6072

61-
### Add content
73+
You have the freedom to deploy your SvelteKit app to your hosting provider of choice. With Vercel and GitHub being a popular choice, we'll cover the basics of that approach.
6274

63-
1. Visit the Studio and create and publish a new `Post` document
64-
2. Visit the App and refresh the page to see your content rendered on the page
75+
1. Create a GitHub repository from this project. [Learn more](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github).
76+
2. Create a new Vercel project and connect it to your Github repository.
77+
3. Set the `Root Directory` to your SvelteKit app.
78+
4. Configure your Environment Variables.
6579

66-
The schema for the `Post` document is defined in the `/studio/schemas` folder. You can add more documents and schemas to the Studio to suit your needs.
80+
#### 3. Invite a collaborator
6781

68-
## Deployments
82+
Now that you’ve deployed your SvelteKit application and Sanity Studio, you can optionally invite a collaborator to your Studio. Open up [Manage](https://www.sanity.io/manage), select your project and click "Invite project members"
6983

70-
The `/app` and `/studio` folders are meant to be deployed separately.
84+
They will be able to access the deployed Studio, where you can collaborate together on creating content.
7185

72-
Make sure that after `/app` is deployed the `.env` file in `/studio` is updated with its deployment URL under `SANITY_STUDIO_PREVIEW_URL`.
86+
## Resources
7387

74-
And `/app` has a `.env` file with `PUBLIC_SANITY_STUDIO_URL` that points to the Studio's deployment URL.
88+
- [Sanity documentation](https://www.sanity.io/docs/)
89+
- [SvelteKit documentation](https://svelte.dev/docs/kit/introduction/)
90+
- [Join the Sanity Community](https://slack.sanity.io)
91+
- [Learn Sanity](https://www.sanity.io/learn)

0 commit comments

Comments
 (0)