@lexibase/rdx-next 1.2.1 → 2.0.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/bin/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
2
|
import { createRequire } from 'node:module'
|
|
3
|
-
import { access, cp, mkdir } from 'node:fs/promises'
|
|
3
|
+
import { access, cp, mkdir, writeFile } from 'node:fs/promises'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
import process from 'node:process'
|
|
@@ -8,6 +8,7 @@ import process from 'node:process'
|
|
|
8
8
|
import { createRdxProject } from '@lexibase/rdx-core/config'
|
|
9
9
|
import { createJiti } from 'jiti'
|
|
10
10
|
|
|
11
|
+
import postcssConfig from '../postcss.config.mjs'
|
|
11
12
|
import { preparePublicAssets } from './public-assets.mjs'
|
|
12
13
|
|
|
13
14
|
export async function runRdxCli({ templateDir } = {}) {
|
|
@@ -30,6 +31,19 @@ export async function runRdxCli({ templateDir } = {}) {
|
|
|
30
31
|
force: true,
|
|
31
32
|
recursive: true,
|
|
32
33
|
})
|
|
34
|
+
// Resolve in Node before Next processes this file: UI may be transitive,
|
|
35
|
+
// and native Tailwind plugins must stay outside the Turbopack module graph.
|
|
36
|
+
const resolvePlugin = createRequire(import.meta.url)
|
|
37
|
+
const plugins = Object.fromEntries(
|
|
38
|
+
Object.entries(postcssConfig.plugins).map(([name, options]) => [
|
|
39
|
+
resolvePlugin.resolve(name),
|
|
40
|
+
options,
|
|
41
|
+
])
|
|
42
|
+
)
|
|
43
|
+
await writeFile(
|
|
44
|
+
path.join(runtimeDirectory, 'postcss.config.mjs'),
|
|
45
|
+
`export default ${JSON.stringify({ ...postcssConfig, plugins }, null, 2)}\n`
|
|
46
|
+
)
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
async function main() {
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { RdxProject, RDXConfig } from '@lexibase/rdx-types';
|
|
3
|
+
import { RdxProject, RDXConfig, RdxDocPage } from '@lexibase/rdx-types';
|
|
4
4
|
export { createRdxProject, getProjectDocsPaths } from '@lexibase/rdx-core';
|
|
5
5
|
import { Metadata } from 'next';
|
|
6
6
|
|
|
@@ -14,6 +14,8 @@ declare function getDocumentMetadata({ project, slug, }: {
|
|
|
14
14
|
project: RdxProject;
|
|
15
15
|
slug?: string[];
|
|
16
16
|
}): Metadata;
|
|
17
|
+
/** Keep page previews in sync while retaining the site's social images and options. */
|
|
18
|
+
declare function getPageMetadata(config: RDXConfig, page: Pick<RdxDocPage, 'title' | 'description'>): Metadata;
|
|
17
19
|
/** Translate the shared configuration through Next's native Metadata API. */
|
|
18
20
|
declare function getRdxMetadata(config: RDXConfig): Metadata;
|
|
19
21
|
|
|
@@ -25,9 +27,12 @@ declare function RdxLayout({ children, config, bodyClassName, }: {
|
|
|
25
27
|
declare function HomePage({ project }: {
|
|
26
28
|
project: RdxProject;
|
|
27
29
|
}): react.JSX.Element;
|
|
30
|
+
declare function NotFoundPage({ project }: {
|
|
31
|
+
project: RdxProject;
|
|
32
|
+
}): react.JSX.Element;
|
|
28
33
|
declare function DocsPage({ slug, project, }: {
|
|
29
34
|
slug?: string[];
|
|
30
35
|
project: RdxProject;
|
|
31
36
|
}): Promise<react.JSX.Element>;
|
|
32
37
|
|
|
33
|
-
export { DocsPage, HomePage, RdxLayout, getDocumentMetadata, getRdxMetadata, getSearchResponse, getSearchSources };
|
|
38
|
+
export { DocsPage, HomePage, NotFoundPage, RdxLayout, getDocumentMetadata, getPageMetadata, getRdxMetadata, getSearchResponse, getSearchSources };
|
package/dist/runtime/index.js
CHANGED
|
@@ -6,15 +6,17 @@ import {
|
|
|
6
6
|
resolveDocsRoute as resolveDocsRoute2
|
|
7
7
|
} from "@lexibase/rdx-core";
|
|
8
8
|
import { Button } from "@lexibase/rdx-ui/components/button";
|
|
9
|
-
import { ButtonLink } from "@lexibase/rdx-ui/components/button-link";
|
|
10
9
|
import { DocsSidebar } from "@lexibase/rdx-ui/components/docs-sidebar";
|
|
11
10
|
import { DocsToc } from "@lexibase/rdx-ui/components/docs-toc";
|
|
12
11
|
import { DocsSearch } from "@lexibase/rdx-ui/components/docs-search";
|
|
13
12
|
import { Home } from "@lexibase/rdx-ui/components/home";
|
|
14
13
|
import { FooterCredit } from "@lexibase/rdx-ui/components/footer-credit";
|
|
15
14
|
import { Logo } from "@lexibase/rdx-ui/components/logo";
|
|
16
|
-
import {
|
|
15
|
+
import { getMdxComponents } from "@lexibase/rdx-ui/components/mdx-components";
|
|
16
|
+
import { getMessages, formatMessage } from "@lexibase/rdx-ui/lib/i18n";
|
|
17
|
+
import { LocaleProvider } from "@lexibase/rdx-ui/providers/locale-provider";
|
|
17
18
|
import { Navbar } from "@lexibase/rdx-ui/components/navbar";
|
|
19
|
+
import { NotFound } from "@lexibase/rdx-ui/components/not-found";
|
|
18
20
|
import {
|
|
19
21
|
VersionDropdown
|
|
20
22
|
} from "@lexibase/rdx-ui/components/version-dropdown";
|
|
@@ -87,9 +89,16 @@ function getDocumentMetadata({
|
|
|
87
89
|
if (!route.slug) return {};
|
|
88
90
|
if (!route.document) notFound();
|
|
89
91
|
const page = route.categories.flatMap((category) => category.pages).find((page2) => page2.slug === route.slug);
|
|
92
|
+
return getPageMetadata(project.config, page);
|
|
93
|
+
}
|
|
94
|
+
function getPageMetadata(config, page) {
|
|
95
|
+
const title = page.title;
|
|
96
|
+
const description = page.description || config.description;
|
|
90
97
|
return {
|
|
91
|
-
title
|
|
92
|
-
description
|
|
98
|
+
title,
|
|
99
|
+
description,
|
|
100
|
+
openGraph: { ...config.metadata.openGraph, title, description },
|
|
101
|
+
twitter: { ...config.metadata.twitter, title, description }
|
|
93
102
|
};
|
|
94
103
|
}
|
|
95
104
|
function getRdxMetadata(config) {
|
|
@@ -125,17 +134,18 @@ function RdxLayout({
|
|
|
125
134
|
config,
|
|
126
135
|
bodyClassName
|
|
127
136
|
}) {
|
|
128
|
-
|
|
137
|
+
const messages = getMessages(config.lang);
|
|
138
|
+
return /* @__PURE__ */ jsx("html", { suppressHydrationWarning: true, lang: config.lang ?? "en", children: /* @__PURE__ */ jsx("body", { className: bodyClassName, children: /* @__PURE__ */ jsx(
|
|
129
139
|
ThemeProvider,
|
|
130
140
|
{
|
|
131
141
|
disableTransitionOnChange: true,
|
|
132
142
|
enableSystem: true,
|
|
133
143
|
attribute: "class",
|
|
134
144
|
defaultTheme: config.theme?.defaultTheme ?? "system",
|
|
135
|
-
children: [
|
|
136
|
-
/* @__PURE__ */ jsx("a", { className: "rdx-skip-link", href: "#rdx-main", children:
|
|
145
|
+
children: /* @__PURE__ */ jsxs(LocaleProvider, { lang: config.lang, children: [
|
|
146
|
+
/* @__PURE__ */ jsx("a", { className: "rdx-skip-link", href: "#rdx-main", children: messages.skipContent }),
|
|
137
147
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col h-dvh", children })
|
|
138
|
-
]
|
|
148
|
+
] })
|
|
139
149
|
}
|
|
140
150
|
) }) });
|
|
141
151
|
}
|
|
@@ -144,13 +154,14 @@ function RdxHeader({
|
|
|
144
154
|
slug
|
|
145
155
|
}) {
|
|
146
156
|
const { config } = project;
|
|
157
|
+
const messages = getMessages(config.lang);
|
|
147
158
|
const { source, slug: currentSlug } = resolveDocsRoute2(project, slug);
|
|
148
159
|
const options = project.sources.map((edition) => {
|
|
149
160
|
const docs = getSourceOptions2(project, edition);
|
|
150
161
|
const destination = currentSlug && getDocument2(currentSlug, docs) ? currentSlug : getDocsPaths(docs)[0];
|
|
151
162
|
return {
|
|
152
163
|
id: edition.id,
|
|
153
|
-
label: edition.id === "current" ?
|
|
164
|
+
label: edition.id === "current" ? messages.current : formatMessage(messages.version, { version: edition.label }),
|
|
154
165
|
kind: edition.id === "current" ? "live" : edition.badge === "Archived" ? "archived" : "version",
|
|
155
166
|
href: ["/docs", edition.routePrefix, destination].filter(Boolean).join("/")
|
|
156
167
|
};
|
|
@@ -159,12 +170,13 @@ function RdxHeader({
|
|
|
159
170
|
return /* @__PURE__ */ jsx(
|
|
160
171
|
Navbar,
|
|
161
172
|
{
|
|
173
|
+
lang: config.lang,
|
|
162
174
|
title: config.navbar?.title ?? "",
|
|
163
175
|
search: config.search ? /* @__PURE__ */ jsx(
|
|
164
176
|
DocsSearch,
|
|
165
177
|
{
|
|
166
178
|
indexUrl: `/rdx-search/${encodeURIComponent(source.routePrefix || "_")}`,
|
|
167
|
-
version: source.label
|
|
179
|
+
version: source.id === "current" ? messages.current : formatMessage(messages.version, { version: source.label })
|
|
168
180
|
}
|
|
169
181
|
) : void 0,
|
|
170
182
|
siteTitle: config.metadata.applicationName,
|
|
@@ -204,10 +216,17 @@ function HomePage({ project }) {
|
|
|
204
216
|
)
|
|
205
217
|
] });
|
|
206
218
|
}
|
|
219
|
+
function NotFoundPage({ project }) {
|
|
220
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221
|
+
/* @__PURE__ */ jsx(RdxHeader, { project }),
|
|
222
|
+
/* @__PURE__ */ jsx(NotFound, { lang: project.config.lang })
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
207
225
|
async function DocsPage({
|
|
208
226
|
slug,
|
|
209
227
|
project
|
|
210
228
|
}) {
|
|
229
|
+
const messages = getMessages(project.config.lang);
|
|
211
230
|
const {
|
|
212
231
|
source,
|
|
213
232
|
slug: currentSlug,
|
|
@@ -218,14 +237,14 @@ async function DocsPage({
|
|
|
218
237
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
219
238
|
/* @__PURE__ */ jsx(RdxHeader, { project, slug }),
|
|
220
239
|
/* @__PURE__ */ jsxs("main", { id: "rdx-main", tabIndex: -1, className: "p-8", children: [
|
|
221
|
-
/* @__PURE__ */ jsx("h1", { children:
|
|
222
|
-
/* @__PURE__ */ jsx("p", { children:
|
|
240
|
+
/* @__PURE__ */ jsx("h1", { children: messages.documentationReady }),
|
|
241
|
+
/* @__PURE__ */ jsx("p", { children: messages.addDocument })
|
|
223
242
|
] })
|
|
224
243
|
] });
|
|
225
244
|
if (!document) notFound2();
|
|
226
245
|
const { content } = await compileDocumentation(
|
|
227
246
|
document.content,
|
|
228
|
-
|
|
247
|
+
getMdxComponents(project.config.lang),
|
|
229
248
|
{
|
|
230
249
|
sourceRoot: getSourceOptions2(project, source).docsDir,
|
|
231
250
|
sourcePath: document.sourcePath,
|
|
@@ -274,7 +293,7 @@ async function DocsPage({
|
|
|
274
293
|
children: [
|
|
275
294
|
/* @__PURE__ */ jsxs("div", { className: "w-full flex flex-col gap-5 md:mx-auto md:max-w-[860px] pt-14 md:pt-0 flex-1", children: [
|
|
276
295
|
/* @__PURE__ */ jsxs("header", { className: "mb-6", children: [
|
|
277
|
-
source.badge && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4", children: source.badge }),
|
|
296
|
+
source.badge && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4", children: source.badge === "Archived" ? messages.archivedVersion : source.badge }),
|
|
278
297
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-zinc-600 font-semibold uppercase block -mb-0.5", children: category?.title }),
|
|
279
298
|
/* @__PURE__ */ jsx("h1", { className: "text-4xl uppercase font-bold mb-2", children: title }),
|
|
280
299
|
description && /* @__PURE__ */ jsx("p", { className: "text-sm text-ring max-w-[726px]", children: description })
|
|
@@ -292,27 +311,20 @@ async function DocsPage({
|
|
|
292
311
|
/* @__PURE__ */ jsxs("footer", { className: "flex flex-col", children: [
|
|
293
312
|
/* @__PURE__ */ jsxs("section", { className: "flex items-center justify-between", children: [
|
|
294
313
|
previous ? /* @__PURE__ */ jsx(
|
|
295
|
-
|
|
314
|
+
Button,
|
|
296
315
|
{
|
|
297
316
|
variant: "outline",
|
|
298
317
|
size: "sm",
|
|
299
318
|
href: hrefFor(previous.slug),
|
|
300
319
|
children: previous.title
|
|
301
320
|
}
|
|
302
|
-
) : /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", disabled: true, children:
|
|
303
|
-
next ? /* @__PURE__ */ jsx(
|
|
304
|
-
ButtonLink,
|
|
305
|
-
{
|
|
306
|
-
variant: "outline",
|
|
307
|
-
size: "sm",
|
|
308
|
-
href: hrefFor(next.slug),
|
|
309
|
-
children: next.title
|
|
310
|
-
}
|
|
311
|
-
) : /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", disabled: true, children: "Next" })
|
|
321
|
+
) : /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", disabled: true, children: messages.previous }),
|
|
322
|
+
next ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", href: hrefFor(next.slug), children: next.title }) : /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", disabled: true, children: messages.next })
|
|
312
323
|
] }),
|
|
313
324
|
/* @__PURE__ */ jsx(
|
|
314
325
|
FooterCredit,
|
|
315
326
|
{
|
|
327
|
+
lang: project.config.lang,
|
|
316
328
|
name: project.config.metadata.applicationName,
|
|
317
329
|
since: project.config.metadata.since
|
|
318
330
|
}
|
|
@@ -330,9 +342,11 @@ async function DocsPage({
|
|
|
330
342
|
export {
|
|
331
343
|
DocsPage,
|
|
332
344
|
HomePage,
|
|
345
|
+
NotFoundPage,
|
|
333
346
|
RdxLayout,
|
|
334
347
|
createRdxProject,
|
|
335
348
|
getDocumentMetadata,
|
|
349
|
+
getPageMetadata,
|
|
336
350
|
getProjectDocsPaths,
|
|
337
351
|
getRdxMetadata,
|
|
338
352
|
getSearchResponse,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/rdx-next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "The Next.js runtime for RDX documentation projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"next-mdx-remote": "^6.0.0",
|
|
52
52
|
"remark-gfm": "^4",
|
|
53
53
|
"typescript": "6.0.3",
|
|
54
|
-
"@lexibase/rdx-
|
|
55
|
-
"@lexibase/rdx-
|
|
54
|
+
"@lexibase/rdx-types": "1.1.1",
|
|
55
|
+
"@lexibase/rdx-core": "1.1.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@lexibase/rdx-ui": "^
|
|
58
|
+
"@lexibase/rdx-ui": "^2.0.0",
|
|
59
59
|
"next": "^16.4.2",
|
|
60
60
|
"react": "^19.3.1",
|
|
61
61
|
"react-dom": "^19.3.1"
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"next": "^16.4.2",
|
|
81
81
|
"react": "19.3.1",
|
|
82
82
|
"react-dom": "19.3.1",
|
|
83
|
-
"@
|
|
84
|
-
"@rdx
|
|
85
|
-
"@rdx/
|
|
83
|
+
"@rdx/eslint-config": "1.0.0",
|
|
84
|
+
"@lexibase/rdx-ui": "2.0.0",
|
|
85
|
+
"@rdx/typescript-config": "1.0.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"dev": "tsup src/index.ts src/runtime/index.tsx --format esm --dts --watch --external @lexibase/rdx-core --external @lexibase/rdx-types --external @lexibase/rdx-ui --external next --external react --external react-dom --external next-mdx-remote",
|