@mintlify/prebuild 1.0.526 → 1.0.527
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/prebuild/update/index.js +4 -1
- package/dist/prebuild/update/rss/docsConfigToRss.d.ts +5 -0
- package/dist/prebuild/update/rss/docsConfigToRss.js +8 -0
- package/dist/prebuild/update/rss/index.d.ts +3 -0
- package/dist/prebuild/update/rss/index.js +3 -0
- package/dist/prebuild/update/rss/mdxToRssUpdates.d.ts +3 -0
- package/dist/prebuild/update/rss/mdxToRssUpdates.js +22 -0
- package/dist/prebuild/update/rss/pageToRss.d.ts +5 -0
- package/dist/prebuild/update/rss/pageToRss.js +12 -0
- package/dist/prebuild/update/write/writeRssFiles.d.ts +6 -0
- package/dist/prebuild/update/write/writeRssFiles.js +26 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyTree } from '@mintlify/common';
|
|
1
|
+
import { stringifyTree, containsUpdates } from '@mintlify/common';
|
|
2
2
|
import { upgradeToDocsConfig } from '@mintlify/validation';
|
|
3
3
|
import { outputFile } from 'fs-extra';
|
|
4
4
|
import { updateDocsConfigFile } from './docsConfig/index.js';
|
|
@@ -10,6 +10,7 @@ import { updateGeneratedDocsNav, updateGeneratedNav } from './updateGeneratedNav
|
|
|
10
10
|
import { writeAsyncApiFiles } from './write/writeAsyncApiFiles.js';
|
|
11
11
|
import { writeFiles } from './write/writeFiles.js';
|
|
12
12
|
import { writeOpenApiFiles } from './write/writeOpenApiFiles.js';
|
|
13
|
+
import { writeRssFiles } from './write/writeRssFiles.js';
|
|
13
14
|
export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, }) => {
|
|
14
15
|
const mintConfigResult = await updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema);
|
|
15
16
|
// we used the original mint config without openapi pages injected
|
|
@@ -28,6 +29,7 @@ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFil
|
|
|
28
29
|
snippetV2Promises,
|
|
29
30
|
pagePromises,
|
|
30
31
|
]);
|
|
32
|
+
const rssPages = mdxFilesWithNoImports.filter((page) => containsUpdates(page.tree));
|
|
31
33
|
await Promise.all([
|
|
32
34
|
resolveImportsAndWriteFiles({
|
|
33
35
|
openApiFiles: newOpenApiFiles,
|
|
@@ -38,6 +40,7 @@ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFil
|
|
|
38
40
|
}),
|
|
39
41
|
writeOpenApiFiles(newOpenApiFiles),
|
|
40
42
|
writeAsyncApiFiles(newAsyncApiFiles),
|
|
43
|
+
writeRssFiles(newDocsConfig, rssPages),
|
|
41
44
|
updateFavicons(newDocsConfig, contentDirectoryPath),
|
|
42
45
|
...writeMdxFilesWithNoImports(mdxFilesWithNoImports),
|
|
43
46
|
...writeFiles(contentDirectoryPath, 'public', [...staticFilenames, ...snippets]),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getTags, isUpdate } from '@mintlify/common';
|
|
2
|
+
export const mdxToRssUpdates = (tree) => {
|
|
3
|
+
const updates = [];
|
|
4
|
+
const updateComponents = tree.children.filter((child) => isUpdate(child));
|
|
5
|
+
for (const updateComponent of updateComponents) {
|
|
6
|
+
const attributes = updateComponent.attributes;
|
|
7
|
+
const label = attributes.find((attribute) => attribute.type === 'mdxJsxAttribute' && attribute.name === 'label')?.value;
|
|
8
|
+
const description = attributes.find((attribute) => attribute.type === 'mdxJsxAttribute' && attribute.name === 'description')?.value;
|
|
9
|
+
const tags = getTags(updateComponent);
|
|
10
|
+
const validTitle = label?.toString() || undefined;
|
|
11
|
+
const validDescription = description?.toString() || '';
|
|
12
|
+
const validTags = tags.length > 0 ? tags : undefined;
|
|
13
|
+
if (validTitle) {
|
|
14
|
+
updates.push({
|
|
15
|
+
title: validTitle,
|
|
16
|
+
description: validDescription,
|
|
17
|
+
categories: validTags,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return updates;
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isFrontmatter } from '@mintlify/common';
|
|
2
|
+
import yaml from 'js-yaml';
|
|
3
|
+
export const pageToRss = (tree) => {
|
|
4
|
+
let title;
|
|
5
|
+
let description;
|
|
6
|
+
if (isFrontmatter(tree.children[0])) {
|
|
7
|
+
const frontmatterObject = yaml.load(tree.children[0].value);
|
|
8
|
+
title = frontmatterObject.title || undefined;
|
|
9
|
+
description = frontmatterObject.description || undefined;
|
|
10
|
+
}
|
|
11
|
+
return { title, description };
|
|
12
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { docsConfigToRss } from '../rss/docsConfigToRss.js';
|
|
3
|
+
import { mdxToRssUpdates } from '../rss/mdxToRssUpdates.js';
|
|
4
|
+
import { pageToRss } from '../rss/pageToRss.js';
|
|
5
|
+
export const writeRssFiles = async (docsConfig, rssPages) => {
|
|
6
|
+
const { orgName, orgDescription } = docsConfigToRss(docsConfig);
|
|
7
|
+
const rssTargetPath = 'src/_props/rssFiles.json';
|
|
8
|
+
const rssItemsToSave = rssPages.map((page) => {
|
|
9
|
+
const { targetPath, tree } = page;
|
|
10
|
+
const { title, description } = pageToRss(tree);
|
|
11
|
+
const rssPath = targetPath.replace('.mdx', '/rss');
|
|
12
|
+
const updates = mdxToRssUpdates(tree);
|
|
13
|
+
return {
|
|
14
|
+
rssPath,
|
|
15
|
+
orgName,
|
|
16
|
+
orgDescription,
|
|
17
|
+
title,
|
|
18
|
+
description,
|
|
19
|
+
updates,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
await fse.remove(rssTargetPath);
|
|
23
|
+
await fse.outputFile(rssTargetPath, JSON.stringify(rssItemsToSave), {
|
|
24
|
+
flag: 'w',
|
|
25
|
+
});
|
|
26
|
+
};
|