Skip to content

Commit 6a793de

Browse files
committed
First commit w/ examples 🌈
0 parents  commit 6a793de

Some content is hidden

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

55 files changed

+8388
-0
lines changed

‎.env.example

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
VITE_SANITY_PROJECT_ID=""
2+
VITE_SANITY_DATASET="production"
3+
4+
## Also available on the client side, because studio is a SPA.
5+
VITE_SANITY_PREVIEW_SECRET="any-random-string"
6+
7+
SANITY_API_READ_TOKEN=""
8+
SANITY_API_WRITE_TOKEN=""

‎.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
.vercel

‎README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Sveltekit x Sanity Studio v3
2+
3+
Hi there 👋! This is a repo for my talk at the [Sanity.io Virtual Meetup - Autumn 2022](https://www.meetup.com/meetup-group-dvjyrjdv/events/289456759/).
4+
5+
## Features
6+
7+
### ✨ Embedding Sanity V3 in a Sveltekit app
8+
9+
When I was working on a new project that involved [Sveltekit](https://kit.svelte.dev/) and Sanity I got curious and wanted to know whether I could directly embed the Sanity Studio V3 (Release Candiate) into a SvelteKit app. I was living on the edge already, so I might as well embrace it 🌈
10+
11+
### 👀 Side-by-side Instant Content preview.
12+
13+
I also go over on how we use Sanity's Side-by-side Instant Content preview feature with Sveltekit. And how you can easily implement this in your own SvelteKit applications. The code ([createPreviewSubscriptionStore](https://github.com/multiplehats/sveltekit-sanityv3/blob/main/src/lib/config/sanity/sveltekit/previewSubscriptionStore.ts#L10)) is mostly inspired from [Sanity's toolkit for Next.js](https://github.com/sanity-io/next-sanity).
14+
15+
#### Learn more
16+
- [Introduction to Sanity Studio v3](https://beta.sanity.io/docs/platform/studio/v2-to-v3)
17+
- [Sanity Studio V3 Announcement](https://www.sanity.io/blog/sanity-studio-v3-developer-preview)
18+
19+
## Developing
20+
21+
Once you've created a project and installed dependencies with `pnpm install`. Make sure you have added all the environment variables (see env.example).
22+
23+
```bash
24+
pnpm dev
25+
26+
# or start the server and open the app in a new browser tab
27+
pnpm dev -- --open
28+
```
29+
30+
## Building & Previewing
31+
32+
To build the project, run:
33+
34+
```bash
35+
pnpm build
36+
```
37+
38+
To preview the build, run:
39+
```bash
40+
pnpm preview
41+
```

‎cypress.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
video: true,
5+
screenshotOnRunFailure: true,
6+
7+
e2e: {
8+
baseUrl: 'http://localhost:3000/',
9+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
10+
setupNodeEvents(on, config) {
11+
// implement node event listeners here
12+
},
13+
},
14+
});

‎cypress/e2e/spec.cy.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
describe('Svelte Meta Tags', () => {
2+
it('Homepage loads', () => {
3+
cy.visit('/');
4+
cy.get('h1').should('contain', 'Welcome to SvelteKit');
5+
});
6+
});

‎cypress/fixtures/example.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

‎cypress/support/commands.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************
3+
// This example commands.ts shows you how to
4+
// create various custom commands and overwrite
5+
// existing commands.
6+
//
7+
// For more comprehensive examples of custom
8+
// commands please read more here:
9+
// https://on.cypress.io/custom-commands
10+
// ***********************************************
11+
//
12+
//
13+
// -- This is a parent command --
14+
// Cypress.Commands.add('login', (email, password) => { ... })
15+
//
16+
//
17+
// -- This is a child command --
18+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19+
//
20+
//
21+
// -- This is a dual command --
22+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23+
//
24+
//
25+
// -- This will overwrite an existing command --
26+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }

‎cypress/support/e2e.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/e2e.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

‎cypress/videos/spec.cy.js.mp4

7.19 KB
Binary file not shown.

‎package.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "daghappie",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite dev --port 3000",
7+
"build": "vite build",
8+
"preview": "vite preview",
9+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11+
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
12+
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
13+
"cy:open": "cypress open",
14+
"cy:run": "cypress run",
15+
"test": "pnpm cy:run"
16+
},
17+
"devDependencies": {
18+
"@sveltejs/adapter-auto": "next",
19+
"@sveltejs/kit": "next",
20+
"@types/react": "^18.0.24",
21+
"@types/react-dom": "^18.0.8",
22+
"@typescript-eslint/eslint-plugin": "^5.41.0",
23+
"@typescript-eslint/parser": "^5.41.0",
24+
"cypress": "^10.11.0",
25+
"eslint": "^8.26.0",
26+
"eslint-config-prettier": "^8.5.0",
27+
"eslint-plugin-cypress": "^2.12.1",
28+
"eslint-plugin-svelte3": "^4.0.0",
29+
"prettier": "^2.7.1",
30+
"prettier-plugin-svelte": "^2.8.0",
31+
"svelte": "^3.52.0",
32+
"svelte-check": "^2.9.2",
33+
"svelte-preprocess": "^4.10.7",
34+
"svelte2tsx": "^0.5.20",
35+
"ts-node": "^10.9.1",
36+
"tslib": "^2.4.0",
37+
"typescript": "^4.8.4",
38+
"vite": "^3.2.2",
39+
"vite-plugin-windicss": "^1.8.8",
40+
"windicss": "^3.5.6"
41+
},
42+
"dependencies": {
43+
"@sanity/client": "^3.4.1",
44+
"@sanity/groq-store": "^1.0.3",
45+
"@sanity/icons": "^1.3.6",
46+
"@sanity/image-url": "^1.0.1",
47+
"@sanity/ui": "^0.37.22",
48+
"@sanity/vision": "3.0.0-dev-preview.22",
49+
"@sanity/webhook": "^2.0.0",
50+
"groq": "^2.33.2",
51+
"react": "^18.2.0",
52+
"react-dom": "^18.2.0",
53+
"sanity": "3.0.0-dev-preview.22",
54+
"sanity-plugin-asset-source-unsplash": "3.0.0-v3-studio.10"
55+
},
56+
"type": "module"
57+
}

0 commit comments

Comments
 (0)