bsmnt 0.4.3 → 0.6.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.
- package/README.md +1 -0
- package/dist/application/add-hooks/index.d.ts.map +1 -1
- package/dist/application/add-hooks/index.js +1 -0
- package/dist/application/add-hooks/index.js.map +1 -1
- package/dist/application/add-integration/index.d.ts +33 -8
- package/dist/application/add-integration/index.d.ts.map +1 -1
- package/dist/application/add-integration/index.js +221 -90
- package/dist/application/add-integration/index.js.map +1 -1
- package/dist/application/create-project/build-context.d.ts +3 -1
- package/dist/application/create-project/build-context.d.ts.map +1 -1
- package/dist/application/create-project/build-context.js +2 -1
- package/dist/application/create-project/build-context.js.map +1 -1
- package/dist/application/create-project/index.d.ts +3 -1
- package/dist/application/create-project/index.d.ts.map +1 -1
- package/dist/application/create-project/index.js +4 -2
- package/dist/application/create-project/index.js.map +1 -1
- package/dist/application/create-project/map-selection-to-registry.js +1 -1
- package/dist/application/create-project/map-selection-to-registry.js.map +1 -1
- package/dist/application/install-skills/index.js +1 -1
- package/dist/application/install-skills/index.js.map +1 -1
- package/dist/application/shared/project-detection.d.ts +2 -2
- package/dist/application/shared/project-detection.d.ts.map +1 -1
- package/dist/application/shared/project-detection.js +2 -2
- package/dist/application/shared/project-detection.js.map +1 -1
- package/dist/core/create/execute-plan.d.ts +4 -0
- package/dist/core/create/execute-plan.d.ts.map +1 -1
- package/dist/core/create/execute-plan.js +8 -0
- package/dist/core/create/execute-plan.js.map +1 -1
- package/dist/core/create/internal-ids.d.ts +4 -1
- package/dist/core/create/internal-ids.d.ts.map +1 -1
- package/dist/core/create/internal-ids.js +6 -1
- package/dist/core/create/internal-ids.js.map +1 -1
- package/dist/core/create/types.d.ts +2 -0
- package/dist/core/create/types.d.ts.map +1 -1
- package/dist/domain/cms.d.ts +0 -7
- package/dist/domain/cms.d.ts.map +1 -1
- package/dist/domain/cms.js.map +1 -1
- package/dist/domain/forms.d.ts +17 -0
- package/dist/domain/forms.d.ts.map +1 -0
- package/dist/domain/forms.js +13 -0
- package/dist/domain/forms.js.map +1 -0
- package/dist/domain/integration.d.ts +30 -0
- package/dist/domain/integration.d.ts.map +1 -0
- package/dist/domain/integration.js +12 -0
- package/dist/domain/integration.js.map +1 -0
- package/dist/domain/skills.d.ts +58 -0
- package/dist/domain/skills.d.ts.map +1 -1
- package/dist/domain/skills.js +52 -0
- package/dist/domain/skills.js.map +1 -1
- package/dist/index.js +114 -38
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/agents/register-sanity-mcp.js +9 -6
- package/dist/infrastructure/agents/register-sanity-mcp.js.map +1 -1
- package/dist/infrastructure/create/apply-package-json.d.ts.map +1 -1
- package/dist/infrastructure/create/apply-package-json.js +19 -0
- package/dist/infrastructure/create/apply-package-json.js.map +1 -1
- package/dist/infrastructure/create/executor.d.ts.map +1 -1
- package/dist/infrastructure/create/executor.js +5 -0
- package/dist/infrastructure/create/executor.js.map +1 -1
- package/dist/infrastructure/create/install-dependencies.d.ts.map +1 -1
- package/dist/infrastructure/create/install-dependencies.js +4 -0
- package/dist/infrastructure/create/install-dependencies.js.map +1 -1
- package/dist/infrastructure/create/lifecycle-registry.d.ts.map +1 -1
- package/dist/infrastructure/create/lifecycle-registry.js +2 -0
- package/dist/infrastructure/create/lifecycle-registry.js.map +1 -1
- package/dist/infrastructure/create/merge-registry.d.ts.map +1 -1
- package/dist/infrastructure/create/merge-registry.js +8 -0
- package/dist/infrastructure/create/merge-registry.js.map +1 -1
- package/dist/infrastructure/create/setup-agent.d.ts +2 -0
- package/dist/infrastructure/create/setup-agent.d.ts.map +1 -1
- package/dist/infrastructure/create/setup-agent.js +32 -8
- package/dist/infrastructure/create/setup-agent.js.map +1 -1
- package/dist/infrastructure/create/setup-dotenvx.d.ts +41 -0
- package/dist/infrastructure/create/setup-dotenvx.d.ts.map +1 -0
- package/dist/infrastructure/create/setup-dotenvx.js +502 -0
- package/dist/infrastructure/create/setup-dotenvx.js.map +1 -0
- package/dist/infrastructure/create/setup-sanity.d.ts +13 -1
- package/dist/infrastructure/create/setup-sanity.d.ts.map +1 -1
- package/dist/infrastructure/create/setup-sanity.js +74 -31
- package/dist/infrastructure/create/setup-sanity.js.map +1 -1
- package/dist/infrastructure/integrations/inject-integration.d.ts +3 -3
- package/dist/infrastructure/integrations/inject-integration.d.ts.map +1 -1
- package/dist/infrastructure/integrations/inject-integration.js +81 -37
- package/dist/infrastructure/integrations/inject-integration.js.map +1 -1
- package/dist/modules/features/cms/sanity/config.d.ts.map +1 -1
- package/dist/modules/features/cms/sanity/config.js +13 -6
- package/dist/modules/features/cms/sanity/config.js.map +1 -1
- package/dist/modules/features/cms/sanity/index.js +8 -2
- package/dist/modules/features/cms/sanity/index.js.map +1 -1
- package/dist/modules/features/cms/sanity/mergers/ci-workflow.d.ts +13 -0
- package/dist/modules/features/cms/sanity/mergers/ci-workflow.d.ts.map +1 -0
- package/dist/modules/features/cms/sanity/mergers/ci-workflow.js +38 -0
- package/dist/modules/features/cms/sanity/mergers/ci-workflow.js.map +1 -0
- package/dist/modules/features/cms/sanity/mergers/knip.d.ts +12 -0
- package/dist/modules/features/cms/sanity/mergers/knip.d.ts.map +1 -0
- package/dist/modules/features/cms/sanity/mergers/knip.js +38 -0
- package/dist/modules/features/cms/sanity/mergers/knip.js.map +1 -0
- package/dist/modules/features/cms/sanity/mergers/layout.d.ts.map +1 -1
- package/dist/modules/features/cms/sanity/mergers/layout.js +17 -3
- package/dist/modules/features/cms/sanity/mergers/layout.js.map +1 -1
- package/dist/modules/features/cms/sanity/mergers/sitemap.d.ts +3 -3
- package/dist/modules/features/cms/sanity/mergers/sitemap.d.ts.map +1 -1
- package/dist/modules/features/cms/sanity/mergers/sitemap.js +48 -62
- package/dist/modules/features/cms/sanity/mergers/sitemap.js.map +1 -1
- package/dist/modules/features/cms/sanity-pagebuilder/config.d.ts.map +1 -1
- package/dist/modules/features/cms/sanity-pagebuilder/config.js +8 -5
- package/dist/modules/features/cms/sanity-pagebuilder/config.js.map +1 -1
- package/dist/modules/features/cms/sanity-pagebuilder/index.js +2 -2
- package/dist/modules/features/cms/sanity-pagebuilder/index.js.map +1 -1
- package/dist/modules/features/env/dotenvx/config.d.ts +13 -0
- package/dist/modules/features/env/dotenvx/config.d.ts.map +1 -0
- package/dist/modules/features/env/dotenvx/config.js +47 -0
- package/dist/modules/features/env/dotenvx/config.js.map +1 -0
- package/dist/modules/features/forms/hubspot/config.d.ts +31 -0
- package/dist/modules/features/forms/hubspot/config.d.ts.map +1 -0
- package/dist/modules/features/forms/hubspot/config.js +25 -0
- package/dist/modules/features/forms/hubspot/config.js.map +1 -0
- package/dist/paths.d.ts +16 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +16 -0
- package/dist/paths.js.map +1 -1
- package/package.json +21 -9
- package/src/agent-skills/json-ld/SKILL.md +85 -0
- package/src/agent-skills/manage-env/SKILL.md +67 -0
- package/src/assets/check-node-version.mjs +22 -0
- package/src/modules/features/cms/sanity/files/app/blog/[slug]/page.tsx +48 -21
- package/src/modules/features/cms/sanity/files/app/blog/page.tsx +54 -0
- package/src/modules/features/cms/sanity/files/app/feed.xml/route.ts +36 -0
- package/src/modules/features/cms/sanity/files/components/sanity/structured-data.tsx +83 -0
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/components/disable-draft-mode.tsx +3 -3
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/queries.ts +14 -0
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/sanity.config.ts +19 -3
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/sanity.types.ts +1 -0
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/article.ts +7 -7
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/index.ts +36 -1
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/metadata.ts +12 -1
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/structured-data-blocks.ts +416 -0
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/schemas/structured-data.ts +100 -0
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/structure.ts +37 -2
- package/src/modules/features/cms/sanity/files/lib/integrations/sanity/utils/page-json-ld.ts +208 -0
- package/src/modules/features/cms/sanity/files/lib/scripts/setup-ci-secrets.ts +117 -0
- package/src/modules/features/cms/sanity/files/lib/utils/rss.ts +96 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/.knip.json +8 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/api/[[...slug]]/route.ts +100 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/api/draft-mode/disable/route.ts +7 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/api/draft-mode/enable/route.ts +20 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/api/revalidate/route.ts +126 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/feed.xml/route.ts +40 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/sitemap.md/route.ts +124 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/app/studio/[[...tool]]/page.tsx +8 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/draft-mode-toggle.tsx +27 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/rich-text.tsx +87 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/components/sanity/visual-editing.tsx +28 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/components/ui/sanity-image/index.tsx +41 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/check-integration.ts +5 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/client.ts +27 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/disable-draft-mode.tsx +23 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/page-builder-input.tsx +39 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/page-category-input.tsx +50 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/same-as-input.tsx +66 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/slug-field.tsx +18 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/components/slug-input.tsx +14 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/confirm-publish-action.ts +40 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/env.ts +34 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/fetchers/layout.ts +67 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/fetchers/redirects.ts +17 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/icons.ts +79 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/live/index.tsx +88 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/markdown-proxy.config.ts +50 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-builder-config.ts +130 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-category.ts +28 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/page-tree-pane.tsx +420 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/pinned-pages.ts +54 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/presentation.ts +119 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/queries.ts +407 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/sanity.cli.ts +29 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/sanity.config.ts +113 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/index.ts +4 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/blog-content.ts +89 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/description.ts +29 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/reusable/hero.ts +28 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/components/singleton/content-collection.ts +45 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/content/author.ts +70 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/content/blog-category.ts +55 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/index.ts +124 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/company-data.ts +70 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/footer.ts +79 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/navbar.ts +75 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/redirect.ts +120 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/layout/structured-data.ts +124 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/link.ts +125 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/logo-field.ts +9 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/metadata.ts +79 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/nav-objects.ts +192 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page-builder.ts +39 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page-folder.ts +124 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/page.ts +242 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/richText.ts +63 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/schemas/shared/structured-data-blocks.ts +436 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/singletons.ts +51 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/structure.ts +330 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/image.ts +8 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/link.ts +140 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/page-builder-markdown.ts +81 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/page-json-ld.ts +208 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/scripts/sanity-typegen.ts +45 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/check-redirect.ts +30 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/json-ld.tsx +521 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/metadata.ts +167 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/rss.ts +96 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/lib/utils/sitemap.ts +40 -0
- package/src/modules/features/cms/sanity-pagebuilder/files/proxy.ts +81 -0
- package/src/modules/features/env/dotenvx/files/decrypt-env.mjs +45 -0
- package/src/modules/features/env/dotenvx/files/gitleaks.yml +25 -0
- package/src/modules/features/env/dotenvx/files/instrumentation.ts +14 -0
- package/src/modules/features/env/dotenvx/files/push-keys.mjs +129 -0
- package/src/modules/features/env/dotenvx/files/save-key.mjs +108 -0
- package/src/modules/features/env/dotenvx/files/setup-env.mjs +67 -0
- package/src/modules/features/env/dotenvx/files/vercelignore +4 -0
- package/src/modules/features/env/dotenvx/files/write-env.mjs +47 -0
- package/src/templates/next-default/.env.example +14 -6
- package/src/templates/next-default/.github/workflows/ci.yml +83 -0
- package/src/templates/next-default/.vscode/extensions.json +3 -0
- package/src/templates/next-default/README.md +53 -0
- package/src/templates/next-default/knip.json +14 -0
- package/src/templates/next-default/lefthook.yml +5 -0
- package/src/templates/next-default/lib/utils/json-ld.tsx +327 -21
- package/src/templates/next-default/next.config.ts +6 -0
- package/src/templates/next-default/package.json +8 -4
- package/src/templates/next-experiments/.env.example +14 -6
- package/src/templates/next-experiments/.github/workflows/ci.yml +83 -0
- package/src/templates/next-experiments/.vscode/extensions.json +3 -0
- package/src/templates/next-experiments/README.md +53 -0
- package/src/templates/next-experiments/knip.json +14 -0
- package/src/templates/next-experiments/lefthook.yml +30 -0
- package/src/templates/next-experiments/lib/utils/json-ld.tsx +327 -21
- package/src/templates/next-experiments/next.config.ts +6 -0
- package/src/templates/next-experiments/package.json +10 -2
- package/src/templates/next-pagebuilder/.env.example +19 -1
- package/src/templates/next-pagebuilder/.github/workflows/ci.yml +90 -0
- package/src/templates/next-pagebuilder/.vscode/extensions.json +3 -0
- package/src/templates/next-pagebuilder/README.md +65 -0
- package/src/templates/next-pagebuilder/app/(content)/[[...slug]]/page.tsx +6 -1
- package/src/templates/next-pagebuilder/app/(content)/layout.tsx +3 -12
- package/src/templates/next-pagebuilder/components/layout/footer/index.tsx +11 -10
- package/src/templates/next-pagebuilder/components/layout/header/index.tsx +5 -3
- package/src/templates/next-pagebuilder/components/layout/json-ld/index.tsx +38 -26
- package/src/templates/next-pagebuilder/components/layout/wrapper/index.tsx +3 -11
- package/src/templates/next-pagebuilder/components/page-builder/components/content-collection/index.tsx +1 -1
- package/src/templates/next-pagebuilder/components/page-document/index.tsx +38 -0
- package/src/templates/next-pagebuilder/knip.json +27 -0
- package/src/templates/next-pagebuilder/lefthook.yml +5 -0
- package/src/templates/next-pagebuilder/lib/integrations/sanity/sanity.types.ts +36 -2
- package/src/templates/next-pagebuilder/lib/scripts/setup-ci-secrets.ts +117 -0
- package/src/templates/next-pagebuilder/next.config.ts +6 -0
- package/src/templates/next-pagebuilder/package.json +9 -3
- package/src/templates/next-webgl/.env.example +14 -6
- package/src/templates/next-webgl/.github/workflows/ci.yml +83 -0
- package/src/templates/next-webgl/.vscode/extensions.json +3 -0
- package/src/templates/next-webgl/README.md +53 -0
- package/src/templates/next-webgl/knip.json +13 -0
- package/src/templates/next-webgl/lefthook.yml +5 -0
- package/src/templates/next-webgl/lib/utils/json-ld.tsx +327 -21
- package/src/templates/next-webgl/next.config.ts +6 -0
- package/src/templates/next-webgl/package.json +8 -4
- package/src/modules/features/cms/sanity/files/lib/utils/json-ld.tsx +0 -244
package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/structure.ts
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { from } from "rxjs";
|
|
2
|
+
import { map } from "rxjs/operators";
|
|
3
|
+
import type {
|
|
4
|
+
ComponentBuilder,
|
|
5
|
+
StructureBuilder,
|
|
6
|
+
StructureResolver,
|
|
7
|
+
StructureResolverContext,
|
|
8
|
+
} from "sanity/structure";
|
|
9
|
+
import { apiVersion } from "./env";
|
|
10
|
+
import {
|
|
11
|
+
authorIcon,
|
|
12
|
+
blogCategoryIcon,
|
|
13
|
+
componentsFolderIcon,
|
|
14
|
+
contentFolderIcon,
|
|
15
|
+
contentIcon,
|
|
16
|
+
descriptionIcon,
|
|
17
|
+
heroIcon,
|
|
18
|
+
layoutFolderIcon,
|
|
19
|
+
pageFolderIcon,
|
|
20
|
+
pageIcon,
|
|
21
|
+
pagesFolderIcon,
|
|
22
|
+
redirectIcon,
|
|
23
|
+
} from "./icons";
|
|
24
|
+
import { PageTreePane } from "./page-tree-pane";
|
|
25
|
+
import { PINNED_PAGE_ENTRIES } from "./pinned-pages";
|
|
26
|
+
import { singletonComponents, singletonLayout } from "./singletons";
|
|
27
|
+
|
|
28
|
+
const PAGE_TREE_ITEM_ID_PREFIX = {
|
|
29
|
+
page: "page-tree-",
|
|
30
|
+
pageFolder: "page-folder-tree-",
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
const normalizeDocumentId = (documentId: string) =>
|
|
34
|
+
documentId.replace(/^drafts\./, "");
|
|
35
|
+
|
|
36
|
+
export const getDocumentIdFromPageTreeItemId = (itemId: string) =>
|
|
37
|
+
normalizeDocumentId(
|
|
38
|
+
itemId
|
|
39
|
+
.replace(PAGE_TREE_ITEM_ID_PREFIX.page, "")
|
|
40
|
+
.replace(PAGE_TREE_ITEM_ID_PREFIX.pageFolder, ""),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const getPageTreeTemplateIds = (folderId: string | null) =>
|
|
44
|
+
folderId === null
|
|
45
|
+
? ["page", "pageFolder"]
|
|
46
|
+
: ["page-with-folder", "page-folder-with-parent"];
|
|
47
|
+
|
|
48
|
+
const buildPageTreeCreateChild = (
|
|
49
|
+
S: StructureBuilder,
|
|
50
|
+
documentId: string,
|
|
51
|
+
folderId: string | null,
|
|
52
|
+
templateId: string,
|
|
53
|
+
) => {
|
|
54
|
+
if (templateId === "page") {
|
|
55
|
+
return S.documentWithInitialValueTemplate("page").documentId(documentId);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (templateId === "pageFolder") {
|
|
59
|
+
return S.documentWithInitialValueTemplate("pageFolder").documentId(
|
|
60
|
+
documentId,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (templateId === "page-with-folder") {
|
|
65
|
+
return S.documentWithInitialValueTemplate("page-with-folder", {
|
|
66
|
+
pageFolderId: folderId,
|
|
67
|
+
}).documentId(documentId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (templateId === "page-folder-with-parent") {
|
|
71
|
+
return S.documentWithInitialValueTemplate("page-folder-with-parent", {
|
|
72
|
+
parentFolderId: folderId,
|
|
73
|
+
}).documentId(documentId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return undefined;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const getPageTreeClient = (context: StructureResolverContext) =>
|
|
80
|
+
context
|
|
81
|
+
.getClient({ apiVersion })
|
|
82
|
+
.withConfig({ perspective: context.perspectiveStack });
|
|
83
|
+
|
|
84
|
+
function buildPageTreeComponent(
|
|
85
|
+
S: StructureBuilder,
|
|
86
|
+
context: StructureResolverContext,
|
|
87
|
+
folderId: string | null,
|
|
88
|
+
title: string,
|
|
89
|
+
): ComponentBuilder {
|
|
90
|
+
const allowedTemplateIds = getPageTreeTemplateIds(folderId);
|
|
91
|
+
|
|
92
|
+
const folderMenuItems =
|
|
93
|
+
folderId === null
|
|
94
|
+
? []
|
|
95
|
+
: [
|
|
96
|
+
S.menuItem()
|
|
97
|
+
.title("Folder Settings")
|
|
98
|
+
.icon(pageFolderIcon)
|
|
99
|
+
.intent({
|
|
100
|
+
type: "edit",
|
|
101
|
+
params: { id: folderId, type: "pageFolder" },
|
|
102
|
+
}),
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const createMenuItems =
|
|
106
|
+
folderId === null
|
|
107
|
+
? [
|
|
108
|
+
S.menuItem()
|
|
109
|
+
.title("Create Page")
|
|
110
|
+
.icon(pageIcon)
|
|
111
|
+
.intent({
|
|
112
|
+
type: "create",
|
|
113
|
+
params: { type: "page", template: "page" },
|
|
114
|
+
}),
|
|
115
|
+
S.menuItem()
|
|
116
|
+
.title("Create Folder")
|
|
117
|
+
.icon(pageFolderIcon)
|
|
118
|
+
.intent({
|
|
119
|
+
type: "create",
|
|
120
|
+
params: { type: "pageFolder", template: "pageFolder" },
|
|
121
|
+
}),
|
|
122
|
+
]
|
|
123
|
+
: [
|
|
124
|
+
S.menuItem()
|
|
125
|
+
.title("Create Page")
|
|
126
|
+
.icon(pageIcon)
|
|
127
|
+
.intent({
|
|
128
|
+
type: "create",
|
|
129
|
+
params: [
|
|
130
|
+
{ type: "page", template: "page-with-folder" },
|
|
131
|
+
{ pageFolderId: folderId },
|
|
132
|
+
],
|
|
133
|
+
}),
|
|
134
|
+
S.menuItem()
|
|
135
|
+
.title("Create Folder")
|
|
136
|
+
.icon(pageFolderIcon)
|
|
137
|
+
.intent({
|
|
138
|
+
type: "create",
|
|
139
|
+
params: [
|
|
140
|
+
{ type: "pageFolder", template: "page-folder-with-parent" },
|
|
141
|
+
{ parentFolderId: folderId },
|
|
142
|
+
],
|
|
143
|
+
}),
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
return S.component()
|
|
147
|
+
.id(`page-tree-${folderId ?? "root"}`)
|
|
148
|
+
.title(title)
|
|
149
|
+
.component(PageTreePane)
|
|
150
|
+
.options({ folderId })
|
|
151
|
+
.canHandleIntent((intentName, params) => {
|
|
152
|
+
if (intentName === "create") {
|
|
153
|
+
return (
|
|
154
|
+
typeof params.template === "string" &&
|
|
155
|
+
allowedTemplateIds.includes(params.template)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (intentName === "edit") {
|
|
160
|
+
const id =
|
|
161
|
+
typeof params.id === "string" ? normalizeDocumentId(params.id) : null;
|
|
162
|
+
|
|
163
|
+
// Pinned pages live at the root pane only.
|
|
164
|
+
if (
|
|
165
|
+
folderId === null &&
|
|
166
|
+
id !== null &&
|
|
167
|
+
params.type === "page" &&
|
|
168
|
+
PINNED_PAGE_ENTRIES.some((entry) => entry.id === id)
|
|
169
|
+
) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
id !== null &&
|
|
175
|
+
folderId !== null &&
|
|
176
|
+
id === normalizeDocumentId(folderId) &&
|
|
177
|
+
params.type === "pageFolder"
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return false;
|
|
182
|
+
})
|
|
183
|
+
.child((childId, childOptions) => {
|
|
184
|
+
const normalizedId = getDocumentIdFromPageTreeItemId(childId);
|
|
185
|
+
|
|
186
|
+
// Pinned pages open by their raw id; seed via template so a
|
|
187
|
+
// not-yet-created pinned page gets its title/slug.
|
|
188
|
+
const pinnedEntry = PINNED_PAGE_ENTRIES.find(
|
|
189
|
+
(entry) => entry.id === childId,
|
|
190
|
+
);
|
|
191
|
+
if (pinnedEntry) {
|
|
192
|
+
return S.documentWithInitialValueTemplate(pinnedEntry.id).documentId(
|
|
193
|
+
pinnedEntry.id,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (childId.startsWith(PAGE_TREE_ITEM_ID_PREFIX.page)) {
|
|
198
|
+
return S.document().schemaType("page").documentId(normalizedId);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (childId.startsWith(PAGE_TREE_ITEM_ID_PREFIX.pageFolder)) {
|
|
202
|
+
// Fetch the folder title so the recursive pane shows the right header.
|
|
203
|
+
return from(
|
|
204
|
+
getPageTreeClient(context).fetch<{ title: string | null } | null>(
|
|
205
|
+
`*[_id == $id || _id == "drafts." + $id][0]{ title }`,
|
|
206
|
+
{ id: normalizedId },
|
|
207
|
+
),
|
|
208
|
+
).pipe(
|
|
209
|
+
map((folder) =>
|
|
210
|
+
buildPageTreeComponent(
|
|
211
|
+
S,
|
|
212
|
+
context,
|
|
213
|
+
normalizedId,
|
|
214
|
+
folder?.title ?? "Untitled Folder",
|
|
215
|
+
),
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Current folder settings (edit intent for the folder itself).
|
|
221
|
+
if (folderId !== null && normalizedId === normalizeDocumentId(folderId)) {
|
|
222
|
+
return S.document().schemaType("pageFolder").documentId(normalizedId);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Template-based document creation.
|
|
226
|
+
const templateId =
|
|
227
|
+
typeof childOptions.params?.template === "string"
|
|
228
|
+
? childOptions.params.template
|
|
229
|
+
: null;
|
|
230
|
+
|
|
231
|
+
if (templateId) {
|
|
232
|
+
return buildPageTreeCreateChild(S, normalizedId, folderId, templateId);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return undefined;
|
|
236
|
+
})
|
|
237
|
+
.menuItems([...folderMenuItems, ...createMenuItems]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// https://www.sanity.io/docs/structure-builder-cheat-sheet
|
|
241
|
+
export const structure: StructureResolver = (S, context) =>
|
|
242
|
+
S.list()
|
|
243
|
+
.title("Content")
|
|
244
|
+
.items([
|
|
245
|
+
// GROUP 1: Pages -- root page tree with inline search/filter
|
|
246
|
+
S.listItem()
|
|
247
|
+
.title("Pages")
|
|
248
|
+
.icon(pagesFolderIcon)
|
|
249
|
+
.child(() => buildPageTreeComponent(S, context, null, "Pages")),
|
|
250
|
+
|
|
251
|
+
S.divider(),
|
|
252
|
+
|
|
253
|
+
// GROUP 2: Content -- authors, blog categories
|
|
254
|
+
S.listItem()
|
|
255
|
+
.title("Content")
|
|
256
|
+
.icon(contentFolderIcon)
|
|
257
|
+
.child(
|
|
258
|
+
S.list()
|
|
259
|
+
.title("Content")
|
|
260
|
+
.items([
|
|
261
|
+
S.documentTypeListItem("author")
|
|
262
|
+
.title("Authors")
|
|
263
|
+
.icon(authorIcon),
|
|
264
|
+
S.documentTypeListItem("blogCategory")
|
|
265
|
+
.title("Blog Categories")
|
|
266
|
+
.icon(blogCategoryIcon),
|
|
267
|
+
]),
|
|
268
|
+
),
|
|
269
|
+
|
|
270
|
+
S.divider(),
|
|
271
|
+
|
|
272
|
+
// GROUP 3: Components -- singleton and reusable components
|
|
273
|
+
S.listItem()
|
|
274
|
+
.title("Components")
|
|
275
|
+
.icon(componentsFolderIcon)
|
|
276
|
+
.child(
|
|
277
|
+
S.list()
|
|
278
|
+
.title("Components")
|
|
279
|
+
.items([
|
|
280
|
+
S.divider().title("Singleton Components"),
|
|
281
|
+
...singletonComponents.map((item) =>
|
|
282
|
+
S.listItem()
|
|
283
|
+
.title(item.title)
|
|
284
|
+
.id(item.documentId)
|
|
285
|
+
.icon(item.icon)
|
|
286
|
+
.child(
|
|
287
|
+
S.document()
|
|
288
|
+
.schemaType(item.schemaType)
|
|
289
|
+
.documentId(item.documentId),
|
|
290
|
+
),
|
|
291
|
+
),
|
|
292
|
+
S.divider().title("Reusable Components"),
|
|
293
|
+
S.documentTypeListItem("hero").title("Headings").icon(heroIcon),
|
|
294
|
+
S.documentTypeListItem("description")
|
|
295
|
+
.title("Descriptions")
|
|
296
|
+
.icon(descriptionIcon),
|
|
297
|
+
S.documentTypeListItem("blogContent")
|
|
298
|
+
.title("Blog Content")
|
|
299
|
+
.icon(contentIcon),
|
|
300
|
+
]),
|
|
301
|
+
),
|
|
302
|
+
|
|
303
|
+
S.divider(),
|
|
304
|
+
|
|
305
|
+
// GROUP 4: Layout -- global layout singletons + managed collections
|
|
306
|
+
S.listItem()
|
|
307
|
+
.title("Layout")
|
|
308
|
+
.icon(layoutFolderIcon)
|
|
309
|
+
.child(
|
|
310
|
+
S.list()
|
|
311
|
+
.title("Layout")
|
|
312
|
+
.items([
|
|
313
|
+
...singletonLayout.map((item) =>
|
|
314
|
+
S.listItem()
|
|
315
|
+
.title(item.title)
|
|
316
|
+
.id(item.documentId)
|
|
317
|
+
.icon(item.icon)
|
|
318
|
+
.child(
|
|
319
|
+
S.document()
|
|
320
|
+
.schemaType(item.schemaType)
|
|
321
|
+
.documentId(item.documentId),
|
|
322
|
+
),
|
|
323
|
+
),
|
|
324
|
+
S.divider(),
|
|
325
|
+
S.documentTypeListItem("redirect")
|
|
326
|
+
.title("Redirects")
|
|
327
|
+
.icon(redirectIcon),
|
|
328
|
+
]),
|
|
329
|
+
),
|
|
330
|
+
]);
|
package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/image.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createImageUrlBuilder } from "@sanity/image-url";
|
|
2
|
+
import { dataset, projectId } from "../env";
|
|
3
|
+
|
|
4
|
+
const builder = createImageUrlBuilder({ projectId, dataset });
|
|
5
|
+
|
|
6
|
+
export const urlForImage = (source: Parameters<typeof builder.image>[0]) => {
|
|
7
|
+
return builder.image(source);
|
|
8
|
+
};
|
package/src/modules/features/cms/sanity-pagebuilder/files/lib/integrations/sanity/utils/link.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { getPinnedPageById } from "@/lib/integrations/sanity/pinned-pages";
|
|
2
|
+
|
|
3
|
+
type PageReference = {
|
|
4
|
+
_id?: string;
|
|
5
|
+
_ref?: string;
|
|
6
|
+
_type?: string;
|
|
7
|
+
slug?: { current?: string | null } | null;
|
|
8
|
+
resolvedSlug?: string | null;
|
|
9
|
+
title?: string | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type PageReferenceLink = {
|
|
13
|
+
_type: "pageReference";
|
|
14
|
+
page?: PageReference | null;
|
|
15
|
+
text?: string | null;
|
|
16
|
+
openInNewTab?: boolean | null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type ExternalLinkItem = {
|
|
20
|
+
_type: "externalLink";
|
|
21
|
+
href?: string | null;
|
|
22
|
+
text?: string | null;
|
|
23
|
+
openInNewTab?: boolean | null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type LinkItem = PageReferenceLink | ExternalLinkItem;
|
|
27
|
+
|
|
28
|
+
// Backward-compatible shape (old data without _type)
|
|
29
|
+
type LegacyLink = {
|
|
30
|
+
page?: PageReference | null;
|
|
31
|
+
href?: string | null;
|
|
32
|
+
text?: string | null;
|
|
33
|
+
openInNewTab?: boolean | null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type LinkLike = LinkItem | LegacyLink;
|
|
37
|
+
|
|
38
|
+
type InternalReference = {
|
|
39
|
+
_id?: string;
|
|
40
|
+
_type: string;
|
|
41
|
+
slug?: { current?: string | null } | null;
|
|
42
|
+
resolvedSlug?: string | null;
|
|
43
|
+
title?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolves a link object to a URL string.
|
|
48
|
+
*
|
|
49
|
+
* Supports both the new discriminated union shape (_type: "pageReference" | "externalLink")
|
|
50
|
+
* and the legacy flat shape (page + href without _type).
|
|
51
|
+
*/
|
|
52
|
+
export const urlForReference = (link: LinkLike | null): string => {
|
|
53
|
+
if (!link) return "#";
|
|
54
|
+
|
|
55
|
+
// New discriminated union
|
|
56
|
+
if ("_type" in link && link._type === "pageReference") {
|
|
57
|
+
if (
|
|
58
|
+
link.page &&
|
|
59
|
+
typeof link.page === "object" &&
|
|
60
|
+
("slug" in link.page || "_id" in link.page)
|
|
61
|
+
) {
|
|
62
|
+
const ref = link.page as InternalReference;
|
|
63
|
+
return resolveDocumentUrl(
|
|
64
|
+
ref._type,
|
|
65
|
+
ref.resolvedSlug ?? undefined,
|
|
66
|
+
ref.slug?.current ?? undefined,
|
|
67
|
+
ref._id,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return "#";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if ("_type" in link && link._type === "externalLink") {
|
|
74
|
+
return link.href || "#";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Legacy fallback (flat shape without _type)
|
|
78
|
+
if (
|
|
79
|
+
"page" in link &&
|
|
80
|
+
link.page &&
|
|
81
|
+
typeof link.page === "object" &&
|
|
82
|
+
("slug" in link.page || "_id" in link.page)
|
|
83
|
+
) {
|
|
84
|
+
const ref = link.page as InternalReference;
|
|
85
|
+
return resolveDocumentUrl(
|
|
86
|
+
ref._type,
|
|
87
|
+
ref.resolvedSlug ?? undefined,
|
|
88
|
+
ref.slug?.current ?? undefined,
|
|
89
|
+
ref._id,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ("href" in link && link.href) {
|
|
94
|
+
return link.href;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return "#";
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function resolveDocumentUrl(
|
|
101
|
+
documentType: string,
|
|
102
|
+
resolvedSlug?: string,
|
|
103
|
+
slug?: string,
|
|
104
|
+
documentId?: string,
|
|
105
|
+
): string {
|
|
106
|
+
if (documentType === "page") {
|
|
107
|
+
const pinned = getPinnedPageById(documentId);
|
|
108
|
+
if (pinned) return pinned.path;
|
|
109
|
+
if (resolvedSlug) return `/${resolvedSlug}`;
|
|
110
|
+
if (slug) return `/${slug}`;
|
|
111
|
+
return "#";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!slug) return "#";
|
|
115
|
+
|
|
116
|
+
console.warn("Unknown document type for URL resolution:", documentType);
|
|
117
|
+
return "#";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns href, target, and rel attributes for a link object.
|
|
122
|
+
*
|
|
123
|
+
* External detection: externalLink type, or URLs starting with "http".
|
|
124
|
+
*/
|
|
125
|
+
export const getLinkAttributes = (link: LinkLike | null) => {
|
|
126
|
+
if (!link) return { href: "#", target: undefined, rel: undefined };
|
|
127
|
+
|
|
128
|
+
const href = urlForReference(link);
|
|
129
|
+
const isExternal =
|
|
130
|
+
("_type" in link && link._type === "externalLink") ||
|
|
131
|
+
href.startsWith("http");
|
|
132
|
+
|
|
133
|
+
const shouldOpenNewTab = link.openInNewTab || isExternal;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
href,
|
|
137
|
+
target: shouldOpenNewTab ? "_blank" : undefined,
|
|
138
|
+
rel: shouldOpenNewTab ? "noopener noreferrer" : undefined,
|
|
139
|
+
};
|
|
140
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { portableTextToMarkdown } from "@portabletext/markdown";
|
|
2
|
+
import type { PAGE_QUERY_RESULT } from "../sanity.types";
|
|
3
|
+
|
|
4
|
+
const markdownOptions = {
|
|
5
|
+
types: {
|
|
6
|
+
table: ({ value }: { value: { rows?: Array<{ cells?: string[] }> } }) => {
|
|
7
|
+
const rows = value?.rows;
|
|
8
|
+
if (!rows?.length) return "";
|
|
9
|
+
return rows
|
|
10
|
+
.map((row) => `| ${(row.cells ?? []).join(" | ")} |`)
|
|
11
|
+
.join("\n");
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} satisfies Parameters<typeof portableTextToMarkdown>[1];
|
|
15
|
+
|
|
16
|
+
type PageBuilderBlock = NonNullable<
|
|
17
|
+
NonNullable<PAGE_QUERY_RESULT>["pageBuilder"]
|
|
18
|
+
>[number];
|
|
19
|
+
|
|
20
|
+
export const renderPageBuilderMarkdown = (
|
|
21
|
+
blocks: PageBuilderBlock[] | null | undefined,
|
|
22
|
+
) => {
|
|
23
|
+
if (!blocks?.length) return "";
|
|
24
|
+
|
|
25
|
+
return blocks
|
|
26
|
+
.flatMap((block) => {
|
|
27
|
+
switch (block._type) {
|
|
28
|
+
case "hero":
|
|
29
|
+
return block.headline ? [`## ${block.headline}`, ""] : [];
|
|
30
|
+
case "description":
|
|
31
|
+
return block.description ? [block.description, ""] : [];
|
|
32
|
+
case "blogContent": {
|
|
33
|
+
const lines: (string | null)[] = [];
|
|
34
|
+
const categories =
|
|
35
|
+
"categories" in block ? block.categories : undefined;
|
|
36
|
+
const relatedPosts =
|
|
37
|
+
"relatedPosts" in block ? block.relatedPosts : undefined;
|
|
38
|
+
|
|
39
|
+
if (categories?.length) {
|
|
40
|
+
lines.push(
|
|
41
|
+
categories
|
|
42
|
+
.map((c) => c.title)
|
|
43
|
+
.filter(Boolean)
|
|
44
|
+
.join(", "),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (block.author?.name) {
|
|
48
|
+
const authorParts = [block.author.name, block.author.role]
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join(", ");
|
|
51
|
+
lines.push(`**Author:** ${authorParts}`);
|
|
52
|
+
}
|
|
53
|
+
if (block.date) {
|
|
54
|
+
lines.push(`**Date:** ${block.date}`);
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
if (block.body) {
|
|
58
|
+
lines.push(
|
|
59
|
+
portableTextToMarkdown(
|
|
60
|
+
block.body as Parameters<typeof portableTextToMarkdown>[0],
|
|
61
|
+
markdownOptions,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (relatedPosts?.length) {
|
|
66
|
+
lines.push("", "## Related Articles", "");
|
|
67
|
+
for (const post of relatedPosts) {
|
|
68
|
+
if (post.title && post.resolvedSlug) {
|
|
69
|
+
lines.push(`- [${post.title}](/${post.resolvedSlug}.md)`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
lines.push("");
|
|
74
|
+
return lines.filter((l) => l !== null);
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
.join("\n");
|
|
81
|
+
};
|