blodemd 0.1.0 → 0.2.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/dist/cli.mjs +50 -174
- package/dist/cli.mjs.map +1 -1
- package/package.json +3 -36
- package/dev-server/app/[[...slug]]/page.tsx +0 -140
- package/dev-server/app/blodemd-dev/invalidate/route.ts +0 -12
- package/dev-server/app/blodemd-dev/static/[...path]/route.ts +0 -32
- package/dev-server/app/blodemd-dev/version/route.ts +0 -14
- package/dev-server/app/blodemd-internal/proxy/route.ts +0 -86
- package/dev-server/app/error.tsx +0 -24
- package/dev-server/app/favicon.ico +0 -0
- package/dev-server/app/globals.css +0 -4
- package/dev-server/app/layout.tsx +0 -38
- package/dev-server/app/not-found.tsx +0 -18
- package/dev-server/app/search/route.ts +0 -17
- package/dev-server/components/dev-reload-script.tsx +0 -86
- package/dev-server/components/providers.tsx +0 -15
- package/dev-server/lib/dev-state.ts +0 -8
- package/dev-server/lib/local-content-source.ts +0 -103
- package/dev-server/lib/local-runtime.tsx +0 -555
- package/dev-server/next-env.d.ts +0 -5
- package/dev-server/next.config.js +0 -54
- package/dev-server/package.json +0 -61
- package/dev-server/postcss.config.mjs +0 -7
- package/dev-server/public/glide-variable.woff2 +0 -0
- package/dev-server/tsconfig.json +0 -50
- package/docs/app/globals.css +0 -471
- package/docs/components/animate-ui/primitives/buttons/button.tsx +0 -14
- package/docs/components/api/api-playground.tsx +0 -467
- package/docs/components/api/api-reference.tsx +0 -157
- package/docs/components/content/collection-index.tsx +0 -114
- package/docs/components/docs/contextual-menu.tsx +0 -495
- package/docs/components/docs/copy-page-menu.tsx +0 -364
- package/docs/components/docs/doc-header.tsx +0 -223
- package/docs/components/docs/doc-shell.tsx +0 -355
- package/docs/components/docs/doc-sidebar.tsx +0 -256
- package/docs/components/docs/doc-toc.tsx +0 -46
- package/docs/components/docs/mobile-nav.tsx +0 -195
- package/docs/components/docs/sidebar-active-highlight.tsx +0 -34
- package/docs/components/docs/sidebar-scroll-area.tsx +0 -63
- package/docs/components/git/repo-picker.tsx +0 -529
- package/docs/components/icons/doc-icon.tsx +0 -96
- package/docs/components/mdx/accordion.tsx +0 -83
- package/docs/components/mdx/agent-instructions.tsx +0 -17
- package/docs/components/mdx/badge.tsx +0 -79
- package/docs/components/mdx/callout.tsx +0 -88
- package/docs/components/mdx/card.tsx +0 -110
- package/docs/components/mdx/code-block.tsx +0 -80
- package/docs/components/mdx/code-group.tsx +0 -203
- package/docs/components/mdx/color.tsx +0 -87
- package/docs/components/mdx/columns.tsx +0 -25
- package/docs/components/mdx/expandable.tsx +0 -45
- package/docs/components/mdx/field-layout.tsx +0 -77
- package/docs/components/mdx/frame.tsx +0 -23
- package/docs/components/mdx/get-text-content.ts +0 -18
- package/docs/components/mdx/icon.tsx +0 -12
- package/docs/components/mdx/iframe.tsx +0 -62
- package/docs/components/mdx/index.tsx +0 -121
- package/docs/components/mdx/installer.tsx +0 -20
- package/docs/components/mdx/panel.tsx +0 -11
- package/docs/components/mdx/param-field.tsx +0 -56
- package/docs/components/mdx/preview.tsx +0 -36
- package/docs/components/mdx/prompt.tsx +0 -63
- package/docs/components/mdx/request-example.tsx +0 -27
- package/docs/components/mdx/response-field.tsx +0 -42
- package/docs/components/mdx/steps.tsx +0 -92
- package/docs/components/mdx/tabs.tsx +0 -193
- package/docs/components/mdx/tile.tsx +0 -43
- package/docs/components/mdx/tooltip.tsx +0 -71
- package/docs/components/mdx/tree.tsx +0 -120
- package/docs/components/mdx/type-table.tsx +0 -71
- package/docs/components/mdx/update.tsx +0 -44
- package/docs/components/mdx/video.tsx +0 -45
- package/docs/components/mdx/view.tsx +0 -66
- package/docs/components/posthog-provider.tsx +0 -42
- package/docs/components/providers.tsx +0 -15
- package/docs/components/tenant-analytics.tsx +0 -49
- package/docs/components/third-parties.tsx +0 -32
- package/docs/components/ui/badge.tsx +0 -61
- package/docs/components/ui/breadcrumb.tsx +0 -112
- package/docs/components/ui/button-group.tsx +0 -83
- package/docs/components/ui/button.tsx +0 -65
- package/docs/components/ui/card.tsx +0 -92
- package/docs/components/ui/command.tsx +0 -167
- package/docs/components/ui/copy-button.tsx +0 -129
- package/docs/components/ui/dialog.tsx +0 -146
- package/docs/components/ui/field.tsx +0 -237
- package/docs/components/ui/input.tsx +0 -23
- package/docs/components/ui/kbd.tsx +0 -98
- package/docs/components/ui/label.tsx +0 -22
- package/docs/components/ui/morph-icon.tsx +0 -79
- package/docs/components/ui/popover.tsx +0 -267
- package/docs/components/ui/search-dialog.tsx +0 -431
- package/docs/components/ui/search.tsx +0 -101
- package/docs/components/ui/separator.tsx +0 -26
- package/docs/components/ui/sheet.tsx +0 -133
- package/docs/components/ui/sidebar.tsx +0 -758
- package/docs/components/ui/skeleton.tsx +0 -11
- package/docs/components/ui/switch.tsx +0 -32
- package/docs/components/ui/tabs.tsx +0 -138
- package/docs/components/ui/theme-toggle.tsx +0 -62
- package/docs/components/ui/tooltip.tsx +0 -53
- package/docs/components/web-mcp.tsx +0 -115
- package/docs/lib/agent-skills.ts +0 -48
- package/docs/lib/api-client.ts +0 -72
- package/docs/lib/config.ts +0 -6
- package/docs/lib/content-root.ts +0 -33
- package/docs/lib/content-source.ts +0 -70
- package/docs/lib/contextual-options.ts +0 -222
- package/docs/lib/dashboard-session.ts +0 -167
- package/docs/lib/db.ts +0 -13
- package/docs/lib/docs-collection.ts +0 -7
- package/docs/lib/docs-runtime.tsx +0 -745
- package/docs/lib/edge-config.ts +0 -95
- package/docs/lib/env.ts +0 -23
- package/docs/lib/etag.ts +0 -22
- package/docs/lib/github-install.ts +0 -33
- package/docs/lib/llms-full.ts +0 -82
- package/docs/lib/marketing-markdown.ts +0 -79
- package/docs/lib/marketing-site.ts +0 -31
- package/docs/lib/mdx.ts +0 -98
- package/docs/lib/navigation.ts +0 -288
- package/docs/lib/openapi-proxy.ts +0 -88
- package/docs/lib/openapi.ts +0 -158
- package/docs/lib/platform-config.ts +0 -6
- package/docs/lib/project-authz.ts +0 -46
- package/docs/lib/routes.ts +0 -103
- package/docs/lib/server-cache.ts +0 -83
- package/docs/lib/shiki.ts +0 -44
- package/docs/lib/supabase.ts +0 -37
- package/docs/lib/tenancy.ts +0 -364
- package/docs/lib/tenant-headers.ts +0 -43
- package/docs/lib/tenant-static.ts +0 -705
- package/docs/lib/tenant-utility-context.ts +0 -62
- package/docs/lib/tenants.ts +0 -72
- package/docs/lib/theme.ts +0 -29
- package/docs/lib/time-ago.ts +0 -24
- package/docs/lib/toc.ts +0 -2
- package/docs/lib/use-mobile.ts +0 -19
- package/docs/lib/use-tab-observer.ts +0 -71
- package/docs/lib/utils.ts +0 -5
- package/packages/@repo/common/dist/index.d.ts +0 -16
- package/packages/@repo/common/dist/index.d.ts.map +0 -1
- package/packages/@repo/common/dist/index.js +0 -84
- package/packages/@repo/common/package.json +0 -34
- package/packages/@repo/common/src/index.ts +0 -101
- package/packages/@repo/contracts/dist/analytics.d.ts +0 -21
- package/packages/@repo/contracts/dist/analytics.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/analytics.js +0 -18
- package/packages/@repo/contracts/dist/api-key.d.ts +0 -27
- package/packages/@repo/contracts/dist/api-key.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/api-key.js +0 -20
- package/packages/@repo/contracts/dist/dates.d.ts +0 -4
- package/packages/@repo/contracts/dist/dates.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/dates.js +0 -2
- package/packages/@repo/contracts/dist/deployment.d.ts +0 -71
- package/packages/@repo/contracts/dist/deployment.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/deployment.js +0 -46
- package/packages/@repo/contracts/dist/domain.d.ts +0 -94
- package/packages/@repo/contracts/dist/domain.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/domain.js +0 -36
- package/packages/@repo/contracts/dist/git.d.ts +0 -28
- package/packages/@repo/contracts/dist/git.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/git.js +0 -24
- package/packages/@repo/contracts/dist/ids.d.ts +0 -14
- package/packages/@repo/contracts/dist/ids.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/ids.js +0 -11
- package/packages/@repo/contracts/dist/index.d.ts +0 -12
- package/packages/@repo/contracts/dist/index.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/index.js +0 -13
- package/packages/@repo/contracts/dist/pagination.d.ts +0 -23
- package/packages/@repo/contracts/dist/pagination.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/pagination.js +0 -15
- package/packages/@repo/contracts/dist/project.d.ts +0 -42
- package/packages/@repo/contracts/dist/project.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/project.js +0 -25
- package/packages/@repo/contracts/dist/tenant.d.ts +0 -147
- package/packages/@repo/contracts/dist/tenant.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/tenant.js +0 -58
- package/packages/@repo/contracts/dist/user.d.ts +0 -9
- package/packages/@repo/contracts/dist/user.d.ts.map +0 -1
- package/packages/@repo/contracts/dist/user.js +0 -9
- package/packages/@repo/contracts/package.json +0 -37
- package/packages/@repo/contracts/src/analytics.ts +0 -33
- package/packages/@repo/contracts/src/api-key.ts +0 -27
- package/packages/@repo/contracts/src/dates.ts +0 -4
- package/packages/@repo/contracts/src/deployment.ts +0 -73
- package/packages/@repo/contracts/src/domain.ts +0 -51
- package/packages/@repo/contracts/src/git.ts +0 -31
- package/packages/@repo/contracts/src/ids.ts +0 -23
- package/packages/@repo/contracts/src/index.ts +0 -13
- package/packages/@repo/contracts/src/pagination.ts +0 -21
- package/packages/@repo/contracts/src/project.ts +0 -32
- package/packages/@repo/contracts/src/tenant.ts +0 -94
- package/packages/@repo/contracts/src/user.ts +0 -12
- package/packages/@repo/models/dist/docs-config.d.ts +0 -961
- package/packages/@repo/models/dist/docs-config.d.ts.map +0 -1
- package/packages/@repo/models/dist/docs-config.js +0 -531
- package/packages/@repo/models/dist/index.d.ts +0 -3
- package/packages/@repo/models/dist/index.d.ts.map +0 -1
- package/packages/@repo/models/dist/index.js +0 -3
- package/packages/@repo/models/dist/tenant.d.ts +0 -37
- package/packages/@repo/models/dist/tenant.d.ts.map +0 -1
- package/packages/@repo/models/dist/tenant.js +0 -1
- package/packages/@repo/models/package.json +0 -37
- package/packages/@repo/models/src/docs-config.ts +0 -629
- package/packages/@repo/models/src/index.ts +0 -3
- package/packages/@repo/models/src/tenant.ts +0 -44
- package/packages/@repo/prebuild/dist/index.d.ts +0 -2
- package/packages/@repo/prebuild/dist/index.d.ts.map +0 -1
- package/packages/@repo/prebuild/dist/index.js +0 -2
- package/packages/@repo/prebuild/dist/openapi.d.ts +0 -43
- package/packages/@repo/prebuild/dist/openapi.d.ts.map +0 -1
- package/packages/@repo/prebuild/dist/openapi.js +0 -86
- package/packages/@repo/prebuild/package.json +0 -39
- package/packages/@repo/prebuild/src/index.ts +0 -2
- package/packages/@repo/prebuild/src/openapi.ts +0 -154
- package/packages/@repo/previewing/dist/blob-source.d.ts +0 -16
- package/packages/@repo/previewing/dist/blob-source.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/blob-source.js +0 -128
- package/packages/@repo/previewing/dist/config-loader.d.ts +0 -134
- package/packages/@repo/previewing/dist/config-loader.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/config-loader.js +0 -231
- package/packages/@repo/previewing/dist/constants.d.ts +0 -15
- package/packages/@repo/previewing/dist/constants.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/constants.js +0 -14
- package/packages/@repo/previewing/dist/content-index.d.ts +0 -7
- package/packages/@repo/previewing/dist/content-index.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/content-index.js +0 -291
- package/packages/@repo/previewing/dist/content-source.d.ts +0 -12
- package/packages/@repo/previewing/dist/content-source.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/content-source.js +0 -1
- package/packages/@repo/previewing/dist/fs-source.d.ts +0 -11
- package/packages/@repo/previewing/dist/fs-source.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/fs-source.js +0 -71
- package/packages/@repo/previewing/dist/index.d.ts +0 -16
- package/packages/@repo/previewing/dist/index.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/index.js +0 -13
- package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts +0 -3
- package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/markdown/agent-markdown.js +0 -176
- package/packages/@repo/previewing/dist/markdown/format.d.ts +0 -8
- package/packages/@repo/previewing/dist/markdown/format.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/markdown/format.js +0 -43
- package/packages/@repo/previewing/dist/markdown/links.d.ts +0 -3
- package/packages/@repo/previewing/dist/markdown/links.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/markdown/links.js +0 -31
- package/packages/@repo/previewing/dist/openapi-pages.d.ts +0 -7
- package/packages/@repo/previewing/dist/openapi-pages.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/openapi-pages.js +0 -200
- package/packages/@repo/previewing/dist/search-index.d.ts +0 -4
- package/packages/@repo/previewing/dist/search-index.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/search-index.js +0 -23
- package/packages/@repo/previewing/dist/serialization.d.ts +0 -13
- package/packages/@repo/previewing/dist/serialization.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/serialization.js +0 -108
- package/packages/@repo/previewing/dist/toc-index.d.ts +0 -5
- package/packages/@repo/previewing/dist/toc-index.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/toc-index.js +0 -53
- package/packages/@repo/previewing/dist/types.d.ts +0 -92
- package/packages/@repo/previewing/dist/types.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/types.js +0 -1
- package/packages/@repo/previewing/dist/utility-index.d.ts +0 -7
- package/packages/@repo/previewing/dist/utility-index.d.ts.map +0 -1
- package/packages/@repo/previewing/dist/utility-index.js +0 -201
- package/packages/@repo/previewing/package.json +0 -41
- package/packages/@repo/previewing/src/blob-source.ts +0 -185
- package/packages/@repo/previewing/src/config-loader.ts +0 -316
- package/packages/@repo/previewing/src/constants.ts +0 -16
- package/packages/@repo/previewing/src/content-index.ts +0 -384
- package/packages/@repo/previewing/src/content-source.ts +0 -12
- package/packages/@repo/previewing/src/fs-source.ts +0 -103
- package/packages/@repo/previewing/src/index.ts +0 -71
- package/packages/@repo/previewing/src/markdown/agent-markdown.ts +0 -254
- package/packages/@repo/previewing/src/markdown/format.ts +0 -63
- package/packages/@repo/previewing/src/markdown/links.ts +0 -46
- package/packages/@repo/previewing/src/openapi-pages.ts +0 -319
- package/packages/@repo/previewing/src/search-index.ts +0 -38
- package/packages/@repo/previewing/src/serialization.ts +0 -191
- package/packages/@repo/previewing/src/toc-index.ts +0 -72
- package/packages/@repo/previewing/src/types.ts +0 -105
- package/packages/@repo/previewing/src/utility-index.ts +0 -304
- package/packages/@repo/validation/dist/index.d.ts +0 -12
- package/packages/@repo/validation/dist/index.d.ts.map +0 -1
- package/packages/@repo/validation/dist/index.js +0 -30
- package/packages/@repo/validation/package.json +0 -38
- package/packages/@repo/validation/src/blodemd-docs-schema.json +0 -3575
- package/packages/@repo/validation/src/index.ts +0 -59
- package/scripts/prepare-package.mjs +0 -53
- package/scripts/repo-packages.mjs +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blodemd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Blode.md CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,12 +10,7 @@
|
|
|
10
10
|
"blodemd": "./dist/cli.mjs"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
"dev-server",
|
|
15
|
-
"docs",
|
|
16
|
-
"packages",
|
|
17
|
-
"scripts/prepare-package.mjs",
|
|
18
|
-
"scripts/repo-packages.mjs"
|
|
13
|
+
"dist"
|
|
19
14
|
],
|
|
20
15
|
"type": "module",
|
|
21
16
|
"main": "./dist/index.mjs",
|
|
@@ -38,40 +33,11 @@
|
|
|
38
33
|
"test:unit": "sh -c 'cd ../.. && vitest run --config vitest.config.ts --project unit apps/cli/src'"
|
|
39
34
|
},
|
|
40
35
|
"dependencies": {
|
|
41
|
-
"@base-ui/react": "^1.3.0",
|
|
42
36
|
"@clack/prompts": "^1.0.0",
|
|
43
|
-
"@mdx-js/mdx": "^3.1.1",
|
|
44
|
-
"@shikijs/rehype": "^4.0.2",
|
|
45
|
-
"@tailwindcss/postcss": "^4.2.2",
|
|
46
|
-
"@types/node": "^24.12.2",
|
|
47
|
-
"@types/react": "19.2.14",
|
|
48
|
-
"@types/react-dom": "19.2.3",
|
|
49
|
-
"blode-icons-react": "^0.3.10",
|
|
50
37
|
"chalk": "^5.6.2",
|
|
51
38
|
"chokidar": "^4.0.3",
|
|
52
|
-
"class-variance-authority": "^0.7.1",
|
|
53
|
-
"clsx": "^2.1.1",
|
|
54
|
-
"cmdk": "^1.1.1",
|
|
55
39
|
"commander": "^14.0.0",
|
|
56
|
-
"geist": "^1.7.0",
|
|
57
|
-
"merge-refs": "^2.0.0",
|
|
58
|
-
"motion": "^12.38.0",
|
|
59
|
-
"next": "16.2.1",
|
|
60
|
-
"next-mdx-remote": "^6.0.0",
|
|
61
|
-
"next-themes": "^0.4.6",
|
|
62
40
|
"open": "^10.2.0",
|
|
63
|
-
"radix-ui": "^1.4.3",
|
|
64
|
-
"react": "^19.2.0",
|
|
65
|
-
"react-dom": "^19.2.0",
|
|
66
|
-
"rehype-autolink-headings": "^7.1.0",
|
|
67
|
-
"rehype-slug": "^6.0.0",
|
|
68
|
-
"remark-gfm": "^4.0.0",
|
|
69
|
-
"shadcn": "^4.1.1",
|
|
70
|
-
"shiki": "^4.0.2",
|
|
71
|
-
"tailwind-merge": "^3.5.0",
|
|
72
|
-
"tailwindcss": "^4.2.2",
|
|
73
|
-
"tw-animate-css": "^1.4.0",
|
|
74
|
-
"typescript": "6.0.2",
|
|
75
41
|
"yaml": "^2.8.3",
|
|
76
42
|
"zod": "^4.3.6"
|
|
77
43
|
},
|
|
@@ -81,6 +47,7 @@
|
|
|
81
47
|
"@repo/models": "*",
|
|
82
48
|
"@repo/previewing": "*",
|
|
83
49
|
"@repo/typescript-config": "*",
|
|
50
|
+
"@types/node": "^24.12.2",
|
|
84
51
|
"oxfmt": "^0.42.0",
|
|
85
52
|
"oxlint": "^1.57.0",
|
|
86
53
|
"tsdown": "^0.21.5",
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { getDocPageContent, getDocShellData } from "@dev/lib/local-runtime";
|
|
2
|
-
import type { Metadata } from "next";
|
|
3
|
-
import { notFound } from "next/navigation";
|
|
4
|
-
|
|
5
|
-
import { ApiReference } from "@/components/api/api-reference";
|
|
6
|
-
import { CollectionIndex } from "@/components/content/collection-index";
|
|
7
|
-
import { DocShell } from "@/components/docs/doc-shell";
|
|
8
|
-
|
|
9
|
-
const buildTitle = (pageTitle?: string, baseTitle = "Docs") =>
|
|
10
|
-
pageTitle ? `${pageTitle} · ${baseTitle}` : baseTitle;
|
|
11
|
-
|
|
12
|
-
export const generateMetadata = async ({
|
|
13
|
-
params,
|
|
14
|
-
}: {
|
|
15
|
-
params: Promise<{ slug?: string[] }>;
|
|
16
|
-
}): Promise<Metadata> => {
|
|
17
|
-
const { slug = [] } = await params;
|
|
18
|
-
const data = await getDocShellData(slug.join("/"));
|
|
19
|
-
|
|
20
|
-
if (!data || "configErrors" in data) {
|
|
21
|
-
return {
|
|
22
|
-
description: "Documentation",
|
|
23
|
-
title: "Docs",
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { config } = data;
|
|
28
|
-
const title = buildTitle(data.pageTitle, config.name ?? "Docs");
|
|
29
|
-
const noindex =
|
|
30
|
-
data.noindex || (data.hidden && config.seo?.indexing !== "all");
|
|
31
|
-
const ogImage = config.metadata?.ogImage;
|
|
32
|
-
const { favicon } = config;
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
description: data.pageDescription ?? config.description,
|
|
36
|
-
icons: favicon ? { icon: favicon } : undefined,
|
|
37
|
-
openGraph: ogImage
|
|
38
|
-
? {
|
|
39
|
-
images: [ogImage],
|
|
40
|
-
}
|
|
41
|
-
: undefined,
|
|
42
|
-
robots: noindex ? { index: false } : undefined,
|
|
43
|
-
title,
|
|
44
|
-
twitter: ogImage
|
|
45
|
-
? {
|
|
46
|
-
card: "summary_large_image",
|
|
47
|
-
images: [ogImage],
|
|
48
|
-
}
|
|
49
|
-
: undefined,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const PreviewPage = async ({
|
|
54
|
-
params,
|
|
55
|
-
}: {
|
|
56
|
-
params: Promise<{ slug?: string[] }>;
|
|
57
|
-
}) => {
|
|
58
|
-
const { slug = [] } = await params;
|
|
59
|
-
const slugKey = slug.join("/");
|
|
60
|
-
const shell = await getDocShellData(slugKey);
|
|
61
|
-
|
|
62
|
-
if (!shell) {
|
|
63
|
-
return notFound();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ("configErrors" in shell) {
|
|
67
|
-
const errors = shell.configErrors ?? [];
|
|
68
|
-
const warnings = shell.configWarnings ?? [];
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className="p-10">
|
|
72
|
-
<h1>Invalid docs.json</h1>
|
|
73
|
-
{warnings.length ? (
|
|
74
|
-
<>
|
|
75
|
-
<h2>Warnings</h2>
|
|
76
|
-
<ul>
|
|
77
|
-
{warnings.map((warning) => (
|
|
78
|
-
<li key={warning}>{warning}</li>
|
|
79
|
-
))}
|
|
80
|
-
</ul>
|
|
81
|
-
</>
|
|
82
|
-
) : null}
|
|
83
|
-
<ul>
|
|
84
|
-
{errors.map((error) => (
|
|
85
|
-
<li key={error}>{error}</li>
|
|
86
|
-
))}
|
|
87
|
-
</ul>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let content: React.ReactNode;
|
|
93
|
-
let rawContent: string | undefined;
|
|
94
|
-
let toc: { id: string; level: number; title: string }[] = [];
|
|
95
|
-
|
|
96
|
-
if (shell.kind === "openapi") {
|
|
97
|
-
content = (
|
|
98
|
-
<ApiReference
|
|
99
|
-
entry={shell.openApiEntry}
|
|
100
|
-
proxyEnabled={shell.openapiProxyEnabled}
|
|
101
|
-
proxyPath="/blodemd-internal/proxy"
|
|
102
|
-
/>
|
|
103
|
-
);
|
|
104
|
-
rawContent = shell.openApiEntry.operation.description ?? "";
|
|
105
|
-
} else if (shell.kind === "index") {
|
|
106
|
-
content = (
|
|
107
|
-
<CollectionIndex basePath="" entries={shell.collectionIndex.entries} />
|
|
108
|
-
);
|
|
109
|
-
} else {
|
|
110
|
-
({ rawContent } = shell);
|
|
111
|
-
({ toc } = shell);
|
|
112
|
-
const rendered = await getDocPageContent(slugKey);
|
|
113
|
-
content = rendered?.content ?? null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<DocShell
|
|
118
|
-
activeTabIndex={shell.activeTabIndex}
|
|
119
|
-
anchors={shell.anchors}
|
|
120
|
-
basePath=""
|
|
121
|
-
breadcrumbs={shell.breadcrumbs}
|
|
122
|
-
config={shell.config}
|
|
123
|
-
content={content}
|
|
124
|
-
currentPath={shell.currentPath}
|
|
125
|
-
deprecated={shell.deprecated}
|
|
126
|
-
hideFooterPagination={shell.hideFooterPagination}
|
|
127
|
-
mode={shell.mode}
|
|
128
|
-
nav={shell.nav}
|
|
129
|
-
nextPage={shell.nextPage}
|
|
130
|
-
pageDescription={shell.pageDescription}
|
|
131
|
-
pageTitle={shell.pageTitle}
|
|
132
|
-
prevPage={shell.prevPage}
|
|
133
|
-
rawContent={rawContent}
|
|
134
|
-
tabs={shell.tabs}
|
|
135
|
-
toc={toc}
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export default PreviewPage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { bumpDevVersion } from "@dev/lib/dev-state";
|
|
2
|
-
import { clearLocalRuntimeCaches } from "@dev/lib/local-runtime";
|
|
3
|
-
import { NextResponse } from "next/server";
|
|
4
|
-
|
|
5
|
-
export const dynamic = "force-dynamic";
|
|
6
|
-
|
|
7
|
-
export const POST = () => {
|
|
8
|
-
clearLocalRuntimeCaches();
|
|
9
|
-
const version = bumpDevVersion();
|
|
10
|
-
|
|
11
|
-
return NextResponse.json({ ok: true, version });
|
|
12
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getStaticAssetContentType,
|
|
3
|
-
readStaticAsset,
|
|
4
|
-
} from "@dev/lib/local-content-source";
|
|
5
|
-
import { NextResponse } from "next/server";
|
|
6
|
-
|
|
7
|
-
export const dynamic = "force-dynamic";
|
|
8
|
-
|
|
9
|
-
export const GET = async (
|
|
10
|
-
_request: Request,
|
|
11
|
-
{
|
|
12
|
-
params,
|
|
13
|
-
}: {
|
|
14
|
-
params: Promise<{ path: string[] }>;
|
|
15
|
-
}
|
|
16
|
-
) => {
|
|
17
|
-
const { path = [] } = await params;
|
|
18
|
-
const relativePath = path.join("/");
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const data = await readStaticAsset(relativePath);
|
|
22
|
-
|
|
23
|
-
return new NextResponse(data, {
|
|
24
|
-
headers: {
|
|
25
|
-
"Cache-Control": "no-store",
|
|
26
|
-
"Content-Type": getStaticAssetContentType(relativePath),
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
} catch {
|
|
30
|
-
return new NextResponse("Not found", { status: 404 });
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getDevVersion } from "@dev/lib/dev-state";
|
|
2
|
-
import { NextResponse } from "next/server";
|
|
3
|
-
|
|
4
|
-
export const dynamic = "force-dynamic";
|
|
5
|
-
|
|
6
|
-
export const GET = () =>
|
|
7
|
-
NextResponse.json(
|
|
8
|
-
{ version: getDevVersion() },
|
|
9
|
-
{
|
|
10
|
-
headers: {
|
|
11
|
-
"Cache-Control": "no-store",
|
|
12
|
-
},
|
|
13
|
-
}
|
|
14
|
-
);
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { getOpenApiProxyContext } from "@dev/lib/local-runtime";
|
|
2
|
-
import { NextResponse } from "next/server";
|
|
3
|
-
|
|
4
|
-
interface ProxyPayload {
|
|
5
|
-
body?: string;
|
|
6
|
-
headers?: Record<string, string>;
|
|
7
|
-
method: string;
|
|
8
|
-
url: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const jsonError = (error: string, status: number) =>
|
|
12
|
-
NextResponse.json({ error }, { status });
|
|
13
|
-
|
|
14
|
-
const resolveAllowedHosts = async () => {
|
|
15
|
-
const context = await getOpenApiProxyContext();
|
|
16
|
-
|
|
17
|
-
if (!context) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const configuredHosts = context.config.openapiProxy?.allowedHosts ?? [];
|
|
22
|
-
if (configuredHosts.length) {
|
|
23
|
-
return configuredHosts;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const derivedHosts = context.registry.entries.flatMap((entry) =>
|
|
27
|
-
(entry.spec.servers ?? []).flatMap((server) => {
|
|
28
|
-
try {
|
|
29
|
-
return [new URL(server.url).hostname];
|
|
30
|
-
} catch {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return [...new Set(derivedHosts)];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const POST = async (request: Request) => {
|
|
40
|
-
const payload = (await request.json()) as ProxyPayload;
|
|
41
|
-
|
|
42
|
-
if (!(payload?.url && payload?.method)) {
|
|
43
|
-
return jsonError("Invalid payload", 400);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const context = await getOpenApiProxyContext();
|
|
47
|
-
if (!context) {
|
|
48
|
-
return jsonError("Invalid docs configuration", 400);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!context.config.openapiProxy?.enabled) {
|
|
52
|
-
return jsonError("Proxy disabled", 403);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const url = new URL(payload.url);
|
|
56
|
-
if (!["http:", "https:"].includes(url.protocol)) {
|
|
57
|
-
return jsonError("Invalid protocol", 400);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const allowedHosts = await resolveAllowedHosts();
|
|
61
|
-
if (!allowedHosts?.length) {
|
|
62
|
-
return jsonError(
|
|
63
|
-
"No proxy allowlist is configured for this docs.json.",
|
|
64
|
-
403
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!allowedHosts.includes(url.hostname)) {
|
|
69
|
-
return jsonError("Host not allowed", 403);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const method = payload.method.toUpperCase();
|
|
73
|
-
const response = await fetch(payload.url, {
|
|
74
|
-
body: method === "GET" ? undefined : payload.body,
|
|
75
|
-
headers: payload.headers,
|
|
76
|
-
method,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const text = await response.text();
|
|
80
|
-
return new NextResponse(text, {
|
|
81
|
-
headers: {
|
|
82
|
-
"content-type": response.headers.get("content-type") ?? "text/plain",
|
|
83
|
-
},
|
|
84
|
-
status: response.status,
|
|
85
|
-
});
|
|
86
|
-
};
|
package/dev-server/app/error.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
const Error = ({
|
|
4
|
-
reset,
|
|
5
|
-
}: {
|
|
6
|
-
error: Error & { digest?: string };
|
|
7
|
-
reset: () => void;
|
|
8
|
-
}) => (
|
|
9
|
-
<div className="flex min-h-[60vh] flex-col items-center justify-center gap-4 px-4 text-center">
|
|
10
|
-
<h1 className="text-4xl font-bold tracking-tight">Something went wrong</h1>
|
|
11
|
-
<p className="max-w-md text-muted-foreground">
|
|
12
|
-
An error occurred while loading this page.
|
|
13
|
-
</p>
|
|
14
|
-
<button
|
|
15
|
-
className="mt-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
|
16
|
-
onClick={reset}
|
|
17
|
-
type="button"
|
|
18
|
-
>
|
|
19
|
-
Try again
|
|
20
|
-
</button>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export default Error;
|
|
Binary file
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DevReloadScript } from "@dev/components/dev-reload-script";
|
|
2
|
-
import { Providers } from "@dev/components/providers";
|
|
3
|
-
import { GeistMono } from "geist/font/mono";
|
|
4
|
-
import type { Metadata } from "next";
|
|
5
|
-
import localFont from "next/font/local";
|
|
6
|
-
|
|
7
|
-
import "./globals.css";
|
|
8
|
-
|
|
9
|
-
const glide = localFont({
|
|
10
|
-
display: "swap",
|
|
11
|
-
src: [{ path: "../public/glide-variable.woff2" }],
|
|
12
|
-
variable: "--font-glide",
|
|
13
|
-
weight: "400 900",
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const metadata: Metadata = {
|
|
17
|
-
description: "Local docs preview for blodemd dev.",
|
|
18
|
-
title: "blodemd dev",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default function RootLayout({
|
|
22
|
-
children,
|
|
23
|
-
}: Readonly<{
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
}>) {
|
|
26
|
-
return (
|
|
27
|
-
<html
|
|
28
|
-
lang="en"
|
|
29
|
-
className={`${glide.variable} ${GeistMono.variable}`}
|
|
30
|
-
suppressHydrationWarning
|
|
31
|
-
>
|
|
32
|
-
<body className="relative flex w-full flex-col justify-center overflow-x-hidden scroll-smooth bg-background font-sans antialiased [--header-height:calc(var(--spacing)*16)]">
|
|
33
|
-
<DevReloadScript />
|
|
34
|
-
<Providers>{children}</Providers>
|
|
35
|
-
</body>
|
|
36
|
-
</html>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
|
-
|
|
3
|
-
const NotFound = () => (
|
|
4
|
-
<div className="flex min-h-[60vh] flex-col items-center justify-center gap-4 px-4 text-center">
|
|
5
|
-
<h1 className="text-4xl font-bold tracking-tight">Page not found</h1>
|
|
6
|
-
<p className="max-w-md text-muted-foreground">
|
|
7
|
-
The page you are looking for does not exist or has been moved.
|
|
8
|
-
</p>
|
|
9
|
-
<Link
|
|
10
|
-
className="mt-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
|
11
|
-
href="/"
|
|
12
|
-
>
|
|
13
|
-
Go home
|
|
14
|
-
</Link>
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export default NotFound;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getSearchItems } from "@dev/lib/local-runtime";
|
|
2
|
-
import { NextResponse } from "next/server";
|
|
3
|
-
|
|
4
|
-
export const dynamic = "force-dynamic";
|
|
5
|
-
|
|
6
|
-
export const GET = async (): Promise<Response> => {
|
|
7
|
-
const items = await getSearchItems();
|
|
8
|
-
|
|
9
|
-
return NextResponse.json(
|
|
10
|
-
{ items },
|
|
11
|
-
{
|
|
12
|
-
headers: {
|
|
13
|
-
"Cache-Control": "no-store",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useRouter } from "next/navigation";
|
|
4
|
-
import { startTransition, useEffect, useRef } from "react";
|
|
5
|
-
|
|
6
|
-
const POLL_INTERVAL_MS = 1000;
|
|
7
|
-
|
|
8
|
-
const readVersion = async (): Promise<number | null> => {
|
|
9
|
-
try {
|
|
10
|
-
const response = await fetch("/blodemd-dev/version", {
|
|
11
|
-
cache: "no-store",
|
|
12
|
-
headers: {
|
|
13
|
-
accept: "application/json",
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const payload = (await response.json()) as { version?: number };
|
|
22
|
-
return typeof payload.version === "number" ? payload.version : null;
|
|
23
|
-
} catch {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const DevReloadScript = () => {
|
|
29
|
-
const router = useRouter();
|
|
30
|
-
const currentVersionRef = useRef<number | null>(null);
|
|
31
|
-
const refreshInFlightRef = useRef(false);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
let cancelled = false;
|
|
35
|
-
|
|
36
|
-
const poll = async () => {
|
|
37
|
-
if (document.visibilityState !== "visible") {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const version = await readVersion();
|
|
42
|
-
if (cancelled || version === null) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (currentVersionRef.current === null) {
|
|
47
|
-
currentVersionRef.current = version;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (version === currentVersionRef.current || refreshInFlightRef.current) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
currentVersionRef.current = version;
|
|
56
|
-
refreshInFlightRef.current = true;
|
|
57
|
-
|
|
58
|
-
startTransition(() => {
|
|
59
|
-
router.refresh();
|
|
60
|
-
window.setTimeout(() => {
|
|
61
|
-
refreshInFlightRef.current = false;
|
|
62
|
-
}, 150);
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const pollSafely = async () => {
|
|
67
|
-
try {
|
|
68
|
-
await poll();
|
|
69
|
-
} catch {
|
|
70
|
-
// Ignore transient polling errors during local dev.
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
pollSafely();
|
|
75
|
-
const interval = window.setInterval(() => {
|
|
76
|
-
pollSafely();
|
|
77
|
-
}, POLL_INTERVAL_MS);
|
|
78
|
-
|
|
79
|
-
return () => {
|
|
80
|
-
cancelled = true;
|
|
81
|
-
window.clearInterval(interval);
|
|
82
|
-
};
|
|
83
|
-
}, [router]);
|
|
84
|
-
|
|
85
|
-
return null;
|
|
86
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { ThemeProvider } from "next-themes";
|
|
4
|
-
|
|
5
|
-
export const Providers = ({ children }: { children: React.ReactNode }) => (
|
|
6
|
-
<ThemeProvider
|
|
7
|
-
attribute="class"
|
|
8
|
-
defaultTheme="system"
|
|
9
|
-
disableTransitionOnChange
|
|
10
|
-
enableColorScheme
|
|
11
|
-
storageKey="theme"
|
|
12
|
-
>
|
|
13
|
-
{children}
|
|
14
|
-
</ThemeProvider>
|
|
15
|
-
);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import { normalizePath } from "@repo/common";
|
|
5
|
-
import type { ContentSource } from "@repo/previewing";
|
|
6
|
-
import { createFsSource } from "@repo/previewing";
|
|
7
|
-
|
|
8
|
-
const BINARY_CONTENT_TYPES: Record<string, string> = {
|
|
9
|
-
".avif": "image/avif",
|
|
10
|
-
".gif": "image/gif",
|
|
11
|
-
".ico": "image/x-icon",
|
|
12
|
-
".jpeg": "image/jpeg",
|
|
13
|
-
".jpg": "image/jpeg",
|
|
14
|
-
".otf": "font/otf",
|
|
15
|
-
".png": "image/png",
|
|
16
|
-
".svg": "image/svg+xml",
|
|
17
|
-
".ttf": "font/ttf",
|
|
18
|
-
".webp": "image/webp",
|
|
19
|
-
".woff": "font/woff",
|
|
20
|
-
".woff2": "font/woff2",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const TEXT_CONTENT_TYPES: Record<string, string> = {
|
|
24
|
-
".css": "text/css; charset=utf-8",
|
|
25
|
-
".html": "text/html; charset=utf-8",
|
|
26
|
-
".js": "text/javascript; charset=utf-8",
|
|
27
|
-
".json": "application/json; charset=utf-8",
|
|
28
|
-
".md": "text/markdown; charset=utf-8",
|
|
29
|
-
".mdx": "text/markdown; charset=utf-8",
|
|
30
|
-
".txt": "text/plain; charset=utf-8",
|
|
31
|
-
".yaml": "application/yaml; charset=utf-8",
|
|
32
|
-
".yml": "application/yaml; charset=utf-8",
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const isWithinRoot = (root: string, candidate: string) =>
|
|
36
|
-
candidate === root || candidate.startsWith(`${root}${path.sep}`);
|
|
37
|
-
|
|
38
|
-
const getDocsRoot = () => {
|
|
39
|
-
const root = process.env.DOCS_ROOT?.trim();
|
|
40
|
-
|
|
41
|
-
if (!root) {
|
|
42
|
-
throw new Error("DOCS_ROOT is required for the local dev server.");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return path.resolve(root);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const resolveDocsPath = (relativePath: string) => {
|
|
49
|
-
const root = getDocsRoot();
|
|
50
|
-
const normalized = normalizePath(relativePath);
|
|
51
|
-
const absolutePath = path.resolve(root, normalized);
|
|
52
|
-
|
|
53
|
-
if (!isWithinRoot(root, absolutePath)) {
|
|
54
|
-
throw new Error(`Path "${relativePath}" escapes DOCS_ROOT.`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return absolutePath;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const toStaticAssetUrl = (relativePath: string) => {
|
|
61
|
-
const normalized = normalizePath(relativePath);
|
|
62
|
-
|
|
63
|
-
if (!normalized || normalized === ".") {
|
|
64
|
-
return "/blodemd-dev/static";
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return `/blodemd-dev/static/${normalized
|
|
68
|
-
.split("/")
|
|
69
|
-
.map((segment) => encodeURIComponent(segment))
|
|
70
|
-
.join("/")}`;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const createPreviewContentSource = (): ContentSource => {
|
|
74
|
-
const source = createFsSource(getDocsRoot());
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
exists(relativePath) {
|
|
78
|
-
return source.exists(relativePath);
|
|
79
|
-
},
|
|
80
|
-
listFiles(directory) {
|
|
81
|
-
return source.listFiles(directory);
|
|
82
|
-
},
|
|
83
|
-
readFile(relativePath) {
|
|
84
|
-
return source.readFile(relativePath);
|
|
85
|
-
},
|
|
86
|
-
resolveUrl(relativePath) {
|
|
87
|
-
return toStaticAssetUrl(relativePath);
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const readStaticAsset = async (relativePath: string) =>
|
|
93
|
-
await fs.readFile(resolveDocsPath(relativePath));
|
|
94
|
-
|
|
95
|
-
export const getStaticAssetContentType = (relativePath: string) => {
|
|
96
|
-
const extension = path.extname(relativePath).toLowerCase();
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
TEXT_CONTENT_TYPES[extension] ??
|
|
100
|
-
BINARY_CONTENT_TYPES[extension] ??
|
|
101
|
-
"application/octet-stream"
|
|
102
|
-
);
|
|
103
|
-
};
|