-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37b5a5e
commit c9aa39f
Showing
6 changed files
with
94 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { defineField, defineType } from "sanity" | ||
import { defineSlugForDocument } from "../../utils/define-slug-for-document"; | ||
|
||
const name = 'NotFound_Page'; | ||
const title = 'Strony nie znaleziono'; | ||
const slug = '/404'; | ||
const icon = () => '🔍'; | ||
|
||
export default defineType({ | ||
name: name, | ||
type: 'document', | ||
title: title, | ||
icon, | ||
fields: [ | ||
...defineSlugForDocument({ slug: slug }), | ||
defineField({ | ||
name: 'components', | ||
type: 'components', | ||
title: 'Page Components', | ||
}), | ||
defineField({ | ||
name: 'seo', | ||
type: 'seo', | ||
title: 'SEO', | ||
group: 'seo', | ||
}), | ||
], | ||
groups: [ | ||
{ | ||
name: 'seo', | ||
title: 'SEO', | ||
}, | ||
], | ||
preview: { | ||
prepare: () => ({ | ||
title: title, | ||
subtitle: slug | ||
}) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { StructureBuilder } from "sanity/structure"; | ||
import { schemaTypes } from "./schema-types"; | ||
import { Preview } from "./preview"; | ||
import { TYPES_TO_EXCLUDE_PREVIEWS } from "."; | ||
|
||
export const createCollection = (S: StructureBuilder, name: string) => { | ||
const { title, icon } = schemaTypes.find(item => item.name === name) as { title: string, icon: React.ReactNode }; | ||
return S.listItem() | ||
.id(name) | ||
.title(title) | ||
.icon(icon) | ||
.child( | ||
S.documentTypeList(name) | ||
.title(title) | ||
.child(documentId => | ||
S.document() | ||
.documentId(documentId) | ||
.schemaType(name) | ||
.views([ | ||
S.view.form().title('Editor').icon(() => '🖋️'), | ||
...(!TYPES_TO_EXCLUDE_PREVIEWS.includes(name) ? [ | ||
S.view | ||
.component(Preview) | ||
.title('Preview') | ||
.icon(() => '👀') | ||
] : []), | ||
]) | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Iframe, type IframeProps } from "sanity-plugin-iframe-pane"; | ||
import { PREVIEW_DEPLOYMENT_DOMAIN } from "../constants"; | ||
|
||
export const Preview = ({ document }: { document: IframeProps['document'] }) => { | ||
const slug = (document.displayed.slug as { current?: string })?.current; | ||
if (!slug) return <div style={{ padding: '1rem' }}>🛑 Preview not available: The slug is missing</div>; | ||
return <Iframe | ||
document={document} | ||
options={{ | ||
url: `${PREVIEW_DEPLOYMENT_DOMAIN}${slug}`, | ||
reload: { button: true } | ||
}} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters