bsmnt 0.4.3 → 0.5.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 (187) hide show
  1. package/dist/application/add-integration/index.d.ts +24 -6
  2. package/dist/application/add-integration/index.d.ts.map +1 -1
  3. package/dist/application/add-integration/index.js +130 -82
  4. package/dist/application/add-integration/index.js.map +1 -1
  5. package/dist/application/create-project/map-selection-to-registry.js +1 -1
  6. package/dist/application/create-project/map-selection-to-registry.js.map +1 -1
  7. package/dist/application/shared/project-detection.d.ts +2 -2
  8. package/dist/application/shared/project-detection.d.ts.map +1 -1
  9. package/dist/application/shared/project-detection.js +2 -2
  10. package/dist/application/shared/project-detection.js.map +1 -1
  11. package/dist/core/create/internal-ids.d.ts +4 -1
  12. package/dist/core/create/internal-ids.d.ts.map +1 -1
  13. package/dist/core/create/internal-ids.js +6 -1
  14. package/dist/core/create/internal-ids.js.map +1 -1
  15. package/dist/domain/cms.d.ts +0 -7
  16. package/dist/domain/cms.d.ts.map +1 -1
  17. package/dist/domain/cms.js.map +1 -1
  18. package/dist/domain/forms.d.ts +17 -0
  19. package/dist/domain/forms.d.ts.map +1 -0
  20. package/dist/domain/forms.js +13 -0
  21. package/dist/domain/forms.js.map +1 -0
  22. package/dist/domain/integration.d.ts +30 -0
  23. package/dist/domain/integration.d.ts.map +1 -0
  24. package/dist/domain/integration.js +12 -0
  25. package/dist/domain/integration.js.map +1 -0
  26. package/dist/domain/skills.d.ts +32 -0
  27. package/dist/domain/skills.d.ts.map +1 -1
  28. package/dist/domain/skills.js +39 -0
  29. package/dist/domain/skills.js.map +1 -1
  30. package/dist/index.js +95 -37
  31. package/dist/index.js.map +1 -1
  32. package/dist/infrastructure/agents/register-sanity-mcp.js +9 -6
  33. package/dist/infrastructure/agents/register-sanity-mcp.js.map +1 -1
  34. package/dist/infrastructure/create/apply-package-json.d.ts.map +1 -1
  35. package/dist/infrastructure/create/apply-package-json.js +19 -0
  36. package/dist/infrastructure/create/apply-package-json.js.map +1 -1
  37. package/dist/infrastructure/create/install-dependencies.d.ts.map +1 -1
  38. package/dist/infrastructure/create/install-dependencies.js +4 -0
  39. package/dist/infrastructure/create/install-dependencies.js.map +1 -1
  40. package/dist/infrastructure/create/merge-registry.d.ts.map +1 -1
  41. package/dist/infrastructure/create/merge-registry.js +8 -0
  42. package/dist/infrastructure/create/merge-registry.js.map +1 -1
  43. package/dist/infrastructure/create/setup-agent.d.ts.map +1 -1
  44. package/dist/infrastructure/create/setup-agent.js +29 -6
  45. package/dist/infrastructure/create/setup-agent.js.map +1 -1
  46. package/dist/infrastructure/create/setup-sanity.d.ts.map +1 -1
  47. package/dist/infrastructure/create/setup-sanity.js +3 -0
  48. package/dist/infrastructure/create/setup-sanity.js.map +1 -1
  49. package/dist/infrastructure/integrations/inject-integration.d.ts +3 -3
  50. package/dist/infrastructure/integrations/inject-integration.d.ts.map +1 -1
  51. package/dist/infrastructure/integrations/inject-integration.js +81 -37
  52. package/dist/infrastructure/integrations/inject-integration.js.map +1 -1
  53. package/dist/modules/features/cms/sanity/config.d.ts.map +1 -1
  54. package/dist/modules/features/cms/sanity/config.js +11 -5
  55. package/dist/modules/features/cms/sanity/config.js.map +1 -1
  56. package/dist/modules/features/cms/sanity/index.js +8 -2
  57. package/dist/modules/features/cms/sanity/index.js.map +1 -1
  58. package/dist/modules/features/cms/sanity/mergers/ci-workflow.d.ts +13 -0
  59. package/dist/modules/features/cms/sanity/mergers/ci-workflow.d.ts.map +1 -0
  60. package/dist/modules/features/cms/sanity/mergers/ci-workflow.js +38 -0
  61. package/dist/modules/features/cms/sanity/mergers/ci-workflow.js.map +1 -0
  62. package/dist/modules/features/cms/sanity/mergers/knip.d.ts +12 -0
  63. package/dist/modules/features/cms/sanity/mergers/knip.d.ts.map +1 -0
  64. package/dist/modules/features/cms/sanity/mergers/knip.js +38 -0
  65. package/dist/modules/features/cms/sanity/mergers/knip.js.map +1 -0
  66. package/dist/modules/features/cms/sanity/mergers/layout.d.ts.map +1 -1
  67. package/dist/modules/features/cms/sanity/mergers/layout.js +7 -3
  68. package/dist/modules/features/cms/sanity/mergers/layout.js.map +1 -1
  69. package/dist/modules/features/cms/sanity/mergers/sitemap.d.ts +3 -3
  70. package/dist/modules/features/cms/sanity/mergers/sitemap.d.ts.map +1 -1
  71. package/dist/modules/features/cms/sanity/mergers/sitemap.js +48 -62
  72. package/dist/modules/features/cms/sanity/mergers/sitemap.js.map +1 -1
  73. package/dist/modules/features/cms/sanity-pagebuilder/config.d.ts.map +1 -1
  74. package/dist/modules/features/cms/sanity-pagebuilder/config.js +8 -5
  75. package/dist/modules/features/cms/sanity-pagebuilder/config.js.map +1 -1
  76. package/dist/modules/features/cms/sanity-pagebuilder/index.js +2 -2
  77. package/dist/modules/features/cms/sanity-pagebuilder/index.js.map +1 -1
  78. package/dist/modules/features/forms/hubspot/config.d.ts +31 -0
  79. package/dist/modules/features/forms/hubspot/config.d.ts.map +1 -0
  80. package/dist/modules/features/forms/hubspot/config.js +25 -0
  81. package/dist/modules/features/forms/hubspot/config.js.map +1 -0
  82. package/dist/paths.d.ts +8 -0
  83. package/dist/paths.d.ts.map +1 -1
  84. package/dist/paths.js +8 -0
  85. package/dist/paths.js.map +1 -1
  86. package/package.json +17 -9
  87. package/src/assets/check-node-version.mjs +22 -0
  88. package/src/modules/features/cms/sanity/files/app/blog/page.tsx +54 -0
  89. package/src/modules/features/cms/sanity/files/app/feed.xml/route.ts +36 -0
  90. package/src/modules/features/cms/sanity/files/lib/integrations/sanity/components/disable-draft-mode.tsx +3 -3
  91. package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/article.ts +7 -7
  92. package/src/modules/features/cms/sanity/files/lib/scripts/setup-ci-secrets.ts +117 -0
  93. package/src/modules/features/cms/sanity/files/lib/utils/rss.ts +96 -0
  94. package/src/modules/features/cms/sanity-pagebuilder/files/.knip.json +8 -0
  95. package/src/modules/features/cms/sanity-pagebuilder/files/app/api/[[...slug]]/route.ts +100 -0
  96. package/src/modules/features/cms/sanity-pagebuilder/files/app/api/draft-mode/disable/route.ts +7 -0
  97. package/src/modules/features/cms/sanity-pagebuilder/files/app/api/draft-mode/enable/route.ts +20 -0
  98. package/src/modules/features/cms/sanity-pagebuilder/files/app/api/revalidate/route.ts +126 -0
  99. package/src/modules/features/cms/sanity-pagebuilder/files/app/feed.xml/route.ts +40 -0
  100. package/src/modules/features/cms/sanity-pagebuilder/files/app/sitemap.md/route.ts +124 -0
  101. package/src/modules/features/cms/sanity-pagebuilder/files/app/studio/[[...tool]]/page.tsx +8 -0
  102. package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/draft-mode-toggle.tsx +27 -0
  103. package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/rich-text.tsx +87 -0
  104. package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/visual-editing.tsx +28 -0
  105. package/src/modules/features/cms/sanity-pagebuilder/files/components/ui/sanity-image/index.tsx +41 -0
  106. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/check-integration.ts +5 -0
  107. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/client.ts +27 -0
  108. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/disable-draft-mode.tsx +23 -0
  109. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/page-builder-input.tsx +39 -0
  110. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/page-category-input.tsx +50 -0
  111. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/slug-field.tsx +18 -0
  112. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/slug-input.tsx +14 -0
  113. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/confirm-publish-action.ts +40 -0
  114. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/env.ts +34 -0
  115. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/fetchers/layout.ts +48 -0
  116. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/fetchers/redirects.ts +17 -0
  117. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/icons.ts +62 -0
  118. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/live/index.tsx +88 -0
  119. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/markdown-proxy.config.ts +50 -0
  120. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-builder-config.ts +130 -0
  121. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-category.ts +28 -0
  122. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-tree-pane.tsx +420 -0
  123. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/pinned-pages.ts +54 -0
  124. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/presentation.ts +119 -0
  125. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/queries.ts +385 -0
  126. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/sanity.cli.ts +29 -0
  127. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/sanity.config.ts +113 -0
  128. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/index.ts +4 -0
  129. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/blog-content.ts +89 -0
  130. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/description.ts +29 -0
  131. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/hero.ts +28 -0
  132. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/singleton/content-collection.ts +45 -0
  133. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/content/author.ts +70 -0
  134. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/content/blog-category.ts +55 -0
  135. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/index.ts +96 -0
  136. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/company-data.ts +62 -0
  137. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/footer.ts +79 -0
  138. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/navbar.ts +75 -0
  139. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/redirect.ts +120 -0
  140. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/link.ts +125 -0
  141. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/logo-field.ts +9 -0
  142. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/metadata.ts +68 -0
  143. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/nav-objects.ts +192 -0
  144. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page-builder.ts +39 -0
  145. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page-folder.ts +124 -0
  146. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page.ts +242 -0
  147. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/richText.ts +63 -0
  148. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/singletons.ts +39 -0
  149. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/structure.ts +330 -0
  150. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/image.ts +8 -0
  151. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/link.ts +140 -0
  152. package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/page-builder-markdown.ts +81 -0
  153. package/src/modules/features/cms/sanity-pagebuilder/files/lib/scripts/sanity-typegen.ts +45 -0
  154. package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/check-redirect.ts +30 -0
  155. package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/json-ld.tsx +212 -0
  156. package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/metadata.ts +167 -0
  157. package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/rss.ts +96 -0
  158. package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/sitemap.ts +40 -0
  159. package/src/modules/features/cms/sanity-pagebuilder/files/proxy.ts +81 -0
  160. package/src/templates/next-default/.github/workflows/ci.yml +62 -0
  161. package/src/templates/next-default/README.md +22 -0
  162. package/src/templates/next-default/knip.json +14 -0
  163. package/src/templates/next-default/lefthook.yml +5 -0
  164. package/src/templates/next-default/package.json +8 -4
  165. package/src/templates/next-experiments/.github/workflows/ci.yml +62 -0
  166. package/src/templates/next-experiments/README.md +22 -0
  167. package/src/templates/next-experiments/knip.json +14 -0
  168. package/src/templates/next-experiments/lefthook.yml +30 -0
  169. package/src/templates/next-experiments/package.json +10 -2
  170. package/src/templates/next-pagebuilder/.github/workflows/ci.yml +70 -0
  171. package/src/templates/next-pagebuilder/README.md +34 -0
  172. package/src/templates/next-pagebuilder/app/(content)/[[...slug]]/page.tsx +6 -1
  173. package/src/templates/next-pagebuilder/app/(content)/layout.tsx +3 -12
  174. package/src/templates/next-pagebuilder/components/layout/footer/index.tsx +11 -10
  175. package/src/templates/next-pagebuilder/components/layout/header/index.tsx +5 -3
  176. package/src/templates/next-pagebuilder/components/layout/json-ld/index.tsx +9 -10
  177. package/src/templates/next-pagebuilder/components/layout/wrapper/index.tsx +3 -11
  178. package/src/templates/next-pagebuilder/components/page-builder/components/content-collection/index.tsx +1 -1
  179. package/src/templates/next-pagebuilder/knip.json +27 -0
  180. package/src/templates/next-pagebuilder/lefthook.yml +5 -0
  181. package/src/templates/next-pagebuilder/lib/scripts/setup-ci-secrets.ts +117 -0
  182. package/src/templates/next-pagebuilder/package.json +9 -3
  183. package/src/templates/next-webgl/.github/workflows/ci.yml +62 -0
  184. package/src/templates/next-webgl/README.md +22 -0
  185. package/src/templates/next-webgl/knip.json +13 -0
  186. package/src/templates/next-webgl/lefthook.yml +5 -0
  187. package/src/templates/next-webgl/package.json +8 -4
