Skip to content

Commit

Permalink
feature/integrate @focus-reactive/sanity-plugin-cms-kit (#24)
Browse files Browse the repository at this point in the history
* Add `@focus-reactive/sanity-plugin-cms-kit`

* Add missing dep

* test tempolate

* fix all templates

* remove templates and comment env initialization in sanity cli package

* add hero template

* add new format templates and scronshots to the core sections

* comment blog templates

---------

Co-authored-by: maksim hodasevich <[email protected]>
  • Loading branch information
chenaski and dogfrogfog authored Dec 25, 2024
1 parent 172ed98 commit cd1aa23
Show file tree
Hide file tree
Showing 38 changed files with 695 additions and 1,306 deletions.
1 change: 1 addition & 0 deletions apps/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"gen:types": "pnpm extract-schema && pnpm sanity typegen generate"
},
"dependencies": {
"@focus-reactive/sanity-plugin-cms-kit": "^0.1.0",
"@portabletext/react": "^3.1.0",
"@sanity/client": "^6.21.1",
"@sanity/image-url": "^1.0.2",
Expand Down
8 changes: 5 additions & 3 deletions apps/sanity/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loadEnvConfig } from "@next/env";
// import { loadEnvConfig } from "@next/env";
import { defineCliConfig } from "sanity/cli";

const dev = process.env.NODE_ENV !== "production";
loadEnvConfig(__dirname, dev, { info: () => null, error: console.error });
console.log("add logic to load ebv variables");

// const dev = process.env.NODE_ENV !== "production";
// loadEnvConfig(__dirname, dev, { info: () => null, error: console.error });

// @TODO report top-level await bug
// Using a dynamic import here as `loadEnvConfig` needs to run before this file is loaded
Expand Down
2 changes: 2 additions & 0 deletions apps/sanity/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CMSKitContentBlocks } from "@focus-reactive/sanity-plugin-cms-kit";
import { visionTool } from "@sanity/vision";
import { pages } from "@tinloof/sanity-studio";
import { defineConfig } from "sanity";
Expand Down Expand Up @@ -40,5 +41,6 @@ export default defineConfig({
structureTool(),
visionTool({ defaultApiVersion: config.sanity.apiVersion }),
simplerColorInput(),
CMSKitContentBlocks({}),
],
});
101 changes: 0 additions & 101 deletions apps/sanity/src/components/Footer/templates/footer.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/sanity/src/components/Footer/templates/index.ts

This file was deleted.

64 changes: 0 additions & 64 deletions apps/sanity/src/components/Header/templates/header.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/sanity/src/components/Header/templates/index.ts

This file was deleted.

19 changes: 9 additions & 10 deletions apps/sanity/src/components/Page/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import {
commonGroups,
themeField,
} from "@/contentSections/commonFields";
// import { sectionsPresets } from "@/contentSections/presets";
import { sectionsPresets } from "@/contentSections/presets";
import { defineBlocksField } from "@focus-reactive/sanity-plugin-cms-kit";
import { definePathname } from "@tinloof/sanity-studio";
import { defineField, defineType, type FieldGroupDefinition } from "sanity";

import sections from "@/lib/schemas/sections";

// import { componentsWithBlocksInput } from "@/lib/templateSelectorInput";

export default defineType({
type: "document",
name: "page",
Expand All @@ -36,17 +35,17 @@ export default defineType({
group: CommonGroup.Content,
validation: (Rule) => Rule.required(),
}),
defineField({
defineBlocksField({
name: "sectionsBody",
title: "Sections",
type: "array",
group: CommonGroup.Content,
// add fields to the package
// title: "Sections",
// group: CommonGroup.Content,
of: sections.map((section) => ({
type: section.name,
})),
// components: componentsWithBlocksInput({
// presets: Object.values(sectionsPresets).flat(),
// }),
options: {
presets: Object.values(sectionsPresets).flat(),
},
}),
defineField({
name: "footer",
Expand Down
32 changes: 16 additions & 16 deletions apps/sanity/src/contentSections/Blog/templates/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { createTemplate } from "@/lib/templateSelectorInput/createTemplate";
import type { Preset } from "@focus-reactive/sanity-plugin-cms-kit";

import withImage from "./with-images.json";
import withoutImage from "./without-images.json";
// import { createTemplate } from "@/lib/utils";

export const blogTemplates = [
createTemplate({
json: withImage,
title: "Blog section with images",
description: "desc1",
category: "blog",
}),
createTemplate({
json: withoutImage,
title: "Blog section without images",
description: "desc2",
category: "blog",
}),
// import withImage from "./with-images.json";
// import withoutImage from "./without-images.json";

export const blogTemplates: Preset[] = [
// createTemplate({
// title: "Blog section with images",
// json: withImage,
// category: "blog",
// }),
// createTemplate({
// title: "Blog section without images",
// json: withoutImage,
// category: "blog",
// }),
];
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd1aa23

Please sign in to comment.