@qualcomm-ui/mdx-vite 2.9.0 → 2.10.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/cli.js +194 -386
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/docs-plugin.d.ts.map +1 -1
- package/dist/docs-plugin/internal/config-schema.d.ts +4 -2
- package/dist/docs-plugin/internal/config-schema.d.ts.map +1 -1
- package/dist/docs-plugin/types.d.ts +10 -4
- package/dist/docs-plugin/types.d.ts.map +1 -1
- package/dist/index.js +126 -41
- package/dist/index.js.map +2 -2
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts +3 -2
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-plugin.d.ts","sourceRoot":"","sources":["../../src/docs-plugin/docs-plugin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,YAAY,EAAgC,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"docs-plugin.d.ts","sourceRoot":"","sources":["../../src/docs-plugin/docs-plugin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,YAAY,EAAgC,MAAM,MAAM,CAAA;AAyBrE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AA4OD,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,YAAY,CAsIvE"}
|
|
@@ -18,7 +18,8 @@ export declare const configSchema: z.ZodObject<{
|
|
|
18
18
|
extraFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
19
|
contents: z.ZodString;
|
|
20
20
|
id: z.ZodString;
|
|
21
|
-
|
|
21
|
+
processAsMdx: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
title: z.ZodOptional<z.ZodString>;
|
|
22
23
|
}, z.core.$strip>>>;
|
|
23
24
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
25
|
pageTitlePrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -27,7 +28,8 @@ export declare const configSchema: z.ZodObject<{
|
|
|
27
28
|
extraFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
28
29
|
contents: z.ZodString;
|
|
29
30
|
id: z.ZodString;
|
|
30
|
-
|
|
31
|
+
processAsMdx: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
title: z.ZodOptional<z.ZodString>;
|
|
31
33
|
}, z.core.$strip>>>;
|
|
32
34
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
33
35
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../../src/docs-plugin/internal/config-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAC,MAAM,KAAK,CAAA;AAErD,OAAO,KAAK,EAQV,SAAS,EACV,MAAM,UAAU,CAAA;AAIjB,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,EAAE,CAItC,CAAA;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,SAAS,CAmB7C,CAAA;
|
|
1
|
+
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../../src/docs-plugin/internal/config-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAC,MAAM,KAAK,CAAA;AAErD,OAAO,KAAK,EAQV,SAAS,EACV,MAAM,UAAU,CAAA;AAIjB,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,EAAE,CAItC,CAAA;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,SAAS,CAmB7C,CAAA;AA2CJ,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BvB,CAAA"}
|
|
@@ -149,11 +149,11 @@ export interface KnowledgeIntegrationConfig {
|
|
|
149
149
|
pageTitlePrefix?: string;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* Extra content to include in knowledge output.
|
|
152
|
+
* Extra content to include in knowledge output. Assumed to be Markdown.
|
|
153
153
|
*/
|
|
154
154
|
export interface KnowledgeExtraFile {
|
|
155
155
|
/**
|
|
156
|
-
* The
|
|
156
|
+
* The Markdown content for this file.
|
|
157
157
|
*/
|
|
158
158
|
contents: string;
|
|
159
159
|
/**
|
|
@@ -161,9 +161,15 @@ export interface KnowledgeExtraFile {
|
|
|
161
161
|
*/
|
|
162
162
|
id: string;
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* Whether to process this file as MDX content, replacing relative URLs and
|
|
165
|
+
* applying other transformations as if the file were authored as mdx
|
|
166
|
+
* documentation.
|
|
165
167
|
*/
|
|
166
|
-
|
|
168
|
+
processAsMdx?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Display title for this content.
|
|
171
|
+
*/
|
|
172
|
+
title?: string;
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
175
|
* Configuration for per-page Markdown exports. Inherits from parent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/docs-plugin/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAC,MAAM,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAA;AAE7D,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,CAAA;AAEpC;;;;;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 @@ var typeDocPropsSchema = implement().with({
|
|
|
3591
3591
|
var knowledgeExtraFileSchema = implement().with({
|
|
3592
3592
|
contents: z2.string(),
|
|
3593
3593
|
id: z2.string(),
|
|
3594
|
-
|
|
3594
|
+
processAsMdx: z2.boolean().optional(),
|
|
3595
|
+
title: z2.string().optional()
|
|
3595
3596
|
});
|
|
3596
3597
|
var knowledgeExportsSchema = implement().with({
|
|
3597
3598
|
enabled: z2.boolean().optional(),
|
|
@@ -5365,6 +5366,37 @@ function getPath(obj, path) {
|
|
|
5365
5366
|
obj
|
|
5366
5367
|
);
|
|
5367
5368
|
}
|
|
5369
|
+
function escapeText(value) {
|
|
5370
|
+
return value.replace(/\n/g, " ");
|
|
5371
|
+
}
|
|
5372
|
+
function propsToDefinitionList(props) {
|
|
5373
|
+
if (props.length === 0) {
|
|
5374
|
+
return "";
|
|
5375
|
+
}
|
|
5376
|
+
return props.map((prop) => {
|
|
5377
|
+
const parts = [`- **${prop.name}** (\`${escapeText(prop.type)}\``];
|
|
5378
|
+
if (prop.defaultValue) {
|
|
5379
|
+
parts.push(`, default: \`${escapeText(prop.defaultValue)}\``);
|
|
5380
|
+
}
|
|
5381
|
+
if (prop.required) {
|
|
5382
|
+
parts.push(", required");
|
|
5383
|
+
}
|
|
5384
|
+
parts.push(")");
|
|
5385
|
+
if (prop.description) {
|
|
5386
|
+
parts.push(` - ${escapeText(prop.description)}`);
|
|
5387
|
+
}
|
|
5388
|
+
return parts.join("");
|
|
5389
|
+
}).join("\n");
|
|
5390
|
+
}
|
|
5391
|
+
function themeDataToJson(data, cssPropertyName) {
|
|
5392
|
+
if (!data || typeof data !== "object") {
|
|
5393
|
+
return "";
|
|
5394
|
+
}
|
|
5395
|
+
if (cssPropertyName) {
|
|
5396
|
+
return JSON.stringify({ cssProperty: cssPropertyName, data }, null, 2);
|
|
5397
|
+
}
|
|
5398
|
+
return JSON.stringify(data, null, 2);
|
|
5399
|
+
}
|
|
5368
5400
|
var KnowledgeGenerator = class {
|
|
5369
5401
|
config;
|
|
5370
5402
|
docProps = null;
|
|
@@ -5394,7 +5426,7 @@ var KnowledgeGenerator = class {
|
|
|
5394
5426
|
const processedPages = [];
|
|
5395
5427
|
for (const page of pages) {
|
|
5396
5428
|
try {
|
|
5397
|
-
const processed = await this.
|
|
5429
|
+
const processed = await this.processMdxPage(page);
|
|
5398
5430
|
processedPages.push(processed);
|
|
5399
5431
|
} catch (error) {
|
|
5400
5432
|
console.error(`Failed to process page: ${page.name}`);
|
|
@@ -5419,7 +5451,7 @@ var KnowledgeGenerator = class {
|
|
|
5419
5451
|
);
|
|
5420
5452
|
await this.generateExtraFiles(extractedMetadata);
|
|
5421
5453
|
}
|
|
5422
|
-
return pages
|
|
5454
|
+
return pages;
|
|
5423
5455
|
}
|
|
5424
5456
|
async loadDocProps() {
|
|
5425
5457
|
const resolvedDocPropsPath = this.config.docPropsPath ? await exists(this.config.docPropsPath) ? this.config.docPropsPath : resolve(process.cwd(), this.config.docPropsPath) : join2(dirname(this.config.routeDir), "doc-props.json");
|
|
@@ -5481,10 +5513,11 @@ var KnowledgeGenerator = class {
|
|
|
5481
5513
|
const url = getPathnameFromPathSegments(segments);
|
|
5482
5514
|
components.push({
|
|
5483
5515
|
demosFolder: demosFolderPath,
|
|
5516
|
+
filePath: dirPath,
|
|
5484
5517
|
id: segments.join("-").trim(),
|
|
5485
5518
|
mdxFile: join2(dirPath, mdxFile.name),
|
|
5486
5519
|
name: segments.at(-1),
|
|
5487
|
-
|
|
5520
|
+
pathname: url,
|
|
5488
5521
|
url: this.config.baseUrl ? new URL(url, this.config.baseUrl).toString() : void 0
|
|
5489
5522
|
});
|
|
5490
5523
|
if (this.config.verbose) {
|
|
@@ -5612,7 +5645,9 @@ ${codeText}
|
|
|
5612
5645
|
}
|
|
5613
5646
|
default:
|
|
5614
5647
|
if (this.config.outputMode === "per-page" && "tag" in part && part.tag === "@link" && typeof part.target === "string") {
|
|
5615
|
-
|
|
5648
|
+
if (part.text === "Learn more") {
|
|
5649
|
+
return "";
|
|
5650
|
+
}
|
|
5616
5651
|
}
|
|
5617
5652
|
return part.text;
|
|
5618
5653
|
}
|
|
@@ -5631,8 +5666,8 @@ ${codeText}
|
|
|
5631
5666
|
};
|
|
5632
5667
|
}
|
|
5633
5668
|
/**
|
|
5634
|
-
* Creates a remark plugin that replaces
|
|
5635
|
-
*
|
|
5669
|
+
* Creates a remark plugin that replaces theme JSX elements with
|
|
5670
|
+
* markdown tables containing theme data.
|
|
5636
5671
|
*/
|
|
5637
5672
|
async replaceThemeNodes() {
|
|
5638
5673
|
let themes = null;
|
|
@@ -5669,11 +5704,21 @@ ${codeText}
|
|
|
5669
5704
|
console.warn(`No theme data for ${node.name}`);
|
|
5670
5705
|
return;
|
|
5671
5706
|
}
|
|
5707
|
+
let markdownTable;
|
|
5708
|
+
if (typeof data === "object" && data !== null && "cssPropertyName" in data && "data" in data) {
|
|
5709
|
+
const { cssPropertyName, data: themeData } = data;
|
|
5710
|
+
markdownTable = themeDataToJson(themeData, cssPropertyName);
|
|
5711
|
+
} else {
|
|
5712
|
+
markdownTable = themeDataToJson(data);
|
|
5713
|
+
}
|
|
5714
|
+
if (!markdownTable) {
|
|
5715
|
+
return;
|
|
5716
|
+
}
|
|
5672
5717
|
Object.assign(node, {
|
|
5673
5718
|
lang: "json",
|
|
5674
5719
|
meta: null,
|
|
5675
5720
|
type: "code",
|
|
5676
|
-
value:
|
|
5721
|
+
value: markdownTable
|
|
5677
5722
|
});
|
|
5678
5723
|
});
|
|
5679
5724
|
done();
|
|
@@ -5694,8 +5739,26 @@ ${codeText}
|
|
|
5694
5739
|
return null;
|
|
5695
5740
|
}
|
|
5696
5741
|
/**
|
|
5697
|
-
* Creates a remark plugin that
|
|
5698
|
-
|
|
5742
|
+
* Creates a remark plugin that transforms relative URLs to absolute URLs.
|
|
5743
|
+
*/
|
|
5744
|
+
transformRelativeUrls(pageUrl) {
|
|
5745
|
+
const baseUrl = this.config.baseUrl;
|
|
5746
|
+
return () => (tree) => {
|
|
5747
|
+
if (!baseUrl || this.config.outputMode !== "per-page") {
|
|
5748
|
+
return;
|
|
5749
|
+
}
|
|
5750
|
+
visit5(tree, "link", (node) => {
|
|
5751
|
+
if (node.url.startsWith("/")) {
|
|
5752
|
+
node.url = `${baseUrl}${node.url}`;
|
|
5753
|
+
} else if (node.url.startsWith("./#") && pageUrl) {
|
|
5754
|
+
node.url = `${pageUrl}${node.url.slice(2)}`;
|
|
5755
|
+
}
|
|
5756
|
+
});
|
|
5757
|
+
};
|
|
5758
|
+
}
|
|
5759
|
+
/**
|
|
5760
|
+
* Creates a remark plugin that replaces TypeDocProps JSX elements with
|
|
5761
|
+
* markdown tables containing component prop documentation.
|
|
5699
5762
|
*/
|
|
5700
5763
|
replaceTypeDocProps() {
|
|
5701
5764
|
return () => (tree, _file, done) => {
|
|
@@ -5742,11 +5805,35 @@ ${codeText}
|
|
|
5742
5805
|
` Replaced TypeDocProps ${propsName} with API documentation`
|
|
5743
5806
|
);
|
|
5744
5807
|
}
|
|
5808
|
+
const regularProps = propsDoc.filter((p) => p.propType === void 0);
|
|
5809
|
+
const inputs = propsDoc.filter((p) => p.propType === "input");
|
|
5810
|
+
const outputs = propsDoc.filter((p) => p.propType === "output");
|
|
5811
|
+
const sections = [];
|
|
5812
|
+
if (regularProps.length > 0) {
|
|
5813
|
+
sections.push(propsToDefinitionList(regularProps));
|
|
5814
|
+
}
|
|
5815
|
+
if (inputs.length > 0) {
|
|
5816
|
+
sections.push(`**Inputs**
|
|
5817
|
+
|
|
5818
|
+
${propsToDefinitionList(inputs)}`);
|
|
5819
|
+
}
|
|
5820
|
+
if (outputs.length > 0) {
|
|
5821
|
+
sections.push(`**Outputs**
|
|
5822
|
+
|
|
5823
|
+
${propsToDefinitionList(outputs)}`);
|
|
5824
|
+
}
|
|
5825
|
+
const markdownContent = sections.join("\n\n");
|
|
5826
|
+
if (!markdownContent) {
|
|
5827
|
+
if (parent && index !== void 0) {
|
|
5828
|
+
parent.children.splice(index, 1);
|
|
5829
|
+
}
|
|
5830
|
+
return;
|
|
5831
|
+
}
|
|
5745
5832
|
Object.assign(node, {
|
|
5746
|
-
lang:
|
|
5833
|
+
lang: null,
|
|
5747
5834
|
meta: null,
|
|
5748
5835
|
type: "code",
|
|
5749
|
-
value:
|
|
5836
|
+
value: markdownContent
|
|
5750
5837
|
});
|
|
5751
5838
|
}
|
|
5752
5839
|
);
|
|
@@ -5887,54 +5974,41 @@ ${codeText}
|
|
|
5887
5974
|
*/
|
|
5888
5975
|
async processMdxContent(mdxContent, pageUrl, demosFolder, frontmatter) {
|
|
5889
5976
|
const demoFiles = [];
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
(_, text, anchor) => pageUrl && this.config.outputMode === "per-page" ? `[${text}](${pageUrl}#${anchor})` : text
|
|
5894
|
-
);
|
|
5895
|
-
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(this.replaceTypeDocProps()).use(this.replaceFrontmatterExpressions(frontmatter)).use(await this.replaceThemeNodes()).use(this.replaceDemos(demosFolder, demoFiles)).use(remarkStringify3);
|
|
5896
|
-
const processed = await processor.process(processedContent);
|
|
5897
|
-
processedContent = String(processed);
|
|
5898
|
-
processedContent = processedContent.replace(/\n\s*\n\s*\n/g, "\n\n");
|
|
5977
|
+
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(this.replaceTypeDocProps()).use(this.replaceFrontmatterExpressions(frontmatter)).use(await this.replaceThemeNodes()).use(this.replaceDemos(demosFolder, demoFiles)).use(this.transformRelativeUrls(pageUrl)).use(remarkStringify3);
|
|
5978
|
+
const processed = await processor.process(mdxContent);
|
|
5979
|
+
const processedContent = String(processed).replace(/\n\s*\n\s*\n/g, "\n\n");
|
|
5899
5980
|
return { content: processedContent, demoFiles };
|
|
5900
5981
|
}
|
|
5901
|
-
async
|
|
5982
|
+
async processMdxPage(pageInfo) {
|
|
5902
5983
|
try {
|
|
5903
|
-
const mdxContent = await readFile(
|
|
5984
|
+
const mdxContent = await readFile(pageInfo.mdxFile, "utf-8");
|
|
5904
5985
|
if (this.config.verbose) {
|
|
5905
|
-
console.log(`Processing page: ${
|
|
5906
|
-
}
|
|
5907
|
-
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(replaceNpmInstallTabs).use(remarkFrontmatter2, ["yaml"]).use(remarkParseFrontmatter2);
|
|
5908
|
-
if (this.config.outputMode === "per-page") {
|
|
5909
|
-
processor.use(remarkSelfLinkHeadings(component.url));
|
|
5986
|
+
console.log(`Processing page: ${pageInfo.name}`);
|
|
5910
5987
|
}
|
|
5911
|
-
processor.use(remarkStringify3);
|
|
5988
|
+
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(replaceNpmInstallTabs).use(remarkFrontmatter2, ["yaml"]).use(remarkParseFrontmatter2).use(remarkStringify3);
|
|
5912
5989
|
const parsed = await processor.process(mdxContent);
|
|
5913
5990
|
const frontmatter = parsed.data?.frontmatter || {};
|
|
5914
5991
|
const { content: processedContent, demoFiles } = await this.processMdxContent(
|
|
5915
5992
|
String(parsed),
|
|
5916
|
-
|
|
5917
|
-
|
|
5993
|
+
pageInfo.url,
|
|
5994
|
+
pageInfo.demosFolder,
|
|
5918
5995
|
frontmatter
|
|
5919
5996
|
);
|
|
5920
5997
|
const removeJsxProcessor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(remarkRemoveJsx).use(remarkStringify3);
|
|
5921
5998
|
const removedJsx = String(
|
|
5922
5999
|
await removeJsxProcessor.process(processedContent)
|
|
5923
6000
|
);
|
|
5924
|
-
const contentWithoutFrontmatter = removedJsx.replace(
|
|
5925
|
-
|
|
5926
|
-
""
|
|
5927
|
-
);
|
|
5928
|
-
const title = frontmatter.title || component.name;
|
|
6001
|
+
const contentWithoutFrontmatter = removedJsx.replace(/^---[\s\S]*?---\n/, "").replace(/(^#{1,6} .*\\<[^>]+)>/gm, "$1\\>");
|
|
6002
|
+
const title = frontmatter.title || pageInfo.name;
|
|
5929
6003
|
return {
|
|
5930
6004
|
content: contentWithoutFrontmatter.trim(),
|
|
5931
6005
|
demoFiles,
|
|
5932
6006
|
frontmatter,
|
|
5933
6007
|
title,
|
|
5934
|
-
url:
|
|
6008
|
+
url: pageInfo.url
|
|
5935
6009
|
};
|
|
5936
6010
|
} catch (error) {
|
|
5937
|
-
console.error(`Error processing component ${
|
|
6011
|
+
console.error(`Error processing component ${pageInfo.name}:`, error);
|
|
5938
6012
|
throw error;
|
|
5939
6013
|
}
|
|
5940
6014
|
}
|
|
@@ -5982,6 +6056,11 @@ ${codeText}
|
|
|
5982
6056
|
let totalSize = 0;
|
|
5983
6057
|
await Promise.all(
|
|
5984
6058
|
extraFiles.map(async (extraFile) => {
|
|
6059
|
+
let contents = extraFile.contents;
|
|
6060
|
+
if (extraFile.processAsMdx) {
|
|
6061
|
+
const removeJsxProcessor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(remarkRemoveJsx).use(this.transformRelativeUrls()).use(remarkStringify3);
|
|
6062
|
+
contents = String(await removeJsxProcessor.process(contents));
|
|
6063
|
+
}
|
|
5985
6064
|
const lines = [];
|
|
5986
6065
|
if (metadata.length) {
|
|
5987
6066
|
lines.push("---");
|
|
@@ -5991,9 +6070,11 @@ ${codeText}
|
|
|
5991
6070
|
lines.push("---");
|
|
5992
6071
|
lines.push("");
|
|
5993
6072
|
}
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
6073
|
+
if (extraFile.title) {
|
|
6074
|
+
lines.push(`# ${extraFile.title}`);
|
|
6075
|
+
lines.push("");
|
|
6076
|
+
}
|
|
6077
|
+
lines.push(contents);
|
|
5997
6078
|
lines.push("");
|
|
5998
6079
|
const outfile = `${resolve(this.config.outputPath)}/${kebabCase(extraFile.id)}.md`;
|
|
5999
6080
|
await writeFile(outfile, lines.join("\n"), "utf-8");
|
|
@@ -6035,6 +6116,10 @@ ${codeText}
|
|
|
6035
6116
|
page.name = processedPage.frontmatter.title;
|
|
6036
6117
|
}
|
|
6037
6118
|
let content = processedPage.content;
|
|
6119
|
+
content = content.replace(
|
|
6120
|
+
new RegExp(`^# ${processedPage.title}\\n+`, ""),
|
|
6121
|
+
""
|
|
6122
|
+
);
|
|
6038
6123
|
if (this.config.pageTitlePrefix) {
|
|
6039
6124
|
content = content.replace(
|
|
6040
6125
|
`# ${page.name}`,
|