@patternfly/patternfly-doc-core 1.21.0 → 1.21.2
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/.astro/content-modules.mjs +73 -73
- package/dist/apiIndex.json +4600 -4600
- package/dist/docs/_worker.js/chunks/{case_DpEzu_9Y.mjs → case_DUYSM3-g.mjs} +19 -6
- package/dist/docs/_worker.js/chunks/fetch_C_ctcuMR.mjs +11 -0
- package/dist/docs/_worker.js/index.js +9 -7
- package/dist/docs/_worker.js/manifest_BuX17AvF.mjs +100 -0
- package/dist/docs/_worker.js/pages/api/_version_/_section_/_page_/props.astro.mjs +6 -12
- package/dist/docs/_worker.js/pages/api/_version_/_section_/names.astro.mjs +3 -9
- package/dist/docs/_worker.js/pages/props.astro.mjs +21 -13
- package/dist/docs/_worker.js/pages/props.json.astro.mjs +1 -0
- package/dist/docs/apiIndex.json +4600 -4600
- package/dist/docs/components/about-modal/html/index.html +8 -8
- package/dist/docs/components/about-modal/html-demos/index.html +4 -4
- package/dist/docs/components/about-modal/index.html +8 -8
- package/dist/docs/components/accordion/html/index.html +25 -25
- package/dist/docs/components/accordion/react/index.html +10 -10
- package/dist/docs/components/action-list/html/index.html +11 -11
- package/dist/docs/components/action-list/react/index.html +9 -9
- package/dist/docs/components/alert/html/index.html +31 -31
- package/dist/docs/components/alert/html-demos/index.html +10 -10
- package/dist/docs/components/avatar/html/index.html +16 -16
- package/dist/docs/components/back-to-top/html/index.html +9 -9
- package/dist/docs/components/back-to-top/html-demos/index.html +4 -4
- package/dist/docs/components/back-to-top/index.html +8 -8
- package/dist/docs/components/back-to-top/react/index.html +8 -8
- package/dist/docs/components/backdrop/html/index.html +11 -11
- package/dist/docs/components/backdrop/index.html +6 -6
- package/dist/docs/components/backdrop/react/index.html +3 -3
- package/dist/docs/components/background-image/react/index.html +6 -6
- package/dist/docs/components/badge/html/index.html +12 -12
- package/dist/docs/components/badge/index.html +8 -8
- package/dist/docs/components/banner/html/index.html +12 -12
- package/dist/docs/components/banner/html-demos/index.html +9 -9
- package/dist/docs/components/banner/index.html +11 -11
- package/dist/docs/components/brand/html/index.html +13 -13
- package/dist/docs/components/brand/index.html +9 -9
- package/dist/docs/components/brand/react/index.html +9 -9
- package/dist/docs/components/breadcrumb/html/index.html +18 -18
- package/dist/docs/components/breadcrumb/index.html +9 -9
- package/dist/docs/components/breadcrumb/react/index.html +6 -6
- package/dist/docs/components/button/html-demos/index.html +8 -8
- package/dist/docs/components/button/react/index.html +44 -44
- package/dist/docs/components/calendar-month/react/index.html +9 -9
- package/dist/docs/components/card/html/index.html +40 -40
- package/dist/docs/components/card/html-demos/index.html +25 -25
- package/dist/docs/components/card/index.html +56 -56
- package/dist/docs/components/checkbox/html/index.html +18 -18
- package/dist/docs/components/checkbox/index.html +13 -13
- package/dist/docs/components/clipboard-copy/html/index.html +15 -15
- package/dist/docs/components/clipboard-copy/index.html +18 -18
- package/dist/docs/components/clipboard-copy/react/index.html +18 -18
- package/dist/docs/components/code-block/react/index.html +9 -9
- package/dist/docs/components/code-editor/html/index.html +13 -13
- package/dist/docs/components/code-editor/index.html +13 -13
- package/dist/docs/components/content/html/index.html +18 -18
- package/dist/docs/components/content/index.html +16 -16
- package/dist/docs/components/data-list/html/index.html +38 -38
- package/dist/docs/components/data-list/html-demos/index.html +12 -12
- package/dist/docs/components/data-list/index.html +21 -21
- package/dist/docs/components/data-list/react/index.html +24 -24
- package/dist/docs/components/date-picker/html/index.html +11 -11
- package/dist/docs/components/date-picker/index.html +14 -14
- package/dist/docs/components/date-picker/react/index.html +17 -17
- package/dist/docs/components/description-list/html/index.html +41 -41
- package/dist/docs/components/description-list/html-demos/index.html +11 -11
- package/dist/docs/components/description-list/index.html +36 -36
- package/dist/docs/components/divider/html/index.html +18 -18
- package/dist/docs/components/divider/index.html +11 -11
- package/dist/docs/components/drawer/html-demos/index.html +13 -13
- package/dist/docs/components/dual-list-selector/react/index.html +20 -20
- package/dist/docs/components/dual-list-selector/react-deprecated/index.html +28 -28
- package/dist/docs/components/empty-state/react/index.html +13 -13
- package/dist/docs/components/expandable-section/html/index.html +17 -17
- package/dist/docs/components/expandable-section/index.html +19 -19
- package/dist/docs/components/form/html/index.html +16 -16
- package/dist/docs/components/form/html-demos/index.html +6 -6
- package/dist/docs/components/form/index.html +16 -16
- package/dist/docs/components/form-control/html/index.html +12 -12
- package/dist/docs/components/form-control/index.html +12 -12
- package/dist/docs/components/helper-text/html-demos/index.html +4 -4
- package/dist/docs/components/input-group/react/index.html +12 -12
- package/dist/docs/components/jump-links/html-demos/index.html +13 -13
- package/dist/docs/components/jump-links/react/index.html +12 -12
- package/dist/docs/components/label/html/index.html +44 -44
- package/dist/docs/components/label/index.html +28 -28
- package/dist/docs/components/list/html/index.html +16 -16
- package/dist/docs/components/list/index.html +12 -12
- package/dist/docs/components/login-page/html/index.html +17 -17
- package/dist/docs/components/login-page/index.html +13 -13
- package/dist/docs/components/login-page/react/index.html +13 -13
- package/dist/docs/components/masthead/html/index.html +13 -13
- package/dist/docs/components/masthead/html-demos/index.html +20 -20
- package/dist/docs/components/masthead/index.html +18 -18
- package/dist/docs/components/masthead/react/index.html +18 -18
- package/dist/docs/components/modal/html-demos/index.html +13 -13
- package/dist/docs/components/modal/react/index.html +38 -38
- package/dist/docs/components/modal/react-deprecated/index.html +41 -41
- package/dist/docs/components/multiple-file-upload/react/index.html +29 -29
- package/dist/docs/components/navigation/html-demos/index.html +13 -13
- package/dist/docs/components/navigation/react/index.html +21 -21
- package/dist/docs/components/notification-badge/index.html +13 -13
- package/dist/docs/components/notification-badge/react/index.html +13 -13
- package/dist/docs/components/notification-drawer/html-demos/index.html +13 -13
- package/dist/docs/components/notification-drawer/react/index.html +8 -8
- package/dist/docs/components/overflow-menu/react/index.html +12 -12
- package/dist/docs/components/page/html-demos/index.html +35 -35
- package/dist/docs/components/password-generator/html-demos/index.html +7 -7
- package/dist/docs/components/password-generator/index.html +7 -7
- package/dist/docs/components/password-strength/html-demos/index.html +10 -10
- package/dist/docs/components/password-strength/index.html +10 -10
- package/dist/docs/components/popover/react/index.html +23 -23
- package/dist/docs/components/progress-stepper/react/index.html +16 -16
- package/dist/docs/components/radio/react/index.html +15 -15
- package/dist/docs/components/search-input/index.html +15 -15
- package/dist/docs/components/search-input/react/index.html +15 -15
- package/dist/docs/components/simple-file-upload/html/index.html +12 -12
- package/dist/docs/components/simple-file-upload/index.html +29 -29
- package/dist/docs/components/skeleton/html-demos/index.html +3 -3
- package/dist/docs/components/table/html/index.html +129 -129
- package/dist/docs/components/table/html-demos/index.html +33 -33
- package/dist/docs/components/tabs/html/index.html +64 -64
- package/dist/docs/components/tabs/html-demos/index.html +13 -13
- package/dist/docs/components/tabs/index.html +74 -74
- package/dist/docs/components/text-input/index.html +13 -13
- package/dist/docs/components/text-input/react/index.html +13 -13
- package/dist/docs/components/text-input-group/html/index.html +24 -24
- package/dist/docs/components/text-input-group/index.html +16 -16
- package/dist/docs/components/text-input-group/react/index.html +16 -16
- package/dist/docs/components/tile/html-deprecated/index.html +11 -11
- package/dist/docs/components/tile/index.html +26 -26
- package/dist/docs/components/tile/react-deprecated/index.html +23 -23
- package/dist/docs/components/time-picker/index.html +13 -13
- package/dist/docs/components/time-picker/react/index.html +13 -13
- package/dist/docs/components/timestamp/react/index.html +21 -21
- package/dist/docs/components/title/html/index.html +13 -13
- package/dist/docs/components/title/index.html +7 -7
- package/dist/docs/components/title/react/index.html +7 -7
- package/dist/docs/components/toggle-group/html/index.html +12 -12
- package/dist/docs/components/toggle-group/index.html +21 -21
- package/dist/docs/components/toggle-group/react/index.html +21 -21
- package/dist/docs/components/toolbar/html-demos/index.html +15 -15
- package/dist/docs/components/toolbar/react/index.html +42 -42
- package/dist/docs/components/tooltip/react/index.html +9 -9
- package/dist/docs/components/tree-view/react/index.html +20 -20
- package/dist/docs/components/truncate/html/index.html +13 -13
- package/dist/docs/components/truncate/index.html +19 -19
- package/dist/docs/components/truncate/react/index.html +19 -19
- package/dist/docs/components/wizard/html/index.html +29 -29
- package/dist/docs/components/wizard/html-demos/index.html +22 -22
- package/dist/docs/components/wizard/index.html +32 -32
- package/dist/docs/extensions/quick-starts/Basic-quick-starts/index.html +11 -11
- package/dist/docs/extensions/quick-starts/about/index.html +43 -43
- package/dist/docs/layouts/bullseye/html/index.html +8 -8
- package/dist/docs/layouts/bullseye/index.html +8 -8
- package/dist/docs/layouts/flex/html/index.html +87 -87
- package/dist/docs/layouts/flex/index.html +87 -87
- package/dist/docs/layouts/gallery/html/index.html +17 -17
- package/dist/docs/layouts/gallery/index.html +17 -17
- package/dist/docs/layouts/grid/html/index.html +25 -25
- package/dist/docs/layouts/grid/index.html +25 -25
- package/dist/docs/layouts/level/html/index.html +13 -13
- package/dist/docs/layouts/level/index.html +13 -13
- package/dist/docs/layouts/split/html/index.html +10 -10
- package/dist/docs/layouts/split/index.html +10 -10
- package/dist/docs/layouts/stack/html/index.html +9 -9
- package/dist/docs/layouts/stack/index.html +9 -9
- package/dist/docs/patterns/card-view/html-demos/index.html +4 -4
- package/dist/docs/patterns/card-view/index.html +4 -4
- package/dist/docs/patterns/dashboard/html-demos/index.html +4 -4
- package/dist/docs/patterns/dashboard/index.html +4 -4
- package/dist/docs/patterns/primary-detail/html-demos/index.html +20 -20
- package/dist/docs/patterns/primary-detail/index.html +20 -20
- package/dist/docs/props.json +1 -0
- package/dist/docs/utility-classes/accessibility/html/index.html +8 -8
- package/dist/docs/utility-classes/accessibility/index.html +8 -8
- package/dist/docs/utility-classes/alignment/html/index.html +7 -7
- package/dist/docs/utility-classes/alignment/index.html +7 -7
- package/dist/docs/utility-classes/background-color/html/index.html +9 -9
- package/dist/docs/utility-classes/background-color/index.html +9 -9
- package/dist/docs/utility-classes/box-shadow/html/index.html +12 -12
- package/dist/docs/utility-classes/box-shadow/index.html +12 -12
- package/dist/docs/utility-classes/display/html/index.html +18 -18
- package/dist/docs/utility-classes/display/index.html +18 -18
- package/dist/docs/utility-classes/flex/html/index.html +20 -20
- package/dist/docs/utility-classes/flex/index.html +17 -17
- package/dist/docs/utility-classes/float/html/index.html +10 -10
- package/dist/docs/utility-classes/float/index.html +7 -7
- package/dist/docs/utility-classes/sizing/html/index.html +28 -28
- package/dist/docs/utility-classes/sizing/index.html +31 -31
- package/dist/docs/utility-classes/spacing/html/index.html +12 -12
- package/dist/docs/utility-classes/spacing/index.html +15 -15
- package/dist/docs/utility-classes/text/html/index.html +18 -18
- package/dist/docs/utility-classes/text/index.html +21 -21
- package/dist/props.json +1 -1
- package/package.json +1 -1
- package/src/pages/api/[version]/[section]/[page]/[tab]/examples/[example].ts +22 -7
- package/src/pages/api/[version]/[section]/[page]/props.ts +8 -17
- package/src/pages/api/[version]/[section]/names.ts +3 -13
- package/src/pages/props.json.ts +25 -0
- package/src/pages/props.ts +23 -13
- package/src/utils/apiRoutes/collections.ts +15 -12
- package/src/utils/apiRoutes/contentMatching.ts +3 -3
- package/src/utils/propsData/fetch.ts +17 -0
- package/dist/docs/_worker.js/chunks/getConfig_DO3RhTb7.mjs +0 -18
- package/dist/docs/_worker.js/manifest_C79qK6PB.mjs +0 -100
- /package/dist/docs/_worker.js/chunks/{_astro_data-layer-content_Ben5jzFH.mjs → _astro_data-layer-content_DNxmV9Mk.mjs} +0 -0
- /package/dist/docs/_worker.js/chunks/{content-modules_BdvZI27c.mjs → content-modules_Dm0LakjO.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import type { APIRoute, GetStaticPaths } from 'astro'
|
|
3
|
-
import { readFile } from 'fs/promises'
|
|
4
|
-
import { resolve } from 'path'
|
|
3
|
+
import { access, readFile } from 'fs/promises'
|
|
4
|
+
import { isAbsolute, resolve } from 'path'
|
|
5
5
|
import { createJsonResponse, createTextResponse } from '../../../../../../../utils/apiHelpers'
|
|
6
6
|
import { generateAndWriteApiIndex } from '../../../../../../../utils/apiIndex/generate'
|
|
7
7
|
import { getEnrichedCollections } from '../../../../../../../utils/apiRoutes/collections'
|
|
@@ -66,23 +66,38 @@ export const GET: APIRoute = async ({ params }) => {
|
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
68
|
const collections = await getEnrichedCollections(version)
|
|
69
|
-
const
|
|
69
|
+
const contentEntryMatch = findContentEntryFilePath(collections, {
|
|
70
70
|
section,
|
|
71
71
|
page,
|
|
72
72
|
tab
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
if (!
|
|
75
|
+
if (!contentEntryMatch) {
|
|
76
76
|
return createJsonResponse(
|
|
77
77
|
{ error: `Content entry not found for ${version}/${section}/${page}/${tab}` },
|
|
78
78
|
404
|
|
79
79
|
)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
const { filePath: contentEntryFilePath, base } = contentEntryMatch
|
|
83
|
+
|
|
84
|
+
// Resolve the content entry file path.
|
|
85
|
+
// In non-monorepo setups, filePath is relative to CWD and resolves directly.
|
|
86
|
+
// In monorepo setups, filePath may be relative to `base` instead of CWD.
|
|
87
|
+
// We try the original path first, then fall back to resolve(base, filePath).
|
|
88
|
+
let resolvedContentPath = contentEntryFilePath
|
|
89
|
+
if (base && !isAbsolute(contentEntryFilePath)) {
|
|
90
|
+
try {
|
|
91
|
+
await access(contentEntryFilePath)
|
|
92
|
+
} catch {
|
|
93
|
+
resolvedContentPath = resolve(base, contentEntryFilePath)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
// Read content entry file to extract imports
|
|
83
98
|
let contentEntryFileContent: string
|
|
84
99
|
try {
|
|
85
|
-
contentEntryFileContent = await readFile(
|
|
100
|
+
contentEntryFileContent = await readFile(resolvedContentPath, 'utf8')
|
|
86
101
|
} catch (error) {
|
|
87
102
|
const details = error instanceof Error ? error.message : String(error)
|
|
88
103
|
return createJsonResponse(
|
|
@@ -110,8 +125,8 @@ export const GET: APIRoute = async ({ params }) => {
|
|
|
110
125
|
// Strip query parameters (like ?raw) from the file path before reading
|
|
111
126
|
const cleanFilePath = relativeExampleFilePath.split('?')[0]
|
|
112
127
|
|
|
113
|
-
// Read example file
|
|
114
|
-
const absoluteExampleFilePath = resolve(
|
|
128
|
+
// Read example file, resolving relative to the content entry file's directory
|
|
129
|
+
const absoluteExampleFilePath = resolve(resolvedContentPath, '../', cleanFilePath)
|
|
115
130
|
let exampleFileContent: string
|
|
116
131
|
try {
|
|
117
132
|
exampleFileContent = await readFile(absoluteExampleFilePath, 'utf8')
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { APIRoute } from 'astro'
|
|
2
|
+
import { pascalCase } from 'change-case'
|
|
3
|
+
|
|
2
4
|
import { createJsonResponse } from '../../../../../utils/apiHelpers'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { readFileSync } from 'node:fs'
|
|
6
|
-
import { sentenceCase, removeSubsection } from '../../../../../utils/case'
|
|
5
|
+
import { fetchProps } from '../../../../../utils/propsData/fetch'
|
|
6
|
+
import { removeSubsection } from '../../../../../utils/case'
|
|
7
7
|
|
|
8
8
|
export const prerender = false
|
|
9
9
|
|
|
10
|
-
export const GET: APIRoute = async ({ params }) => {
|
|
10
|
+
export const GET: APIRoute = async ({ params, url }) => {
|
|
11
11
|
const { page } = params
|
|
12
12
|
|
|
13
13
|
if (!page) {
|
|
@@ -18,14 +18,8 @@ export const GET: APIRoute = async ({ params }) => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const propsFilePath = join(outputDir, 'props.json')
|
|
25
|
-
const propsDataFile = readFileSync(propsFilePath)
|
|
26
|
-
const props = JSON.parse(propsDataFile.toString())
|
|
27
|
-
|
|
28
|
-
const propsData = props[sentenceCase(removeSubsection(page))]
|
|
21
|
+
const props = await fetchProps(url)
|
|
22
|
+
const propsData = props[pascalCase(removeSubsection(page))]
|
|
29
23
|
|
|
30
24
|
if (propsData === undefined) {
|
|
31
25
|
return createJsonResponse(
|
|
@@ -39,11 +33,8 @@ export const GET: APIRoute = async ({ params }) => {
|
|
|
39
33
|
} catch (error) {
|
|
40
34
|
const details = error instanceof Error ? error.message : String(error)
|
|
41
35
|
return createJsonResponse(
|
|
42
|
-
{ error: '
|
|
36
|
+
{ error: 'Failed to load props data', details },
|
|
43
37
|
500,
|
|
44
38
|
)
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import type { APIRoute } from 'astro'
|
|
2
2
|
import { createJsonResponse } from '../../../../utils/apiHelpers'
|
|
3
|
-
import {
|
|
4
|
-
import { join } from 'node:path'
|
|
5
|
-
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { fetchProps } from '../../../../utils/propsData/fetch'
|
|
6
4
|
|
|
7
5
|
export const prerender = false
|
|
8
6
|
|
|
9
|
-
export const GET: APIRoute = async ({ }) => {
|
|
7
|
+
export const GET: APIRoute = async ({ url }) => {
|
|
10
8
|
try {
|
|
11
|
-
const
|
|
12
|
-
const outputDir = config?.outputDir || join(process.cwd(), 'dist')
|
|
13
|
-
|
|
14
|
-
const propsFilePath = join(outputDir, 'props.json')
|
|
15
|
-
const propsDataFile = readFileSync(propsFilePath)
|
|
16
|
-
const props = JSON.parse(propsDataFile.toString())
|
|
9
|
+
const props = await fetchProps(url)
|
|
17
10
|
|
|
18
11
|
const propsKey = new RegExp("Props", 'i'); // ignore ComponentProps objects
|
|
19
12
|
const names = Object.keys(props).filter(name => !propsKey.test(name))
|
|
@@ -27,6 +20,3 @@ export const GET: APIRoute = async ({ }) => {
|
|
|
27
20
|
)
|
|
28
21
|
}
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { APIRoute } from 'astro'
|
|
2
|
+
import { readFile } from 'fs/promises'
|
|
3
|
+
import { join } from 'path'
|
|
4
|
+
import { getOutputDir } from '../utils/getOutputDir'
|
|
5
|
+
|
|
6
|
+
// Prerender at build time so this doesn't run in the Cloudflare Worker
|
|
7
|
+
export const prerender = true
|
|
8
|
+
|
|
9
|
+
export const GET: APIRoute = async () => {
|
|
10
|
+
try {
|
|
11
|
+
const outputDir = await getOutputDir()
|
|
12
|
+
const propsFilePath = join(outputDir, 'props.json')
|
|
13
|
+
const propsData = await readFile(propsFilePath, 'utf-8')
|
|
14
|
+
|
|
15
|
+
return new Response(propsData, {
|
|
16
|
+
status: 200,
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
} catch (error) {
|
|
22
|
+
const details = error instanceof Error ? error.message : String(error)
|
|
23
|
+
throw new Error(`Failed to prerender /props.json: ${details}`)
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/pages/props.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getConfig } from '../../cli/getConfig'
|
|
1
|
+
import { fetchProps } from '../utils/propsData/fetch'
|
|
2
|
+
import { createJsonResponse } from '../utils/apiHelpers'
|
|
4
3
|
|
|
5
4
|
export const prerender = false
|
|
6
5
|
|
|
7
6
|
export async function GET({ request }: { request: Request }) {
|
|
8
|
-
const
|
|
9
|
-
const outputDir = config?.outputDir || join(process.cwd(), 'dist')
|
|
7
|
+
const url = new URL(request.url)
|
|
10
8
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const components = url.searchParams.get('components')
|
|
10
|
+
if (!components) {
|
|
11
|
+
return createJsonResponse(
|
|
12
|
+
{ error: 'components query parameter is required' },
|
|
13
|
+
400,
|
|
14
|
+
)
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
try {
|
|
18
|
+
const props = await fetchProps(url)
|
|
19
|
+
const propsData = components
|
|
20
|
+
.split(',')
|
|
21
|
+
.map((component) => props[component.trim()])
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
return createJsonResponse(propsData)
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const details = error instanceof Error ? error.message : String(error)
|
|
26
|
+
return createJsonResponse(
|
|
27
|
+
{ error: 'Failed to load props data', details },
|
|
28
|
+
500,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
21
31
|
}
|
|
@@ -5,6 +5,7 @@ import { getDefaultTabForApi } from '../packageUtils'
|
|
|
5
5
|
|
|
6
6
|
export type EnrichedContentEntry = {
|
|
7
7
|
filePath: string
|
|
8
|
+
base?: string
|
|
8
9
|
data: {
|
|
9
10
|
tab: string
|
|
10
11
|
[key: string]: any
|
|
@@ -20,20 +21,22 @@ export type EnrichedContentEntry = {
|
|
|
20
21
|
* @returns Promise resolving to array of collection entries with enriched metadata
|
|
21
22
|
*/
|
|
22
23
|
export async function getEnrichedCollections(version: string): Promise<EnrichedContentEntry[]> {
|
|
23
|
-
const
|
|
24
|
-
.filter((entry) => entry.version === version)
|
|
25
|
-
.map((entry) => entry.name as CollectionKey)
|
|
24
|
+
const contentEntries = content.filter((entry) => entry.version === version)
|
|
26
25
|
|
|
27
26
|
const collections = await Promise.all(
|
|
28
|
-
|
|
27
|
+
contentEntries.map((entry) => getCollection(entry.name as CollectionKey))
|
|
29
28
|
)
|
|
30
29
|
|
|
31
|
-
return collections.
|
|
32
|
-
|
|
33
|
-
...rest
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
return collections.flatMap((collectionEntries, index) => {
|
|
31
|
+
const base = contentEntries[index].base
|
|
32
|
+
return collectionEntries.map(({ data, filePath = '', ...rest }) => ({
|
|
33
|
+
filePath,
|
|
34
|
+
base,
|
|
35
|
+
...rest,
|
|
36
|
+
data: {
|
|
37
|
+
...data,
|
|
38
|
+
tab: data.tab || data.source || getDefaultTabForApi(filePath),
|
|
39
|
+
},
|
|
40
|
+
}))
|
|
41
|
+
})
|
|
39
42
|
}
|
|
@@ -66,12 +66,12 @@ export function findContentEntry(
|
|
|
66
66
|
* @param entries - Array of enriched content entries to search
|
|
67
67
|
* @param params - Parameters to match against (section, page, tab)
|
|
68
68
|
* - page may be underscore-separated for subsection pages (e.g., "forms_checkbox")
|
|
69
|
-
* @returns
|
|
69
|
+
* @returns Object with filePath and optional base, or null if not found
|
|
70
70
|
*/
|
|
71
71
|
export function findContentEntryFilePath(
|
|
72
72
|
entries: EnrichedContentEntry[],
|
|
73
73
|
params: ContentMatchParams
|
|
74
|
-
): string | null {
|
|
74
|
+
): { filePath: string; base?: string } | null {
|
|
75
75
|
// Find all matching entries using shared matching logic
|
|
76
76
|
const matchingEntries = entries.filter((entry) => matchesParams(entry, params))
|
|
77
77
|
|
|
@@ -83,5 +83,5 @@ export function findContentEntryFilePath(
|
|
|
83
83
|
const mdxEntry = matchingEntries.find((entry) => entry.filePath.endsWith('.mdx'))
|
|
84
84
|
const selectedEntry = mdxEntry || matchingEntries[0]
|
|
85
85
|
|
|
86
|
-
return selectedEntry.filePath
|
|
86
|
+
return { filePath: selectedEntry.filePath, base: selectedEntry.base }
|
|
87
87
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the props data from the server as a static asset
|
|
3
|
+
* Used by API routes at runtime instead of reading from the filesystem
|
|
4
|
+
*
|
|
5
|
+
* @param url - The URL object from the API route context
|
|
6
|
+
* @returns Promise resolving to the props data structure
|
|
7
|
+
*/
|
|
8
|
+
export async function fetchProps(url: URL): Promise<Record<string, any>> {
|
|
9
|
+
const propsUrl = new URL('/props.json', url.origin)
|
|
10
|
+
const response = await fetch(propsUrl)
|
|
11
|
+
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new Error(`Failed to load props data: ${response.status} ${response.statusText}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return await response.json()
|
|
17
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
globalThis.process ??= {}; globalThis.process.env ??= {};
|
|
2
|
-
async function getConfig(fileLocation) {
|
|
3
|
-
try {
|
|
4
|
-
const { config } = await import(fileLocation);
|
|
5
|
-
return config;
|
|
6
|
-
} catch (e) {
|
|
7
|
-
if (["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"].includes(e.code)) {
|
|
8
|
-
console.error(
|
|
9
|
-
"pf-docs.config.mjs not found, have you created it at the root of your package?"
|
|
10
|
-
);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
console.error(e);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { getConfig as g };
|