Skip to content

Commit

Permalink
add sanity-plugin-sanitypress plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchuman committed Feb 20, 2025
1 parent 3a2fc1a commit 95d2dcd
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 234 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# testing
/coverage
.yalc/
yalc.lock

# next.js
/.next/
Expand Down Expand Up @@ -37,4 +39,4 @@ next-env.d.ts

public/google*.html

public/admin/static
public/admin/static
65 changes: 23 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"react-icons": "^5.5.0",
"sanity": "^3.76.3",
"sanity-plugin-dashboard-widget-vercel": "^2.0.1",
"sanity-plugin-sanitypress": "^0.0.1",
"shiki": "^3.0.0",
"styled-components": "^6.1.15",
"tailwind-merge": "^3.0.1",
Expand Down
40 changes: 19 additions & 21 deletions sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use client'

import pkg from '$/package.json'
import { defineConfig } from 'sanity'
import { projectId, dataset, apiVersion } from '@/sanity/lib/env'
import { icon, structure } from './src/sanity/structure'
import { structure } from './src/sanity/structure'
import { presentation } from './src/sanity/presentation'
import { sanitypress, icon, infoWidget } from 'sanity-plugin-sanitypress'
import {
dashboardTool,
projectInfoWidget,
projectUsersWidget,
} from '@sanity/dashboard'
import { infoWidget } from './src/sanity/infoWidget'
import { vercelWidget } from 'sanity-plugin-dashboard-widget-vercel'
import { visionTool } from '@sanity/vision'
import { codeInput } from '@sanity/code-input'
import { schemaTypes } from './src/sanity/schemaTypes'

const singletonTypes = ['site']
import resolveUrl from '@/lib/resolveUrl'

export default defineConfig({
title: 'SanityPress',
Expand All @@ -27,6 +27,9 @@ export default defineConfig({
plugins: [
structure,
presentation,
sanitypress({
singletonTypes: ['site'],
}),
dashboardTool({
name: 'deployment',
title: 'Deployment',
Expand All @@ -35,31 +38,26 @@ export default defineConfig({
dashboardTool({
name: 'info',
title: 'Info',
widgets: [projectInfoWidget(), projectUsersWidget(), infoWidget()],
widgets: [
projectInfoWidget(),
projectUsersWidget(),
infoWidget({ version: pkg.version }),
],
}),
visionTool({ defaultApiVersion: apiVersion }),
codeInput(),
],

tasks: { enabled: false },
scheduledPublishing: { enabled: false },

schema: {
types: schemaTypes,
templates: (templates) =>
templates.filter(
({ schemaType }) => !singletonTypes.includes(schemaType),
),
},

document: {
actions: (input, { schemaType }) =>
singletonTypes.includes(schemaType)
? input.filter(
({ action }) =>
action &&
['publish', 'discardChanges', 'restore'].includes(action),
)
: input,
productionUrl: async (prev, { document }) => {
if (['page', 'blog.post'].includes(document?._type)) {
return resolveUrl(document as Sanity.PageBase, { base: true })
}

return prev
},
},
})
160 changes: 0 additions & 160 deletions src/sanity/infoWidget.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions src/sanity/structure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,3 @@ export const structure = structureTool({
]).icon(BsDatabaseAdd),
]),
})

export function icon() {
return (
<img
style={{ width: '100%', aspectRatio: 1 }}
src="/favicon.ico"
alt="SanityPress"
/>
)
}

0 comments on commit 95d2dcd

Please sign in to comment.