bsmnt 0.2.11 → 0.3.0

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.
Files changed (115) hide show
  1. package/dist/helpers/create/copy-template.d.ts +1 -1
  2. package/dist/helpers/create/copy-template.d.ts.map +1 -1
  3. package/dist/helpers/create/index.d.ts.map +1 -1
  4. package/dist/helpers/create/index.js +2 -1
  5. package/dist/helpers/create/index.js.map +1 -1
  6. package/dist/helpers/integrate/merge-config.d.ts.map +1 -1
  7. package/dist/helpers/integrate/merge-config.js +0 -2
  8. package/dist/helpers/integrate/merge-config.js.map +1 -1
  9. package/dist/helpers/integrate/sanity/config.d.ts.map +1 -1
  10. package/dist/helpers/integrate/sanity/config.js +3 -14
  11. package/dist/helpers/integrate/sanity/config.js.map +1 -1
  12. package/dist/index.js +84 -35
  13. package/dist/index.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/templates/next-pagebuilder/.env.example +11 -0
  16. package/src/templates/next-pagebuilder/README.md +23 -0
  17. package/src/templates/next-pagebuilder/_gitignore +67 -0
  18. package/src/templates/next-pagebuilder/app/(content)/[[...slug]]/page.tsx +68 -0
  19. package/src/templates/next-pagebuilder/app/(content)/layout.tsx +13 -0
  20. package/src/templates/next-pagebuilder/app/api/[[...slug]]/route.ts +100 -0
  21. package/src/templates/next-pagebuilder/app/api/draft-mode/disable/route.ts +7 -0
  22. package/src/templates/next-pagebuilder/app/api/draft-mode/enable/route.ts +20 -0
  23. package/src/templates/next-pagebuilder/app/api/revalidate/route.ts +121 -0
  24. package/src/templates/next-pagebuilder/app/favicon.ico +0 -0
  25. package/src/templates/next-pagebuilder/app/layout.tsx +80 -0
  26. package/src/templates/next-pagebuilder/app/robots.ts +15 -0
  27. package/src/templates/next-pagebuilder/app/sitemap.md/route.ts +124 -0
  28. package/src/templates/next-pagebuilder/app/sitemap.xml/route.ts +80 -0
  29. package/src/templates/next-pagebuilder/app/studio/[[...tool]]/page.tsx +8 -0
  30. package/src/templates/next-pagebuilder/biome.json +239 -0
  31. package/src/templates/next-pagebuilder/components/layout/footer/index.tsx +95 -0
  32. package/src/templates/next-pagebuilder/components/layout/header/components/cta-button.tsx +28 -0
  33. package/src/templates/next-pagebuilder/components/layout/header/components/mega-menu-panel.tsx +90 -0
  34. package/src/templates/next-pagebuilder/components/layout/header/components/nav-item-renderer.tsx +98 -0
  35. package/src/templates/next-pagebuilder/components/layout/header/components/nav-leaf-item.tsx +33 -0
  36. package/src/templates/next-pagebuilder/components/layout/header/components/types.ts +7 -0
  37. package/src/templates/next-pagebuilder/components/layout/header/header-client.tsx +110 -0
  38. package/src/templates/next-pagebuilder/components/layout/header/index.tsx +8 -0
  39. package/src/templates/next-pagebuilder/components/layout/json-ld/index.tsx +45 -0
  40. package/src/templates/next-pagebuilder/components/layout/wrapper/index.tsx +30 -0
  41. package/src/templates/next-pagebuilder/components/page-builder/components/article-content/index.tsx +83 -0
  42. package/src/templates/next-pagebuilder/components/page-builder/components/article-content/related-post-item.tsx +27 -0
  43. package/src/templates/next-pagebuilder/components/page-builder/components/description.tsx +17 -0
  44. package/src/templates/next-pagebuilder/components/page-builder/components/hero.tsx +17 -0
  45. package/src/templates/next-pagebuilder/components/page-builder/components/post-collection/content-card.tsx +66 -0
  46. package/src/templates/next-pagebuilder/components/page-builder/components/post-collection/content-grid.tsx +42 -0
  47. package/src/templates/next-pagebuilder/components/page-builder/components/post-collection/index.tsx +28 -0
  48. package/src/templates/next-pagebuilder/components/page-builder/components/post-collection/types.ts +16 -0
  49. package/src/templates/next-pagebuilder/components/page-builder/renderer.tsx +36 -0
  50. package/src/templates/next-pagebuilder/components/page-builder/types.ts +23 -0
  51. package/src/templates/next-pagebuilder/components/page-document/index.tsx +91 -0
  52. package/src/templates/next-pagebuilder/components/sanity/draft-mode-toggle.tsx +27 -0
  53. package/src/templates/next-pagebuilder/components/sanity/rich-text.tsx +87 -0
  54. package/src/templates/next-pagebuilder/components/sanity/visual-editing.tsx +27 -0
  55. package/src/templates/next-pagebuilder/components/ui/image/index.tsx +216 -0
  56. package/src/templates/next-pagebuilder/components/ui/link/index.tsx +152 -0
  57. package/src/templates/next-pagebuilder/components/ui/sanity-image/index.tsx +41 -0
  58. package/src/templates/next-pagebuilder/lib/integrations/check-integration.ts +5 -0
  59. package/src/templates/next-pagebuilder/lib/integrations/sanity/client.ts +27 -0
  60. package/src/templates/next-pagebuilder/lib/integrations/sanity/components/disable-draft-mode.tsx +23 -0
  61. package/src/templates/next-pagebuilder/lib/integrations/sanity/components/page-builder-input.tsx +36 -0
  62. package/src/templates/next-pagebuilder/lib/integrations/sanity/components/page-category-input.tsx +50 -0
  63. package/src/templates/next-pagebuilder/lib/integrations/sanity/components/rich-text.tsx +84 -0
  64. package/src/templates/next-pagebuilder/lib/integrations/sanity/confirm-publish-action.ts +40 -0
  65. package/src/templates/next-pagebuilder/lib/integrations/sanity/env.ts +34 -0
  66. package/src/templates/next-pagebuilder/lib/integrations/sanity/fetchers/layout.ts +35 -0
  67. package/src/templates/next-pagebuilder/lib/integrations/sanity/icons.ts +58 -0
  68. package/src/templates/next-pagebuilder/lib/integrations/sanity/live/index.tsx +61 -0
  69. package/src/templates/next-pagebuilder/lib/integrations/sanity/markdown-proxy.config.ts +50 -0
  70. package/src/templates/next-pagebuilder/lib/integrations/sanity/page-builder-config.ts +132 -0
  71. package/src/templates/next-pagebuilder/lib/integrations/sanity/page-category.ts +28 -0
  72. package/src/templates/next-pagebuilder/lib/integrations/sanity/queries.ts +281 -0
  73. package/src/templates/next-pagebuilder/lib/integrations/sanity/sanity.cli.ts +29 -0
  74. package/src/templates/next-pagebuilder/lib/integrations/sanity/sanity.config.ts +211 -0
  75. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/components/index.ts +4 -0
  76. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/components/reusable/blog-content.ts +89 -0
  77. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/components/reusable/description.ts +29 -0
  78. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/components/reusable/hero.ts +28 -0
  79. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/components/singleton/content-collection.ts +45 -0
  80. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/content/author.ts +70 -0
  81. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/content/blog-category.ts +55 -0
  82. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/index.ts +96 -0
  83. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/layout/company-data.ts +62 -0
  84. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/layout/footer.ts +79 -0
  85. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/layout/navbar.ts +74 -0
  86. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/link.ts +125 -0
  87. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/logo-field.ts +9 -0
  88. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/metadata.ts +68 -0
  89. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/nav-objects.ts +192 -0
  90. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/page-builder.ts +39 -0
  91. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/page-folder.ts +124 -0
  92. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/page.ts +232 -0
  93. package/src/templates/next-pagebuilder/lib/integrations/sanity/schemas/shared/richText.ts +63 -0
  94. package/src/templates/next-pagebuilder/lib/integrations/sanity/singletons.ts +44 -0
  95. package/src/templates/next-pagebuilder/lib/integrations/sanity/structure.ts +453 -0
  96. package/src/templates/next-pagebuilder/lib/integrations/sanity/utils/image.ts +8 -0
  97. package/src/templates/next-pagebuilder/lib/integrations/sanity/utils/link.ts +137 -0
  98. package/src/templates/next-pagebuilder/lib/integrations/sanity/utils/page-builder-markdown.ts +81 -0
  99. package/src/templates/next-pagebuilder/lib/scripts/sanity-typegen.ts +45 -0
  100. package/src/templates/next-pagebuilder/lib/styles/cn.ts +5 -0
  101. package/src/templates/next-pagebuilder/lib/styles/global.css +70 -0
  102. package/src/templates/next-pagebuilder/lib/utils/base-url.ts +17 -0
  103. package/src/templates/next-pagebuilder/lib/utils/format-date.ts +8 -0
  104. package/src/templates/next-pagebuilder/lib/utils/json-ld.tsx +213 -0
  105. package/src/templates/next-pagebuilder/lib/utils/metadata.ts +167 -0
  106. package/src/templates/next-pagebuilder/lib/utils/sitemap.ts +37 -0
  107. package/src/templates/next-pagebuilder/lib/utils/slug-tag.ts +6 -0
  108. package/src/templates/next-pagebuilder/next.config.ts +134 -0
  109. package/src/templates/next-pagebuilder/package.json +71 -0
  110. package/src/templates/next-pagebuilder/postcss.config.mjs +39 -0
  111. package/src/templates/next-pagebuilder/proxy.ts +81 -0
  112. package/src/templates/next-pagebuilder/svg.d.ts +5 -0
  113. package/src/templates/next-pagebuilder/tsconfig.json +38 -0
  114. package/src/helpers/integrate/sanity/files/lib/scripts/copy-sanity-mcp.ts +0 -23
  115. package/src/helpers/integrate/sanity/files/lib/scripts/generate-page.ts +0 -297
