@mintlify/prebuild 1.0.1453 → 1.0.1454
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.
|
@@ -77,6 +77,7 @@ function toGeneratedPage(page, config, directory, referenceSlugs, autogeneratedB
|
|
|
77
77
|
kind: page.target.kind,
|
|
78
78
|
name: page.target.name,
|
|
79
79
|
...(page.target.parent ? { parent: page.target.parent } : {}),
|
|
80
|
+
...(page.target.namespace ? { namespace: page.target.namespace } : {}),
|
|
80
81
|
}
|
|
81
82
|
: undefined;
|
|
82
83
|
return {
|
|
@@ -84,7 +85,7 @@ function toGeneratedPage(page, config, directory, referenceSlugs, autogeneratedB
|
|
|
84
85
|
title: page.title,
|
|
85
86
|
...(page.description ? { description: page.description } : {}),
|
|
86
87
|
...(page.tag ? { tag: page.tag } : {}),
|
|
87
|
-
content: prefixInternalLinks(
|
|
88
|
+
content: prefixInternalLinks(renderGeneratedBody(page, true), directory, referenceSlugs),
|
|
88
89
|
format: config.format,
|
|
89
90
|
source: config.source,
|
|
90
91
|
...(sdk ? { sdk } : {}),
|
|
@@ -283,8 +284,8 @@ export async function composeSdkFrontmatterPage(args) {
|
|
|
283
284
|
: slugDirectory
|
|
284
285
|
: (args.inherited.directory ?? DEFAULT_OUTPUT_DIR);
|
|
285
286
|
const referenceSlugs = new Set(reference.pages.map((entry) => entry.slug));
|
|
286
|
-
const generatedBody = prefixInternalLinks(stripLeadingDescription(page.content, page.description), directory, referenceSlugs);
|
|
287
287
|
const authorBody = stripFrontmatter(args.authorContent).trim();
|
|
288
|
+
const generatedBody = prefixInternalLinks(renderGeneratedBody(page, authorBody.length === 0), directory, referenceSlugs);
|
|
288
289
|
const content = [authorBody, generatedBody].filter(Boolean).join('\n\n');
|
|
289
290
|
return {
|
|
290
291
|
slug,
|
|
@@ -478,13 +479,25 @@ function assertSafeSlug(slug, config) {
|
|
|
478
479
|
throw new Error(`SDK reference ${config.format}:${config.source} produced an unsafe page slug "${slug}"`);
|
|
479
480
|
}
|
|
480
481
|
}
|
|
482
|
+
// Link text stops at the next bracket and a destination at the next paren, so
|
|
483
|
+
// each attempt ends at the next markup character and a chunk full of unclosed
|
|
484
|
+
// links costs linear time (destinations with nested parens are left as is).
|
|
481
485
|
function normalizeProse(text) {
|
|
482
486
|
return text
|
|
483
|
-
.replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
487
|
+
.replace(/!?\[([^\][\n]*)\]\([^()\n]*\)/g, '$1')
|
|
484
488
|
.replace(/[`*_\\]/g, '')
|
|
485
489
|
.replace(/\s+/g, ' ')
|
|
486
490
|
.trim();
|
|
487
491
|
}
|
|
492
|
+
// A page's intro (a package README, for instance) stands in for author prose,
|
|
493
|
+
// so an author who claims the page replaces it while the reference sections
|
|
494
|
+
// stay. The converter has already left the description out of the intro.
|
|
495
|
+
function renderGeneratedBody(page, withIntro) {
|
|
496
|
+
const body = stripLeadingDescription(page.content, page.description);
|
|
497
|
+
if (withIntro && page.intro)
|
|
498
|
+
return [page.intro, body].filter(Boolean).join('\n\n');
|
|
499
|
+
return body;
|
|
500
|
+
}
|
|
488
501
|
function stripLeadingDescription(content, description) {
|
|
489
502
|
if (!description)
|
|
490
503
|
return content;
|