@sanity/cli-test 0.0.2-alpha.1 → 0.0.2-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -0
- package/dist/index.d.ts +516 -3
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/test/constants.js +21 -0
- package/dist/test/constants.js.map +1 -0
- package/dist/test/createTestClient.js +53 -0
- package/dist/test/createTestClient.js.map +1 -0
- package/dist/test/createTestToken.js +13 -0
- package/dist/test/createTestToken.js.map +1 -0
- package/dist/test/mockApi.js +5 -3
- package/dist/test/mockApi.js.map +1 -1
- package/dist/test/mockSanityCommand.js +68 -0
- package/dist/test/mockSanityCommand.js.map +1 -0
- package/dist/test/mockTelemetry.js +22 -0
- package/dist/test/mockTelemetry.js.map +1 -0
- package/dist/test/setupFixtures.js +138 -0
- package/dist/test/setupFixtures.js.map +1 -0
- package/dist/test/snapshotSerializer.js +12 -0
- package/dist/test/snapshotSerializer.js.map +1 -0
- package/dist/test/testCommand.js +11 -4
- package/dist/test/testCommand.js.map +1 -1
- package/dist/test/testFixture.js +112 -0
- package/dist/test/testFixture.js.map +1 -0
- package/dist/test/testHook.js +23 -7
- package/dist/test/testHook.js.map +1 -1
- package/dist/utils/fileExists.js +13 -0
- package/dist/utils/fileExists.js.map +1 -0
- package/dist/utils/paths.js +66 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/vitest.d.ts +116 -0
- package/dist/vitest.js +22 -0
- package/dist/vitest.js.map +1 -0
- package/dist/vitestWorker.js +135 -0
- package/dist/vitestWorker.js.map +1 -0
- package/fixtures/basic-app/package.json +26 -0
- package/fixtures/basic-app/sanity.cli.ts +12 -0
- package/fixtures/basic-app/src/App.css +20 -0
- package/fixtures/basic-app/src/App.tsx +26 -0
- package/fixtures/basic-app/src/ExampleComponent.css +84 -0
- package/fixtures/basic-app/src/ExampleComponent.tsx +38 -0
- package/fixtures/basic-app/tsconfig.json +17 -0
- package/fixtures/basic-studio/package.json +28 -0
- package/fixtures/basic-studio/sanity.cli.ts +11 -0
- package/fixtures/basic-studio/sanity.config.ts +18 -0
- package/fixtures/basic-studio/schemaTypes/author.ts +52 -0
- package/fixtures/basic-studio/schemaTypes/blockContent.ts +71 -0
- package/fixtures/basic-studio/schemaTypes/category.ts +20 -0
- package/fixtures/basic-studio/schemaTypes/index.ts +6 -0
- package/fixtures/basic-studio/schemaTypes/post.ts +67 -0
- package/fixtures/basic-studio/tsconfig.json +17 -0
- package/fixtures/multi-workspace-studio/package.json +28 -0
- package/fixtures/multi-workspace-studio/sanity.cli.ts +11 -0
- package/fixtures/multi-workspace-studio/sanity.config.ts +37 -0
- package/fixtures/multi-workspace-studio/schemaTypes/author.ts +52 -0
- package/fixtures/multi-workspace-studio/schemaTypes/blockContent.ts +70 -0
- package/fixtures/multi-workspace-studio/schemaTypes/category.ts +20 -0
- package/fixtures/multi-workspace-studio/schemaTypes/index.ts +6 -0
- package/fixtures/multi-workspace-studio/schemaTypes/post.ts +67 -0
- package/fixtures/multi-workspace-studio/tsconfig.json +17 -0
- package/fixtures/prebuilt-app/README.md +3 -0
- package/fixtures/prebuilt-app/dist/favicon.ico +0 -0
- package/fixtures/prebuilt-app/dist/index.html +102 -0
- package/fixtures/prebuilt-app/dist/static/sanity-CtOxKsdo.css +24 -0
- package/fixtures/prebuilt-app/dist/static/sanity-D4a4eOYZ.js +17 -0
- package/fixtures/prebuilt-app/package.json +26 -0
- package/fixtures/prebuilt-app/sanity.cli.ts +12 -0
- package/fixtures/prebuilt-app/src/App.css +20 -0
- package/fixtures/prebuilt-app/src/App.tsx +24 -0
- package/fixtures/prebuilt-app/tsconfig.json +17 -0
- package/fixtures/prebuilt-studio/README.md +3 -0
- package/fixtures/prebuilt-studio/dist/favicon.ico +0 -0
- package/fixtures/prebuilt-studio/dist/index.html +113 -0
- package/fixtures/prebuilt-studio/dist/static/sanity-DxH-rpFr.js +9 -0
- package/fixtures/prebuilt-studio/package.json +25 -0
- package/fixtures/prebuilt-studio/sanity.cli.ts +11 -0
- package/fixtures/prebuilt-studio/sanity.config.ts +11 -0
- package/fixtures/prebuilt-studio/tsconfig.json +17 -0
- package/fixtures/worst-case-studio/README.md +21 -0
- package/fixtures/worst-case-studio/package.json +32 -0
- package/fixtures/worst-case-studio/sanity.cli.ts +16 -0
- package/fixtures/worst-case-studio/sanity.config.tsx +49 -0
- package/fixtures/worst-case-studio/src/defines.ts +8 -0
- package/fixtures/worst-case-studio/src/descriptionIcon.svg +7 -0
- package/fixtures/worst-case-studio/src/descriptionInput.module.css +13 -0
- package/fixtures/worst-case-studio/src/descriptionInput.tsx +55 -0
- package/fixtures/worst-case-studio/src/schemaTypes/author.ts +52 -0
- package/fixtures/worst-case-studio/src/schemaTypes/blockContent.ts +70 -0
- package/fixtures/worst-case-studio/src/schemaTypes/category.ts +20 -0
- package/fixtures/worst-case-studio/src/schemaTypes/index.ts +6 -0
- package/fixtures/worst-case-studio/src/schemaTypes/post.ts +71 -0
- package/fixtures/worst-case-studio/src/typings.d.ts +37 -0
- package/fixtures/worst-case-studio/tsconfig.json +22 -0
- package/package.json +52 -22
- package/dist/test/captureOutput.d.ts +0 -33
- package/dist/test/mockApi.d.ts +0 -34
- package/dist/test/testCommand.d.ts +0 -6
- package/dist/test/testHook.d.ts +0 -8
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* Container styling for the app */
|
|
2
|
+
.app-container {
|
|
3
|
+
max-width: 1200px;
|
|
4
|
+
margin: 0 auto;
|
|
5
|
+
padding: 2rem;
|
|
6
|
+
font-family:
|
|
7
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
|
|
8
|
+
'Helvetica Neue', sans-serif;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Basic reset */
|
|
12
|
+
* {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
background-color: #f9f9f9;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {type SanityConfig} from '@sanity/sdk'
|
|
2
|
+
import {SanityApp} from '@sanity/sdk-react'
|
|
3
|
+
|
|
4
|
+
import './App.css'
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
// apps can access many different projects or other sources of data
|
|
8
|
+
const sanityConfigs: SanityConfig[] = [
|
|
9
|
+
{
|
|
10
|
+
dataset: 'dataset-name',
|
|
11
|
+
projectId: 'project-id',
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="app-container">
|
|
17
|
+
<SanityApp config={sanityConfigs} fallback={<div>Loading...</div>}>
|
|
18
|
+
<div />
|
|
19
|
+
</SanityApp>
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default App
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"module": "Preserve",
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"incremental": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
16
|
+
"exclude": ["node_modules"]
|
|
17
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta
|
|
6
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover"
|
|
7
|
+
name="viewport"
|
|
8
|
+
/>
|
|
9
|
+
<meta content="noindex" name="robots" />
|
|
10
|
+
<meta content="same-origin" name="referrer" />
|
|
11
|
+
<title>Sanity Studio</title>
|
|
12
|
+
<style>
|
|
13
|
+
html,
|
|
14
|
+
body,
|
|
15
|
+
#sanity {
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
body {
|
|
19
|
+
margin: 0;
|
|
20
|
+
-webkit-font-smoothing: antialiased;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
23
|
+
<script type="application/json" id="__imports">
|
|
24
|
+
{
|
|
25
|
+
"imports": {
|
|
26
|
+
"react": "/vendor/react/index-CVS62ceT.mjs",
|
|
27
|
+
"react/compiler-runtime": "/vendor/react/compiler-runtime-DFvlMPQC.mjs",
|
|
28
|
+
"react/jsx-dev-runtime": "/vendor/react/jsx-dev-runtime-DYLplPiq.mjs",
|
|
29
|
+
"react/jsx-runtime": "/vendor/react/jsx-runtime-CInpRuN4.mjs",
|
|
30
|
+
"react/package.json": "/vendor/react/package.json-B3Sv_Ots.mjs",
|
|
31
|
+
"react-dom": "/vendor/react-dom/index-B3pchmCn.mjs",
|
|
32
|
+
"react-dom/client": "/vendor/react-dom/client-BptInOSw.mjs",
|
|
33
|
+
"react-dom/package.json": "/vendor/react-dom/package.json-CNqBlmzA.mjs",
|
|
34
|
+
"react-dom/server": "/vendor/react-dom/server-FfCSsckh.mjs",
|
|
35
|
+
"react-dom/static": "/vendor/react-dom/static-CN1Myo0a.mjs",
|
|
36
|
+
"styled-components": "/vendor/styled-components/index-X329-4Jb.mjs",
|
|
37
|
+
"styled-components/package.json": "/vendor/styled-components/package.json-DqoIBjAO.mjs",
|
|
38
|
+
"react-dom/server.browser": "/vendor/react-dom/server.browser-BzpYnHww.mjs",
|
|
39
|
+
"react-dom/static.browser": "/vendor/react-dom/static.browser-BCHXHC4T.mjs",
|
|
40
|
+
"sanity": "https://sanity-cdn.com/v1/modules/sanity/default/%5E5.7.0/t1769729422",
|
|
41
|
+
"sanity/": "https://sanity-cdn.com/v1/modules/sanity/default/%5E5.7.0/t1769729422/",
|
|
42
|
+
"@sanity/vision": "https://sanity-cdn.com/v1/modules/@sanity__vision/default/%5E5.7.0/t1769729422",
|
|
43
|
+
"@sanity/vision/": "https://sanity-cdn.com/v1/modules/@sanity__vision/default/%5E5.7.0/t1769729422/"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
<script>
|
|
48
|
+
// auto-generated script to add import map with timestamp
|
|
49
|
+
const importsJson = document.getElementById('__imports')?.textContent
|
|
50
|
+
const {imports = {}, ...rest} = importsJson ? JSON.parse(importsJson) : {}
|
|
51
|
+
const importMapEl = document.createElement('script')
|
|
52
|
+
importMapEl.type = 'importmap'
|
|
53
|
+
const newTimestamp = `/t${Math.floor(Date.now() / 1000)}`
|
|
54
|
+
importMapEl.textContent = JSON.stringify({
|
|
55
|
+
imports: Object.fromEntries(
|
|
56
|
+
Object.entries(imports).map(([specifier, path]) => {
|
|
57
|
+
try {
|
|
58
|
+
const url = new URL(path)
|
|
59
|
+
if (/^sanity-cdn\.[a-zA-Z]+$/.test(url.hostname)) {
|
|
60
|
+
url.pathname = url.pathname.replace(/\/t\d+/, newTimestamp)
|
|
61
|
+
}
|
|
62
|
+
return [specifier, url.toString()]
|
|
63
|
+
} catch {
|
|
64
|
+
return [specifier, path]
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
|
+
...rest,
|
|
69
|
+
})
|
|
70
|
+
document.head.appendChild(importMapEl)
|
|
71
|
+
</script>
|
|
72
|
+
<script
|
|
73
|
+
src="https://core.sanity-cdn.com/bridge.js"
|
|
74
|
+
async
|
|
75
|
+
type="module"
|
|
76
|
+
data-sanity-core
|
|
77
|
+
></script>
|
|
78
|
+
</head>
|
|
79
|
+
<body>
|
|
80
|
+
<div id="sanity"></div>
|
|
81
|
+
<script src="/static/sanity-DxH-rpFr.js" type="module"></script>
|
|
82
|
+
<noscript
|
|
83
|
+
><div class="sanity-app-no-js__root">
|
|
84
|
+
<div class="sanity-app-no-js__content">
|
|
85
|
+
<style type="text/css">
|
|
86
|
+
.sanity-app-no-js__root {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
left: 0;
|
|
91
|
+
bottom: 0;
|
|
92
|
+
background: #fff;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.sanity-app-no-js__content {
|
|
96
|
+
position: absolute;
|
|
97
|
+
top: 50%;
|
|
98
|
+
left: 50%;
|
|
99
|
+
transform: translate(-50%, -50%);
|
|
100
|
+
text-align: center;
|
|
101
|
+
font-family: helvetica, arial, sans-serif;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
104
|
+
<h1>JavaScript disabled</h1>
|
|
105
|
+
<p>
|
|
106
|
+
Please <a href="https://www.enable-javascript.com/">enable JavaScript</a> in your
|
|
107
|
+
browser and reload the page to proceed.
|
|
108
|
+
</p>
|
|
109
|
+
</div>
|
|
110
|
+
</div></noscript
|
|
111
|
+
>
|
|
112
|
+
</body>
|
|
113
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prebuilt-studio",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sanity"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "package.json",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "sanity dev",
|
|
13
|
+
"preview": "sanity preview"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"react": "^19.2.3",
|
|
17
|
+
"react-dom": "^19.2.3",
|
|
18
|
+
"sanity": "^5.9.0",
|
|
19
|
+
"styled-components": "^6.3.8"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/react": "^19.2.9",
|
|
23
|
+
"typescript": "^5.9.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"module": "Preserve",
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"incremental": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
16
|
+
"exclude": ["node_modules"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# worst-case-studio
|
|
2
|
+
|
|
3
|
+
A collection of things we'd rather not have you do, but that we technically speaking
|
|
4
|
+
"have" to support for backwards compatibility or similar reasons.
|
|
5
|
+
|
|
6
|
+
## The Unfortunates List™
|
|
7
|
+
|
|
8
|
+
- TypeScript path aliases in CLI config (through typescript)
|
|
9
|
+
- TypeScript path aliases in studio config (through vite plugin)
|
|
10
|
+
- JSX in studio config
|
|
11
|
+
- CSS imports in studio config
|
|
12
|
+
- Font/SVG/file imports in studio config
|
|
13
|
+
- Browser-only globals in studio config
|
|
14
|
+
- Timers setup in studio config
|
|
15
|
+
- Top level await in studio config
|
|
16
|
+
- HTTP imports in studio config
|
|
17
|
+
- TypeScript syntax extensions (enums) in studio config
|
|
18
|
+
- CommonJS vs ESM
|
|
19
|
+
- Environment variables from `.env`
|
|
20
|
+
- Environment variables from `process.env` and `import.meta.env`
|
|
21
|
+
- Vite config from `sanity.cli.ts`, with global defines
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "worst-case-studio",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sanity"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "package.json",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"deploy": "sanity deploy",
|
|
13
|
+
"deploy-graphql": "sanity graphql deploy",
|
|
14
|
+
"dev": "sanity dev",
|
|
15
|
+
"start": "sanity start"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@sanity/code-input": "^7.0.6",
|
|
19
|
+
"@sanity/vision": "^5.9.0",
|
|
20
|
+
"react": "^19.2.3",
|
|
21
|
+
"react-dom": "^19.2.3",
|
|
22
|
+
"sanity": "^5.9.0",
|
|
23
|
+
"styled-components": "^6.3.8",
|
|
24
|
+
"vite-tsconfig-paths": "^6.0.5"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@sanity/color": "^3.0.6",
|
|
28
|
+
"@types/react": "^19.2.9",
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"vite": "^7.3.1"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {defineCliConfig} from 'sanity/cli'
|
|
2
|
+
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line import/no-unresolved
|
|
5
|
+
import {defines} from '@/defines'
|
|
6
|
+
|
|
7
|
+
export default defineCliConfig({
|
|
8
|
+
api: {
|
|
9
|
+
dataset: 'test',
|
|
10
|
+
projectId: 'ppsg7ml5',
|
|
11
|
+
},
|
|
12
|
+
vite: {
|
|
13
|
+
define: defines,
|
|
14
|
+
plugins: [tsconfigPaths({root: '.'})],
|
|
15
|
+
},
|
|
16
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {codeInput} from '@sanity/code-input'
|
|
2
|
+
import {visionTool} from '@sanity/vision'
|
|
3
|
+
// eslint-disable-next-line import/no-unresolved
|
|
4
|
+
import {theme} from 'https://themer.sanity.build/api/hues?preset=dew'
|
|
5
|
+
import {defineConfig, defineField, defineType} from 'sanity'
|
|
6
|
+
import {structureTool} from 'sanity/structure'
|
|
7
|
+
|
|
8
|
+
import DescriptionInput from '@/descriptionInput'
|
|
9
|
+
import {schemaTypes} from '@/schemaTypes'
|
|
10
|
+
|
|
11
|
+
// Look ma, dynamic imports in the config 🙈
|
|
12
|
+
// Look ma, top level await in the config 🙈
|
|
13
|
+
const arbitraryImport = await import('@/defines')
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
theme,
|
|
17
|
+
title: arbitraryImport.studioTitle,
|
|
18
|
+
|
|
19
|
+
dataset: 'test',
|
|
20
|
+
|
|
21
|
+
// Don't do this in a real project.
|
|
22
|
+
// @ts-expect-error - defined through vite's `define` option in CLI config
|
|
23
|
+
projectId: PROJECT_ID,
|
|
24
|
+
|
|
25
|
+
plugins: [structureTool(), visionTool(), codeInput()],
|
|
26
|
+
|
|
27
|
+
schema: {
|
|
28
|
+
types: [
|
|
29
|
+
...schemaTypes,
|
|
30
|
+
|
|
31
|
+
defineType({
|
|
32
|
+
fields: [
|
|
33
|
+
defineField({name: 'title', type: 'string'}),
|
|
34
|
+
defineField({components: {input: DescriptionInput}, name: 'description', type: 'text'}),
|
|
35
|
+
],
|
|
36
|
+
name: 'wurst',
|
|
37
|
+
type: 'document',
|
|
38
|
+
|
|
39
|
+
preview: {
|
|
40
|
+
prepare(values) {
|
|
41
|
+
// Look ma, JSX in the config 🙈
|
|
42
|
+
return {...values, media: <em>🌭</em>}
|
|
43
|
+
},
|
|
44
|
+
select: {title: 'title'},
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<rect width="512" height="512" fill="#F03E2F" rx="30" />
|
|
4
|
+
<path d="M161.527 136.723C161.527 179.76 187.738 205.443 240.388 219.095L296 232.283C345.687 243.852 376 272.775 376 319.514C376 341.727 369.162 360.931 357.538 375.971C357.538 329.232 333.607 303.78 276.171 288.74L221.47 276.246C177.709 266.065 143.977 242.464 143.977 191.56C143.977 170.505 150.359 151.994 161.527 136.723Z" fill="white" />
|
|
5
|
+
<path opacity="0.5" d="M323.35 308.176C347.054 323.679 357.538 345.197 357.538 376.202C337.709 401.654 303.293 416 262.724 416C194.575 416 146.484 381.756 136 322.753H201.641C210.074 350.056 232.41 362.551 262.268 362.551C298.735 362.32 322.895 342.652 323.35 308.176Z" fill="white" />
|
|
6
|
+
<path opacity="0.5" d="M195.715 200.816C172.923 186.007 161.527 165.183 161.527 136.954C180.672 111.503 213.493 96 253.835 96C323.35 96 363.692 133.252 373.721 185.776H310.359C303.293 165.183 285.971 148.986 254.291 148.986C220.33 148.986 197.311 169.116 195.715 200.816Z" fill="white" />
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {useEffect, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
// Look ma, SVG imports in the config 🙈
|
|
4
|
+
import iconPath from './descriptionIcon.svg'
|
|
5
|
+
// Look ma, CSS module imports in the config 🙈
|
|
6
|
+
import styles from './descriptionInput.module.css'
|
|
7
|
+
|
|
8
|
+
// Look ma, process.env variables in the config 🙈
|
|
9
|
+
if (process.env.SANITY_STUDIO_PREFIXED_VAR !== 'yes-this-is-prefixed') {
|
|
10
|
+
throw new Error('`process.env.SANITY_STUDIO_PREFIXED_VAR` is not set to `yes-this-is-prefixed`')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Look ma, import.meta.env variables in the config 🙈
|
|
14
|
+
if (import.meta.env.SANITY_STUDIO_PREFIXED_VAR !== 'yes-this-is-prefixed') {
|
|
15
|
+
throw new Error(
|
|
16
|
+
'`import.meta.env.SANITY_STUDIO_PREFIXED_VAR` is not set to `yes-this-is-prefixed`',
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function DescriptionInput() {
|
|
21
|
+
const [counter, setCounter] = useState(0)
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const timer = setInterval(() => {
|
|
24
|
+
setCounter((prev) => prev + 1)
|
|
25
|
+
}, 1000)
|
|
26
|
+
|
|
27
|
+
return () => clearInterval(timer)
|
|
28
|
+
}, [])
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className={styles.input}>
|
|
32
|
+
<img src={iconPath} style={{width: '32px'}} />
|
|
33
|
+
Look ma, gradients, icons & counters
|
|
34
|
+
<div className={styles.counter}>{counter}</div>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const logCallback = requestIdleCallback(() => {
|
|
40
|
+
console.log('Look ma, requestIdleCallback in the config 🙈')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
if (document.location.hostname === 'localhost') {
|
|
44
|
+
console.log('Look ma, `document` references in the config 🙈')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Look ma, unchecked `window` references in the config 🙈
|
|
48
|
+
window.addEventListener('beforeunload', () => {
|
|
49
|
+
cancelIdleCallback(logCallback)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Look ma, this will just run forever 🙈
|
|
53
|
+
setInterval(() => {
|
|
54
|
+
console.log('Look ma, setInterval in the config 🙈')
|
|
55
|
+
}, 15_000)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {defineField, defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
export default defineType({
|
|
4
|
+
name: 'author',
|
|
5
|
+
title: 'Author',
|
|
6
|
+
type: 'document',
|
|
7
|
+
|
|
8
|
+
fields: [
|
|
9
|
+
defineField({
|
|
10
|
+
name: 'name',
|
|
11
|
+
title: 'Name',
|
|
12
|
+
type: 'string',
|
|
13
|
+
}),
|
|
14
|
+
defineField({
|
|
15
|
+
name: 'slug',
|
|
16
|
+
options: {
|
|
17
|
+
maxLength: 96,
|
|
18
|
+
source: 'name',
|
|
19
|
+
},
|
|
20
|
+
title: 'Slug',
|
|
21
|
+
type: 'slug',
|
|
22
|
+
}),
|
|
23
|
+
defineField({
|
|
24
|
+
name: 'image',
|
|
25
|
+
options: {
|
|
26
|
+
hotspot: true,
|
|
27
|
+
},
|
|
28
|
+
title: 'Image',
|
|
29
|
+
type: 'image',
|
|
30
|
+
}),
|
|
31
|
+
defineField({
|
|
32
|
+
name: 'bio',
|
|
33
|
+
of: [
|
|
34
|
+
{
|
|
35
|
+
lists: [],
|
|
36
|
+
styles: [{title: 'Normal', value: 'normal'}],
|
|
37
|
+
title: 'Block',
|
|
38
|
+
type: 'block',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
title: 'Bio',
|
|
42
|
+
type: 'array',
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
preview: {
|
|
47
|
+
select: {
|
|
48
|
+
media: 'image',
|
|
49
|
+
title: 'name',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {defineArrayMember, defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is the schema definition for the rich text fields used for
|
|
5
|
+
* for this blog studio. When you import it in schemas.js it can be
|
|
6
|
+
* reused in other parts of the studio with:
|
|
7
|
+
* ```ts
|
|
8
|
+
* {
|
|
9
|
+
* name: 'someName',
|
|
10
|
+
* title: 'Some title',
|
|
11
|
+
* type: 'blockContent'
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export default defineType({
|
|
16
|
+
name: 'blockContent',
|
|
17
|
+
title: 'Block Content',
|
|
18
|
+
type: 'array',
|
|
19
|
+
|
|
20
|
+
of: [
|
|
21
|
+
defineArrayMember({
|
|
22
|
+
lists: [{title: 'Bullet', value: 'bullet'}],
|
|
23
|
+
// Marks let you mark up inline text in the block editor.
|
|
24
|
+
marks: {
|
|
25
|
+
// Annotations can be any object structure – e.g. a link or a footnote.
|
|
26
|
+
annotations: [
|
|
27
|
+
{
|
|
28
|
+
fields: [
|
|
29
|
+
{
|
|
30
|
+
name: 'href',
|
|
31
|
+
title: 'URL',
|
|
32
|
+
type: 'url',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
name: 'link',
|
|
36
|
+
title: 'URL',
|
|
37
|
+
type: 'object',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
// Decorators usually describe a single property – e.g. a typographic
|
|
41
|
+
// preference or highlighting by editors.
|
|
42
|
+
decorators: [
|
|
43
|
+
{title: 'Strong', value: 'strong'},
|
|
44
|
+
{title: 'Emphasis', value: 'em'},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
// Styles let you set what your user can mark up blocks with. These
|
|
48
|
+
// correspond with HTML tags, but you can set any title or value
|
|
49
|
+
// you want and decide how you want to deal with it where you want to
|
|
50
|
+
// use your content.
|
|
51
|
+
styles: [
|
|
52
|
+
{title: 'Normal', value: 'normal'},
|
|
53
|
+
{title: 'H1', value: 'h1'},
|
|
54
|
+
{title: 'H2', value: 'h2'},
|
|
55
|
+
{title: 'H3', value: 'h3'},
|
|
56
|
+
{title: 'H4', value: 'h4'},
|
|
57
|
+
{title: 'Quote', value: 'blockquote'},
|
|
58
|
+
],
|
|
59
|
+
title: 'Block',
|
|
60
|
+
type: 'block',
|
|
61
|
+
}),
|
|
62
|
+
// You can add additional types here. Note that you can't use
|
|
63
|
+
// primitive types such as 'string' and 'number' in the same array
|
|
64
|
+
// as a block type.
|
|
65
|
+
defineArrayMember({
|
|
66
|
+
options: {hotspot: true},
|
|
67
|
+
type: 'image',
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {defineField, defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
export default defineType({
|
|
4
|
+
name: 'category',
|
|
5
|
+
title: 'Category',
|
|
6
|
+
type: 'document',
|
|
7
|
+
|
|
8
|
+
fields: [
|
|
9
|
+
defineField({
|
|
10
|
+
name: 'title',
|
|
11
|
+
title: 'Title',
|
|
12
|
+
type: 'string',
|
|
13
|
+
}),
|
|
14
|
+
defineField({
|
|
15
|
+
name: 'description',
|
|
16
|
+
title: 'Description',
|
|
17
|
+
type: 'text',
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
})
|