@@ -0,0 +1,79 @@
1
+ import { defineField, defineType } from "sanity"
2
+
3
+ export const footer = defineType({
4
+ name: "footer",
5
+ title: "Footer",
6
+ type: "document",
7
+ fields: [
8
+ defineField({
9
+ name: "links",
10
+ title: "Links",
11
+ description: "Navigation columns (e.g. Products, Solutions, Resources)",
12
+ type: "array",
13
+ of: [
14
+ {
15
+ type: "object",
16
+ fields: [
17
+ defineField({
18
+ name: "title",
19
+ title: "Title",
20
+ type: "string",
21
+ validation: (Rule) => Rule.required(),
22
+ }),
23
+ defineField({
24
+ name: "items",
25
+ title: "Items",
26
+ type: "array",
27
+ of: [
28
+ {
29
+ type: "object",
30
+ fields: [
31
+ defineField({
32
+ name: "label",
33
+ title: "Label",
34
+ type: "string",
35
+ validation: (Rule) => Rule.required(),
36
+ }),
37
+ defineField({
38
+ name: "href",
39
+ title: "Path",
40
+ type: "string",
41
+ description: "Relative path (e.g. /products, /about)",
42
+ validation: (Rule) =>
43
+ Rule.required().custom((value) => {
44
+ if (
45
+ typeof value === "string" &&
46
+ !value.startsWith("/")
47
+ ) {
48
+ return "Path must start with /"
49
+ }
50
+ return true
51
+ }),
52
+ }),
53
+ ],
54
+ preview: {
55
+ select: { title: "label", subtitle: "href" },
56
+ },
57
+ },
58
+ ],
59
+ }),
60
+ ],
61
+ preview: {
62
+ select: { title: "title", items: "items" },
63
+ prepare({ title, items }) {
64
+ return {
65
+ title,
66
+ subtitle: `${items?.length ?? 0} items`,
67
+ }
68
+ },
69
+ },
70
+ },
71
+ ],
72
+ }),
73
+ ],
74
+ preview: {
75
+ prepare() {
76
+ return { title: "Footer" }
77
+ },
78
+ },
79
+ })
@@ -0,0 +1,74 @@
1
+ import { defineArrayMember, defineField, defineType } from "sanity"
2
+
3
+ import { logoField } from "@/lib/integrations/sanity/schemas/shared/logo-field"
4
+
5
+ export const navbar = defineType({
6
+ name: "navbar",
7
+ title: "Navbar",
8
+ type: "document",
9
+ fields: [
10
+ logoField,
11
+ defineField({
12
+ name: "navigationItems",
13
+ title: "Navigation Items",
14
+ type: "array",
15
+ of: [defineArrayMember({ type: "navItem" })],
16
+ description: "Top-level navigation items -- direct links or menu triggers",
17
+ }),
18
+ defineField({
19
+ name: "ctaButtons",
20
+ title: "CTA Buttons",
21
+ type: "array",
22
+ of: [
23
+ {
24
+ type: "object",
25
+ fields: [
26
+ defineField({
27
+ name: "label",
28
+ title: "Label",
29
+ type: "string",
30
+ validation: (Rule) => Rule.required(),
31
+ }),
32
+ defineField({
33
+ name: "link",
34
+ title: "Link",
35
+ type: "link",
36
+ validation: (Rule) => Rule.required(),
37
+ }),
38
+ defineField({
39
+ name: "variant",
40
+ title: "Variant",
41
+ type: "string",
42
+ options: {
43
+ list: [
44
+ { title: "Primary", value: "primary" },
45
+ { title: "Secondary", value: "secondary" },
46
+ ],
47
+ },
48
+ initialValue: "primary",
49
+ validation: (Rule) => Rule.required(),
50
+ }),
51
+ ],
52
+ preview: {
53
+ select: {
54
+ title: "label",
55
+ variant: "variant",
56
+ },
57
+ prepare({ title, variant }) {
58
+ return {
59
+ title,
60
+ subtitle: variant || "primary",
61
+ }
62
+ },
63
+ },
64
+ },
65
+ ],
66
+ description: "Action buttons on the right side of the navbar",
67
+ }),
68
+ ],
69
+ preview: {
70
+ prepare() {
71
+ return { title: "Navbar" }
72
+ },
73
+ },
74
+ })
@@ -0,0 +1,125 @@
1
+ import { defineArrayMember, defineField, defineType } from "sanity"
2
+
3
+ /**
4
+ * Page Reference -- internal link to a Sanity page document.
5
+ */
6
+ export const pageReference = defineType({
7
+ name: "pageReference",
8
+ title: "Page",
9
+ type: "object",
10
+ fields: [
11
+ defineField({
12
+ name: "page",
13
+ title: "Page",
14
+ type: "reference",
15
+ to: [{ type: "page" }],
16
+ validation: (Rule) => Rule.required(),
17
+ }),
18
+ defineField({
19
+ name: "openInNewTab",
20
+ title: "Open in New Tab",
21
+ type: "boolean",
22
+ initialValue: false,
23
+ }),
24
+ ],
25
+ preview: {
26
+ select: {
27
+ text: "text",
28
+ pageTitle: "page.title",
29
+ },
30
+ prepare({ text, pageTitle }) {
31
+ return {
32
+ title: text || pageTitle || "Untitled",
33
+ subtitle: pageTitle ? `Page: ${pageTitle}` : "Page Reference",
34
+ }
35
+ },
36
+ },
37
+ })
38
+
39
+ /**
40
+ * External Link -- URL pointing outside the site (or to pages not yet in Sanity).
41
+ */
42
+ export const externalLink = defineType({
43
+ name: "externalLink",
44
+ title: "URL",
45
+ type: "object",
46
+ fields: [
47
+ defineField({
48
+ name: "href",
49
+ title: "URL",
50
+ type: "url",
51
+ validation: (Rule) =>
52
+ Rule.required().uri({
53
+ scheme: ["http", "https", "mailto", "tel"],
54
+ allowRelative: true,
55
+ }),
56
+ }),
57
+ defineField({
58
+ name: "openInNewTab",
59
+ title: "Open in New Tab",
60
+ type: "boolean",
61
+ initialValue: false,
62
+ }),
63
+ ],
64
+ preview: {
65
+ select: {
66
+ text: "text",
67
+ href: "href",
68
+ },
69
+ prepare({ text, href }) {
70
+ return {
71
+ title: text || href || "Untitled",
72
+ subtitle: href ? `URL: ${href}` : "External Link",
73
+ }
74
+ },
75
+ },
76
+ })
77
+
78
+ /**
79
+ * Link -- array-of-one wrapper that accepts either a page reference or external URL.
80
+ * Editors click "Add" and pick which type they need.
81
+ */
82
+ export const link = defineType({
83
+ name: "link",
84
+ title: "Link",
85
+ type: "array",
86
+ of: [
87
+ defineArrayMember({ type: "pageReference" }),
88
+ defineArrayMember({ type: "externalLink" }),
89
+ ],
90
+ validation: (Rule) => Rule.max(1),
91
+ })
92
+
93
+ /**
94
+ * Annotations for Portable Text -- both link types as separate mark annotations.
95
+ */
96
+ export const linkAnnotations = [
97
+ defineArrayMember({ type: "pageReference" }),
98
+ defineArrayMember({ type: "externalLink" }),
99
+ ]
100
+
101
+ // Helper field exports for easy reuse
102
+ export const linkField = defineField({
103
+ name: "link",
104
+ title: "Link",
105
+ type: "link",
106
+ })
107
+
108
+ type LinkFieldOptions = {
109
+ name?: string
110
+ title?: string
111
+ required?: boolean
112
+ }
113
+
114
+ export function extendedLinkField({
115
+ name = "link",
116
+ title = "Link",
117
+ required = false,
118
+ }: LinkFieldOptions = {}) {
119
+ return defineField({
120
+ name,
121
+ title,
122
+ type: "link",
123
+ validation: required ? (Rule) => Rule.required().min(1) : undefined,
124
+ })
125
+ }
@@ -0,0 +1,9 @@
1
+ import { defineField } from "sanity"
2
+
3
+ export const logoField = defineField({
4
+ name: "logo",
5
+ title: "Logo",
6
+ type: "image",
7
+ options: { hotspot: true },
8
+ validation: (Rule) => Rule.required(),
9
+ })
@@ -0,0 +1,68 @@
1
+ import { defineField, defineType } from "sanity"
2
+
3
+ export const metadata = defineType({
4
+ name: "metadata",
5
+ title: "SEO & Metadata",
6
+ type: "object",
7
+ options: {
8
+ collapsible: true,
9
+ collapsed: true,
10
+ },
11
+ fields: [
12
+ defineField({
13
+ name: "metaTitle",
14
+ title: "Meta Title",
15
+ type: "string",
16
+ description: "Title used by search engines",
17
+ validation: (Rule) =>
18
+ Rule.max(60).warning(
19
+ "Title should be under 60 characters for optimal SEO"
20
+ ),
21
+ }),
22
+ defineField({
23
+ name: "metaDescription",
24
+ title: "Meta Description",
25
+ type: "text",
26
+ rows: 3,
27
+ description: "Description used by search engines",
28
+ validation: (Rule) =>
29
+ Rule.max(160).warning(
30
+ "Description should be under 160 characters for optimal SEO"
31
+ ),
32
+ }),
33
+ defineField({
34
+ name: "image",
35
+ title: "OG Image",
36
+ type: "image",
37
+ description: "Image for social sharing previews (1200x630px recommended)",
38
+ options: {
39
+ hotspot: true,
40
+ },
41
+ }),
42
+ defineField({
43
+ name: "index",
44
+ title: "Index",
45
+ type: "boolean",
46
+ description: "Allow search engines to index this page",
47
+ initialValue: true,
48
+ }),
49
+ defineField({
50
+ name: "title",
51
+ title: "Legacy Meta Title",
52
+ type: "string",
53
+ hidden: true,
54
+ }),
55
+ defineField({
56
+ name: "description",
57
+ title: "Legacy Meta Description",
58
+ type: "text",
59
+ hidden: true,
60
+ }),
61
+ defineField({
62
+ name: "noIndex",
63
+ title: "Legacy No Index",
64
+ type: "boolean",
65
+ hidden: true,
66
+ }),
67
+ ],
68
+ })
@@ -0,0 +1,192 @@
1
+ import { defineArrayMember, defineField, defineType } from "sanity"
2
+
3
+ /**
4
+ * Nav Leaf Item
5
+ *
6
+ * Individual navigation link within a menu column.
7
+ */
8
+ export const navLeafItem = defineType({
9
+ name: "navLeafItem",
10
+ title: "Navigation Link",
11
+ type: "object",
12
+ fields: [
13
+ defineField({
14
+ name: "title",
15
+ title: "Title",
16
+ type: "string",
17
+ description: "Display text for the navigation link",
18
+ validation: (Rule) => Rule.required(),
19
+ }),
20
+ defineField({
21
+ name: "link",
22
+ title: "Link",
23
+ type: "link",
24
+ description:
25
+ "Optional -- leave empty for items with pages not yet created",
26
+ }),
27
+ ],
28
+ preview: {
29
+ select: {
30
+ title: "title",
31
+ internalTitle: "link.0.page.title",
32
+ externalHref: "link.0.href",
33
+ },
34
+ prepare({ title, internalTitle, externalHref }) {
35
+ return {
36
+ title: title || "Untitled Link",
37
+ subtitle: internalTitle || externalHref || "",
38
+ }
39
+ },
40
+ },
41
+ })
42
+
43
+ /**
44
+ * Nav Column
45
+ *
46
+ * A column within a mega-menu containing a group of leaf items.
47
+ * Title is optional to support unnamed column groups (e.g. Company's first column).
48
+ * Link is optional -- some column headers are clickable (Products), some are labels only (Solutions).
49
+ */
50
+ export const navColumn = defineType({
51
+ name: "navColumn",
52
+ title: "Menu Column",
53
+ type: "object",
54
+ fields: [
55
+ defineField({
56
+ name: "title",
57
+ title: "Column Title",
58
+ type: "string",
59
+ description:
60
+ "Column header text. Leave empty for unnamed groups (e.g. Company's first column).",
61
+ }),
62
+ defineField({
63
+ name: "link",
64
+ title: "Column Link",
65
+ type: "link",
66
+ description:
67
+ "Optional -- makes the column header clickable (e.g. Products column headers link to section pages)",
68
+ }),
69
+ defineField({
70
+ name: "items",
71
+ title: "Items",
72
+ type: "array",
73
+ of: [defineArrayMember({ type: "navLeafItem" })],
74
+ description: "Navigation links within this column",
75
+ }),
76
+ ],
77
+ preview: {
78
+ select: {
79
+ title: "title",
80
+ items: "items",
81
+ },
82
+ prepare({ title, items }) {
83
+ const itemCount = items?.length ?? 0
84
+ return {
85
+ title: title || "Unnamed Column",
86
+ subtitle: `${itemCount} item${itemCount === 1 ? "" : "s"}`,
87
+ }
88
+ },
89
+ },
90
+ })
91
+
92
+ /**
93
+ * Nav Menu
94
+ *
95
+ * The content of a menu dropdown panel.
96
+ * Contains columns of navigation links.
97
+ */
98
+ export const navMegaMenu = defineType({
99
+ name: "navMegaMenu",
100
+ title: "Menu",
101
+ type: "object",
102
+ fields: [
103
+ defineField({
104
+ name: "columns",
105
+ title: "Columns",
106
+ type: "array",
107
+ of: [defineArrayMember({ type: "navColumn" })],
108
+ validation: (Rule) => Rule.required().min(1),
109
+ description: "Column groups within the menu dropdown",
110
+ }),
111
+ ],
112
+ preview: {
113
+ select: {
114
+ columns: "columns",
115
+ },
116
+ prepare({ columns }) {
117
+ const colCount = columns?.length ?? 0
118
+ return {
119
+ title: "Menu",
120
+ subtitle: `${colCount} column${colCount === 1 ? "" : "s"}`,
121
+ }
122
+ },
123
+ },
124
+ })
125
+
126
+ /**
127
+ * Nav Item
128
+ *
129
+ * A top-level navigation item. Discriminated union:
130
+ * - "link" type: a simple direct navigation link (e.g. Customers, Resources, Pricing)
131
+ * - "mega-menu" type: opens a multi-column dropdown panel (e.g. Products, Solutions, Company)
132
+ */
133
+ export const navItem = defineType({
134
+ name: "navItem",
135
+ title: "Navigation Item",
136
+ type: "object",
137
+ fields: [
138
+ defineField({
139
+ name: "title",
140
+ title: "Title",
141
+ type: "string",
142
+ description: "Display text in the navigation bar",
143
+ validation: (Rule) => Rule.required(),
144
+ }),
145
+ defineField({
146
+ name: "itemType",
147
+ title: "Item Type",
148
+ type: "string",
149
+ options: {
150
+ list: [
151
+ { title: "Direct Link", value: "link" },
152
+ { title: "Menu", value: "mega-menu" },
153
+ ],
154
+ layout: "radio",
155
+ },
156
+ initialValue: "link",
157
+ validation: (Rule) => Rule.required(),
158
+ }),
159
+ defineField({
160
+ name: "link",
161
+ title: "Link",
162
+ type: "link",
163
+ description: "Destination for direct link items",
164
+ hidden: ({ parent }) => parent?.itemType !== "link",
165
+ }),
166
+ defineField({
167
+ name: "megaMenu",
168
+ title: "Menu",
169
+ type: "navMegaMenu",
170
+ description: "Dropdown menu content with columns",
171
+ hidden: ({ parent }) => parent?.itemType !== "mega-menu",
172
+ }),
173
+ ],
174
+ preview: {
175
+ select: {
176
+ title: "title",
177
+ itemType: "itemType",
178
+ columns: "megaMenu.columns",
179
+ },
180
+ prepare({ title, itemType, columns }) {
181
+ const colCount = columns?.length ?? 0
182
+ const subtitle =
183
+ itemType === "mega-menu"
184
+ ? `Menu (${colCount} column${colCount === 1 ? "" : "s"})`
185
+ : "Direct Link"
186
+ return {
187
+ title: title || "Untitled Item",
188
+ subtitle,
189
+ }
190
+ },
191
+ },
192
+ })
@@ -0,0 +1,39 @@
1
+ import { defineArrayMember, defineType } from "sanity"
2
+ import { PageBuilderInput } from "@/lib/integrations/sanity/components/page-builder-input"
3
+ import {
4
+ pageBuilderInsertMenuGroups,
5
+ pageBuilderReferenceMembers,
6
+ } from "@/lib/integrations/sanity/page-builder-config"
7
+
8
+ export const pageBuilder = defineType({
9
+ name: "pageBuilder",
10
+ title: "Page Builder",
11
+ type: "array",
12
+ components: { input: PageBuilderInput },
13
+ options: {
14
+ insertMenu: {
15
+ filter: true,
16
+ groups: pageBuilderInsertMenuGroups,
17
+ },
18
+ },
19
+ of: pageBuilderReferenceMembers.map((member) =>
20
+ defineArrayMember({
21
+ name: member.name,
22
+ title: member.title,
23
+ type: "reference",
24
+ to: [{ type: member.documentType }],
25
+ ...(member.documentId
26
+ ? {
27
+ options: {
28
+ disableNew: true,
29
+ filter: "_id in [$documentId, $draftDocumentId]",
30
+ filterParams: {
31
+ documentId: member.documentId,
32
+ draftDocumentId: `drafts.${member.documentId}`,
33
+ },
34
+ },
35
+ }
36
+ : {}),
37
+ })
38
+ ),
39
+ })