@@ -0,0 +1,62 @@
1
+ import type { Icon, IconProps } from "@phosphor-icons/react";
2
+ import {
3
+ ArrowBendUpRightIcon,
4
+ ArticleNyTimesIcon,
5
+ BrowsersIcon,
6
+ BuildingsIcon,
7
+ FileTextIcon,
8
+ FolderOpenIcon,
9
+ FootprintsIcon,
10
+ LayoutIcon,
11
+ ListBulletsIcon,
12
+ ListIcon,
13
+ PackageIcon,
14
+ PushPinIcon,
15
+ RocketIcon,
16
+ ShapesIcon,
17
+ ShareNetworkIcon,
18
+ TagIcon,
19
+ TextAlignLeftIcon,
20
+ UserCircleIcon,
21
+ } from "@phosphor-icons/react/dist/ssr";
22
+ import { createElement, forwardRef } from "react";
23
+
24
+ export type SanityStudioIcon = Icon;
25
+
26
+ const asDuotoneIcon = (IconComponent: Icon): SanityStudioIcon => {
27
+ const DuotoneIcon = forwardRef<SVGSVGElement, IconProps>((props, ref) =>
28
+ createElement(IconComponent, { ...props, ref, weight: "duotone" }),
29
+ );
30
+
31
+ DuotoneIcon.displayName = `${IconComponent.displayName ?? "Phosphor"}Duotone`;
32
+
33
+ return DuotoneIcon;
34
+ };
35
+
36
+ export const pageBuilderCardIcon = asDuotoneIcon(PackageIcon);
37
+ export const pageBuilderCardListIcon = asDuotoneIcon(ListIcon);
38
+
39
+ export const authorIcon = asDuotoneIcon(UserCircleIcon);
40
+
41
+ export const pageListIcon = asDuotoneIcon(ListBulletsIcon);
42
+
43
+ export const blogCategoryIcon = asDuotoneIcon(TagIcon);
44
+
45
+ export const componentsFolderIcon = asDuotoneIcon(ShapesIcon);
46
+
47
+ export const companyDataIcon = asDuotoneIcon(BuildingsIcon);
48
+ export const socialLinksIcon = asDuotoneIcon(ShareNetworkIcon);
49
+ export const navbarIcon = asDuotoneIcon(ListIcon);
50
+ export const footerIcon = asDuotoneIcon(FootprintsIcon);
51
+ export const redirectIcon = asDuotoneIcon(ArrowBendUpRightIcon);
52
+ export const layoutFolderIcon = asDuotoneIcon(LayoutIcon);
53
+
54
+ export const heroIcon = asDuotoneIcon(RocketIcon);
55
+ export const descriptionIcon = asDuotoneIcon(TextAlignLeftIcon);
56
+ export const contentIcon = asDuotoneIcon(ArticleNyTimesIcon);
57
+
58
+ export const pageIcon = asDuotoneIcon(FileTextIcon);
59
+ export const pinIcon = asDuotoneIcon(PushPinIcon);
60
+ export const pagesFolderIcon = asDuotoneIcon(BrowsersIcon);
61
+ export const pageFolderIcon = asDuotoneIcon(FolderOpenIcon);
62
+ export const contentFolderIcon = asDuotoneIcon(FolderOpenIcon);
@@ -0,0 +1,88 @@
1
+ import { NextResponse } from "next/server";
2
+ import type { QueryParams } from "next-sanity";
3
+ import { defineLive } from "next-sanity/live";
4
+ import { isSanityConfigured } from "@/lib/integrations/check-integration";
5
+ import { client } from "../client";
6
+ import { sanityToken } from "../env";
7
+
8
+ const isConfigured = isSanityConfigured() && client;
9
+
10
+ const liveExports =
11
+ isConfigured && client
12
+ ? defineLive({
13
+ client,
14
+ browserToken: sanityToken ?? false,
15
+ serverToken: sanityToken ?? false,
16
+ })
17
+ : null;
18
+
19
+ export const sanityFetch =
20
+ liveExports?.sanityFetch ?? (async () => ({ data: null }));
21
+
22
+ export const SanityLive = liveExports?.SanityLive ?? (() => null);
23
+
24
+ type SanityFetchOptions = {
25
+ query: string;
26
+ params?: QueryParams;
27
+ tags?: string[];
28
+ stega?: boolean;
29
+ perspective?: "published" | "drafts" | "previewDrafts";
30
+ };
31
+
32
+ export async function fetchSanity<T = unknown>({
33
+ query,
34
+ params = {},
35
+ tags = [],
36
+ stega,
37
+ perspective,
38
+ }: SanityFetchOptions): Promise<{ data: T | null }> {
39
+ const { data } = await sanityFetch({
40
+ query,
41
+ params,
42
+ tags,
43
+ ...(typeof stega === "boolean" ? { stega } : {}),
44
+ ...(perspective ? { perspective } : {}),
45
+ });
46
+
47
+ return { data: (data as T | null) ?? null };
48
+ }
49
+
50
+ export const SanityFetch = async <T,>(
51
+ slug: string,
52
+ query: string,
53
+ label = "Content",
54
+ ): Promise<T | NextResponse> => {
55
+ if (!client) {
56
+ return new NextResponse(`# 503 Unavailable\n\nCMS client unavailable.`, {
57
+ status: 503,
58
+ headers: { "Content-Type": "text/markdown; charset=utf-8" },
59
+ });
60
+ }
61
+
62
+ try {
63
+ const { data } = await sanityFetch({
64
+ query,
65
+ params: { slug },
66
+ });
67
+
68
+ const result = data as T | null;
69
+
70
+ if (!result) {
71
+ return new NextResponse(`# 404 Not Found\n\nPage not found.`, {
72
+ status: 404,
73
+ headers: { "Content-Type": "text/markdown; charset=utf-8" },
74
+ });
75
+ }
76
+
77
+ return result;
78
+ } catch (error) {
79
+ console.error(`Error fetching ${label.toLowerCase()}:`, error);
80
+ return new NextResponse(
81
+ `# 500 Error\n\nFailed to fetch ${label.toLowerCase()}.`,
82
+ {
83
+ status: 500,
84
+ headers: { "Content-Type": "text/markdown; charset=utf-8" },
85
+ },
86
+ );
87
+ }
88
+ };
@@ -0,0 +1,50 @@
1
+ export interface MarkdownRoute {
2
+ /** Regex to match the public-facing URL */
3
+ regex: RegExp;
4
+ /** API route path template (under /api/) */
5
+ apiPath: string;
6
+ /** Public markdown URL template (for Link headers) */
7
+ publicPath: string;
8
+ }
9
+
10
+ /**
11
+ * Routes that serve markdown versions for AI agents.
12
+ * All pages are backed by the shared `page` document type and resolved
13
+ * through the catch-all route handlers.
14
+ *
15
+ * How it works:
16
+ * - `regex`: match the public-facing URL (e.g. /about.md or /about)
17
+ * - `apiPath`: the internal API route that serves the markdown (e.g. /api/about.md)
18
+ * - Proxy rewrites .md URLs and Accept: text/markdown requests to the API route
19
+ * - Route handlers live under /api/ so page.tsx can coexist at the public path
20
+ */
21
+
22
+ /** .md extension routes -- rewrite to API endpoints */
23
+ export const mdExtensionRoutes: MarkdownRoute[] = [
24
+ {
25
+ regex: /^\/(.+)\.md$/,
26
+ apiPath: "/api/[slug].md",
27
+ publicPath: "/[slug].md",
28
+ },
29
+ ];
30
+
31
+ /** Accept: text/markdown routes -- content negotiation for HTML pages */
32
+ export const acceptHeaderRoutes: MarkdownRoute[] = [
33
+ {
34
+ regex: /^\/(.+)$/,
35
+ apiPath: "/api/[slug].md",
36
+ publicPath: "/[slug].md",
37
+ },
38
+ ];
39
+
40
+ /**
41
+ * Paths the proxy should never process.
42
+ * Studio, static files, Next.js internals.
43
+ */
44
+ export const ignoredPaths = [
45
+ "/studio",
46
+ "/api/",
47
+ "/_next/",
48
+ "/favicon.ico",
49
+ "/sitemap.md",
50
+ ];
@@ -0,0 +1,130 @@
1
+ import { contentIcon, pageIcon, type SanityStudioIcon } from "./icons";
2
+ import { singletonComponents } from "./singletons";
3
+
4
+ export type PageBuilderDocumentType =
5
+ | "hero"
6
+ | "description"
7
+ | "blogContent"
8
+ | (typeof singletonComponents)[number]["schemaType"];
9
+
10
+ type PageBuilderReferenceMember = {
11
+ documentType: PageBuilderDocumentType;
12
+ name: string;
13
+ title: string;
14
+ documentId?: string;
15
+ groups: PageBuilderGroupName[];
16
+ };
17
+
18
+ export type PageBuilderGroupName = "generic" | "blogEntry";
19
+
20
+ export const pageBuilderPageTypes: Array<{
21
+ title: string;
22
+ value: PageBuilderGroupName;
23
+ }> = [
24
+ { title: "Generic", value: "generic" },
25
+ { title: "Blog Entry", value: "blogEntry" },
26
+ ];
27
+
28
+ const pageCategoryIcons: Record<PageBuilderGroupName, SanityStudioIcon> = {
29
+ generic: pageIcon,
30
+ blogEntry: contentIcon,
31
+ };
32
+
33
+ export const getPageCategoryIcon = (
34
+ pageType: PageBuilderGroupName | undefined | null,
35
+ ) => pageCategoryIcons[pageType ?? "generic"];
36
+
37
+ const reusablePageBuilderReferenceMembers: PageBuilderReferenceMember[] = [
38
+ {
39
+ documentType: "hero",
40
+ name: "heroReference",
41
+ title: "Heading",
42
+ groups: ["generic"],
43
+ },
44
+ {
45
+ documentType: "description",
46
+ name: "descriptionReference",
47
+ title: "Description",
48
+ groups: ["generic"],
49
+ },
50
+ {
51
+ documentType: "blogContent",
52
+ name: "blogContentReference",
53
+ title: "Blog Content",
54
+ groups: ["blogEntry"],
55
+ },
56
+ ];
57
+
58
+ const singletonPageBuilderReferenceMembers: PageBuilderReferenceMember[] =
59
+ singletonComponents.map((component) => ({
60
+ documentType: component.schemaType,
61
+ name: `${component.schemaType}Reference`,
62
+ title: component.title,
63
+ documentId: component.documentId,
64
+ groups: ["generic"],
65
+ }));
66
+
67
+ export const pageBuilderReferenceMembers: PageBuilderReferenceMember[] = [
68
+ ...reusablePageBuilderReferenceMembers,
69
+ ...singletonPageBuilderReferenceMembers,
70
+ ];
71
+
72
+ export const getPageBuilderReferenceMember = (name: string) =>
73
+ pageBuilderReferenceMembers.find((member) => member.name === name);
74
+
75
+ export const getPageBuilderReferenceMemberByDocumentType = (
76
+ documentType: PageBuilderDocumentType,
77
+ ) =>
78
+ pageBuilderReferenceMembers.find(
79
+ (member) => member.documentType === documentType,
80
+ );
81
+
82
+ const isPageBuilderGroupVisible = (
83
+ pageType: PageBuilderGroupName | undefined,
84
+ group: PageBuilderGroupName,
85
+ ) => (pageType ?? "generic") === group;
86
+
87
+ export const getVisiblePageBuilderReferenceMembers = (
88
+ pageType: PageBuilderGroupName | undefined,
89
+ ) =>
90
+ pageBuilderReferenceMembers.filter((member) =>
91
+ member.groups.some((group) => isPageBuilderGroupVisible(pageType, group)),
92
+ );
93
+
94
+ export const getVisiblePageBuilderInsertMenuGroups = (
95
+ pageType: PageBuilderGroupName | undefined,
96
+ ) =>
97
+ pageBuilderInsertMenuGroups.filter(
98
+ (group) => group.name === (pageType ?? "generic"),
99
+ );
100
+
101
+ export const getInvalidPageBuilderDocumentTypes = (
102
+ pageType: PageBuilderGroupName | undefined,
103
+ documentTypes: PageBuilderDocumentType[],
104
+ ) =>
105
+ documentTypes.filter((documentType) => {
106
+ const member = getPageBuilderReferenceMemberByDocumentType(documentType);
107
+
108
+ if (!member) return false;
109
+
110
+ return !member.groups.some((group) =>
111
+ isPageBuilderGroupVisible(pageType, group),
112
+ );
113
+ });
114
+
115
+ export const pageBuilderInsertMenuGroups = [
116
+ {
117
+ name: "generic",
118
+ title: "Generic",
119
+ of: pageBuilderReferenceMembers
120
+ .filter((member) => member.groups.includes("generic"))
121
+ .map((member) => member.name),
122
+ },
123
+ {
124
+ name: "blogEntry",
125
+ title: "Blog Entry",
126
+ of: pageBuilderReferenceMembers
127
+ .filter((member) => member.groups.includes("blogEntry"))
128
+ .map((member) => member.name),
129
+ },
130
+ ];
@@ -0,0 +1,28 @@
1
+ import type { PageBuilderGroupName } from "@/lib/integrations/sanity/page-builder-config";
2
+
3
+ type PageCategoryParams = {
4
+ slug?: string | null;
5
+ folder?: string | null;
6
+ };
7
+
8
+ export const isEmptyPageSlug = (slug?: string | null) =>
9
+ slug == null || slug === "" || slug === "/";
10
+
11
+ export const getGeneratedPageCategory = ({
12
+ slug,
13
+ folder,
14
+ }: PageCategoryParams): PageBuilderGroupName => {
15
+ if (!isEmptyPageSlug(slug) && folder === "blog") return "blogEntry";
16
+
17
+ return "generic";
18
+ };
19
+
20
+ export const pageCategoryExpression = `
21
+ select(
22
+ defined(slug.current) &&
23
+ slug.current != "" &&
24
+ slug.current != "/" &&
25
+ pageFolder->slug.current == "blog" => "blogEntry",
26
+ "generic"
27
+ )
28
+ `;