@lexibase/rdx-next 1.0.0 → 1.0.1

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.
@@ -9,6 +9,11 @@ declare function getSearchSources(project: RdxProject): {
9
9
  }[];
10
10
  declare function getSearchResponse(project: RdxProject, key: string): Response;
11
11
 
12
+ /** Read metadata from the same content source and index used by the page. */
13
+ declare function getDocumentMetadata({ project, slug, }: {
14
+ project: RdxProject;
15
+ slug?: string[];
16
+ }): Metadata;
12
17
  /** Translate the shared configuration through Next's native Metadata API. */
13
18
  declare function getRdxMetadata(config: RDXConfig): Metadata;
14
19
 
@@ -25,4 +30,4 @@ declare function DocsPage({ slug, project, }: {
25
30
  project: RdxProject;
26
31
  }): Promise<react.JSX.Element>;
27
32
 
28
- export { DocsPage, HomePage, RdxLayout, getRdxMetadata, getSearchResponse, getSearchSources };
33
+ export { DocsPage, HomePage, RdxLayout, getDocumentMetadata, getRdxMetadata, getSearchResponse, getSearchSources };
@@ -3,7 +3,7 @@ import {
3
3
  getDocument as getDocument2,
4
4
  getDocsPaths,
5
5
  getSourceOptions as getSourceOptions2,
6
- resolveDocsRoute
6
+ resolveDocsRoute as resolveDocsRoute2
7
7
  } from "@lexibase/rdx-core";
8
8
  import { Button } from "@lexibase/rdx-ui/components/button";
9
9
  import { ButtonLink } from "@lexibase/rdx-ui/components/button-link";
@@ -18,7 +18,7 @@ import {
18
18
  VersionDropdown
19
19
  } from "@lexibase/rdx-ui/components/version-dropdown";
20
20
  import { ThemeProvider } from "@lexibase/rdx-ui/providers/theme-provider";
21
- import { notFound, redirect } from "next/navigation";
21
+ import { notFound as notFound2, redirect } from "next/navigation";
22
22
 
23
23
  // src/runtime/mdx.ts
24
24
  import { compileMDX } from "next-mdx-remote/rsc";
@@ -76,6 +76,21 @@ function getSearchResponse(project, key) {
76
76
  }
77
77
 
78
78
  // src/runtime/metadata.ts
79
+ import { resolveDocsRoute } from "@lexibase/rdx-core";
80
+ import { notFound } from "next/navigation";
81
+ function getDocumentMetadata({
82
+ project,
83
+ slug
84
+ }) {
85
+ const route = resolveDocsRoute(project, slug);
86
+ if (!route.slug) return {};
87
+ if (!route.document) notFound();
88
+ const page = route.categories.flatMap((category) => category.pages).find((page2) => page2.slug === route.slug);
89
+ return {
90
+ title: page.title,
91
+ description: page.description || project.config.description
92
+ };
93
+ }
79
94
  function getRdxMetadata(config) {
80
95
  const { metadataBase, ...metadata } = config.metadata;
81
96
  const name = metadata.applicationName;
@@ -127,7 +142,7 @@ function RdxHeader({
127
142
  slug
128
143
  }) {
129
144
  const { config } = project;
130
- const { source, slug: currentSlug } = resolveDocsRoute(project, slug);
145
+ const { source, slug: currentSlug } = resolveDocsRoute2(project, slug);
131
146
  const options = project.sources.map((edition) => {
132
147
  const docs = getSourceOptions2(project, edition);
133
148
  const destination = currentSlug && getDocument2(currentSlug, docs) ? currentSlug : getDocsPaths(docs)[0];
@@ -196,7 +211,7 @@ async function DocsPage({
196
211
  slug: currentSlug,
197
212
  document,
198
213
  categories
199
- } = resolveDocsRoute(project, slug);
214
+ } = resolveDocsRoute2(project, slug);
200
215
  if (!currentSlug)
201
216
  return /* @__PURE__ */ jsxs(Fragment, { children: [
202
217
  /* @__PURE__ */ jsx(RdxHeader, { project, slug }),
@@ -205,7 +220,7 @@ async function DocsPage({
205
220
  /* @__PURE__ */ jsx("p", { children: "Add an .mdx file inside your configured documentation directory." })
206
221
  ] })
207
222
  ] });
208
- if (!document) notFound();
223
+ if (!document) notFound2();
209
224
  const { content } = await compileDocumentation(
210
225
  document.content,
211
226
  mdxComponents,
@@ -314,6 +329,7 @@ export {
314
329
  HomePage,
315
330
  RdxLayout,
316
331
  createRdxProject,
332
+ getDocumentMetadata,
317
333
  getProjectDocsPaths,
318
334
  getRdxMetadata,
319
335
  getSearchResponse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexibase/rdx-next",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "The Next.js runtime for RDX documentation projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,9 +46,9 @@
46
46
  "next-mdx-remote": "^6.0.0",
47
47
  "remark-gfm": "^4",
48
48
  "typescript": "6.0.3",
49
+ "@lexibase/rdx-types": "1.0.0",
49
50
  "@lexibase/rdx-core": "1.0.0",
50
- "@lexibase/rdx-ui": "1.0.0",
51
- "@lexibase/rdx-types": "1.0.0"
51
+ "@lexibase/rdx-ui": "1.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "next": "^16.4.2",
@@ -1,7 +1,21 @@
1
- import { DocsPage, getProjectDocsPaths } from '@lexibase/rdx-next/runtime'
1
+ import type { Metadata } from 'next'
2
+ import {
3
+ DocsPage,
4
+ getDocumentMetadata,
5
+ getProjectDocsPaths,
6
+ } from '@lexibase/rdx-next/runtime'
2
7
 
3
8
  import { getProject } from '../../../rdx-project'
4
9
 
10
+ export async function generateMetadata({
11
+ params,
12
+ }: {
13
+ params: Promise<{ slug?: string[] }>
14
+ }): Promise<Metadata> {
15
+ const { slug } = await params
16
+ return getDocumentMetadata({ project: await getProject(), slug })
17
+ }
18
+
5
19
  export async function generateStaticParams() {
6
20
  return getProjectDocsPaths(await getProject()).map((slug) => ({
7
21
  slug: slug.split('/'),