@supatent/supatent-docs 0.1.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/chunk-QVZFIUSH.js +13777 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +75 -0
- package/dist/next-config.d.ts +20 -0
- package/dist/next-config.js +305 -0
- package/dist/types-Cf4pRODK.d.ts +60 -0
- package/package.json +49 -0
- package/runtime/middleware.ts +52 -0
- package/runtime/src/app/[locale]/docs-internal/[[...slug]]/page.tsx +91 -0
- package/runtime/src/app/[locale]/docs-internal/ai/all/route.ts +52 -0
- package/runtime/src/app/[locale]/docs-internal/ai/index/route.ts +52 -0
- package/runtime/src/app/[locale]/docs-internal/markdown/[...slug]/route.ts +50 -0
- package/runtime/src/app/globals.css +1082 -0
- package/runtime/src/app/layout.tsx +37 -0
- package/runtime/src/app/page.tsx +26 -0
- package/runtime/src/components/code-group-enhancer.tsx +128 -0
- package/runtime/src/components/docs-shell.tsx +140 -0
- package/runtime/src/components/header-dropdown.tsx +138 -0
- package/runtime/src/components/icons.tsx +58 -0
- package/runtime/src/components/locale-switcher.tsx +97 -0
- package/runtime/src/components/mobile-docs-menu.tsx +208 -0
- package/runtime/src/components/site-header.tsx +44 -0
- package/runtime/src/components/site-search.tsx +358 -0
- package/runtime/src/components/theme-toggle.tsx +74 -0
- package/runtime/src/docs.config.ts +91 -0
- package/runtime/src/framework/config.ts +76 -0
- package/runtime/src/framework/errors.ts +34 -0
- package/runtime/src/framework/locales.ts +45 -0
- package/runtime/src/framework/markdown-search-text.ts +11 -0
- package/runtime/src/framework/navigation.ts +58 -0
- package/runtime/src/framework/next-config.ts +160 -0
- package/runtime/src/framework/rendering.ts +445 -0
- package/runtime/src/framework/repository.ts +255 -0
- package/runtime/src/framework/runtime-locales.ts +85 -0
- package/runtime/src/framework/search-index-types.ts +34 -0
- package/runtime/src/framework/search-index.ts +271 -0
- package/runtime/src/framework/service.ts +302 -0
- package/runtime/src/framework/settings.ts +43 -0
- package/runtime/src/framework/site-title.ts +54 -0
- package/runtime/src/framework/theme.ts +17 -0
- package/runtime/src/framework/types.ts +66 -0
- package/runtime/src/framework/url.ts +78 -0
- package/runtime/src/supatent/client.ts +2 -0
- package/src/index.ts +11 -0
- package/src/next-config.ts +5 -0
- package/src/next.ts +10 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { docsConfig } from "../../../../../docs.config";
|
|
3
|
+
import { isSupportedLocale } from "../../../../../framework/locales";
|
|
4
|
+
import { createDocsService } from "../../../../../framework/service";
|
|
5
|
+
import { getRuntimeLocales } from "../../../../../framework/runtime-locales";
|
|
6
|
+
|
|
7
|
+
type RouteParams = {
|
|
8
|
+
locale: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const dynamic = "force-dynamic";
|
|
12
|
+
|
|
13
|
+
export async function GET(
|
|
14
|
+
_request: Request,
|
|
15
|
+
context: { params: Promise<RouteParams> | RouteParams },
|
|
16
|
+
) {
|
|
17
|
+
const params = await Promise.resolve(context.params);
|
|
18
|
+
const runtimeLocales = await getRuntimeLocales({
|
|
19
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
20
|
+
});
|
|
21
|
+
const localeConfig = {
|
|
22
|
+
defaultLocale: runtimeLocales.defaultLocale,
|
|
23
|
+
locales: runtimeLocales.locales,
|
|
24
|
+
fallbackMode: docsConfig.routing.fallbackMode,
|
|
25
|
+
};
|
|
26
|
+
if (!isSupportedLocale(params.locale, localeConfig)) {
|
|
27
|
+
return NextResponse.json({ error: "Locale not found" }, { status: 404 });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const docsService = createDocsService(docsConfig, {
|
|
31
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
32
|
+
localeConfig,
|
|
33
|
+
});
|
|
34
|
+
const result = await docsService.getAiAll(params.locale);
|
|
35
|
+
if (!result) {
|
|
36
|
+
return NextResponse.json(
|
|
37
|
+
{
|
|
38
|
+
requestedLocale: params.locale,
|
|
39
|
+
pages: [],
|
|
40
|
+
},
|
|
41
|
+
{ status: 200 },
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return NextResponse.json(
|
|
46
|
+
{
|
|
47
|
+
generatedAt: new Date().toISOString(),
|
|
48
|
+
...result,
|
|
49
|
+
},
|
|
50
|
+
{ status: 200 },
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { docsConfig } from "../../../../../docs.config";
|
|
3
|
+
import { isSupportedLocale } from "../../../../../framework/locales";
|
|
4
|
+
import { createDocsService } from "../../../../../framework/service";
|
|
5
|
+
import { getRuntimeLocales } from "../../../../../framework/runtime-locales";
|
|
6
|
+
|
|
7
|
+
type RouteParams = {
|
|
8
|
+
locale: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const dynamic = "force-dynamic";
|
|
12
|
+
|
|
13
|
+
export async function GET(
|
|
14
|
+
_request: Request,
|
|
15
|
+
context: { params: Promise<RouteParams> | RouteParams },
|
|
16
|
+
) {
|
|
17
|
+
const params = await Promise.resolve(context.params);
|
|
18
|
+
const runtimeLocales = await getRuntimeLocales({
|
|
19
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
20
|
+
});
|
|
21
|
+
const localeConfig = {
|
|
22
|
+
defaultLocale: runtimeLocales.defaultLocale,
|
|
23
|
+
locales: runtimeLocales.locales,
|
|
24
|
+
fallbackMode: docsConfig.routing.fallbackMode,
|
|
25
|
+
};
|
|
26
|
+
if (!isSupportedLocale(params.locale, localeConfig)) {
|
|
27
|
+
return NextResponse.json({ error: "Locale not found" }, { status: 404 });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const docsService = createDocsService(docsConfig, {
|
|
31
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
32
|
+
localeConfig,
|
|
33
|
+
});
|
|
34
|
+
const result = await docsService.getAiIndex(params.locale);
|
|
35
|
+
if (!result) {
|
|
36
|
+
return NextResponse.json(
|
|
37
|
+
{
|
|
38
|
+
requestedLocale: params.locale,
|
|
39
|
+
pages: [],
|
|
40
|
+
},
|
|
41
|
+
{ status: 200 },
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return NextResponse.json(
|
|
46
|
+
{
|
|
47
|
+
generatedAt: new Date().toISOString(),
|
|
48
|
+
...result,
|
|
49
|
+
},
|
|
50
|
+
{ status: 200 },
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { docsConfig } from "../../../../../docs.config";
|
|
3
|
+
import { isSupportedLocale } from "../../../../../framework/locales";
|
|
4
|
+
import { createDocsService } from "../../../../../framework/service";
|
|
5
|
+
import { getRuntimeLocales } from "../../../../../framework/runtime-locales";
|
|
6
|
+
|
|
7
|
+
type RouteParams = {
|
|
8
|
+
locale: string;
|
|
9
|
+
slug: string[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const dynamic = "force-dynamic";
|
|
13
|
+
|
|
14
|
+
export async function GET(
|
|
15
|
+
_request: Request,
|
|
16
|
+
context: { params: Promise<RouteParams> | RouteParams },
|
|
17
|
+
) {
|
|
18
|
+
const params = await Promise.resolve(context.params);
|
|
19
|
+
const runtimeLocales = await getRuntimeLocales({
|
|
20
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
21
|
+
});
|
|
22
|
+
const localeConfig = {
|
|
23
|
+
defaultLocale: runtimeLocales.defaultLocale,
|
|
24
|
+
locales: runtimeLocales.locales,
|
|
25
|
+
fallbackMode: docsConfig.routing.fallbackMode,
|
|
26
|
+
};
|
|
27
|
+
if (!isSupportedLocale(params.locale, localeConfig)) {
|
|
28
|
+
return new NextResponse("Locale not found", { status: 404 });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const docsService = createDocsService(docsConfig, {
|
|
32
|
+
dataMode: docsConfig.supatent.dataMode,
|
|
33
|
+
localeConfig,
|
|
34
|
+
});
|
|
35
|
+
const slug = params.slug.join("/");
|
|
36
|
+
const pageResult = await docsService.getPage(params.locale, slug);
|
|
37
|
+
if (!pageResult) {
|
|
38
|
+
return new NextResponse("Page not found", { status: 404 });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return new NextResponse(pageResult.page.body, {
|
|
42
|
+
status: 200,
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "text/markdown; charset=utf-8",
|
|
45
|
+
"X-Docs-Requested-Locale": pageResult.requestedLocale,
|
|
46
|
+
"X-Docs-Resolved-Locale": pageResult.resolvedLocale,
|
|
47
|
+
"X-Docs-Fallback-Used": String(pageResult.usedFallback),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|