@mintlify/prebuild 1.0.525 → 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 CHANGED
@@ -3,3 +3,4 @@ export * from './generate.js';
3
3
  export * from './utils.js';
4
4
  export * from './prebuild/index.js';
5
5
  export { getFaviconsConfig } from './prebuild/generateFavicons.js';
6
+ export * from './prebuild/update/rss/index.js';
package/dist/index.js CHANGED
@@ -3,3 +3,4 @@ export * from './generate.js';
3
3
  export * from './utils.js';
4
4
  export * from './prebuild/index.js';
5
5
  export { getFaviconsConfig } from './prebuild/generateFavicons.js';
6
+ export * from './prebuild/update/rss/index.js';
@@ -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,5 @@
1
+ import { DocsConfig } from '@mintlify/validation';
2
+ export declare const docsConfigToRss: (docsConfig: DocsConfig) => {
3
+ orgName: string;
4
+ orgDescription: string | undefined;
5
+ };
@@ -0,0 +1,8 @@
1
+ export const docsConfigToRss = (docsConfig) => {
2
+ const orgName = docsConfig.name;
3
+ const orgDescription = docsConfig.description;
4
+ return {
5
+ orgName,
6
+ orgDescription,
7
+ };
8
+ };
@@ -0,0 +1,3 @@
1
+ export * from './docsConfigToRss.js';
2
+ export * from './mdxToRssUpdates.js';
3
+ export * from './pageToRss.js';
@@ -0,0 +1,3 @@
1
+ export * from './docsConfigToRss.js';
2
+ export * from './mdxToRssUpdates.js';
3
+ export * from './pageToRss.js';
@@ -0,0 +1,3 @@
1
+ import { RSSItem } from '@mintlify/common';
2
+ import { Root } from 'mdast';
3
+ export declare const mdxToRssUpdates: (tree: Root) => RSSItem[];
@@ -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,5 @@
1
+ import { Root } from 'mdast';
2
+ export declare const pageToRss: (tree: Root) => {
3
+ title: string | undefined;
4
+ description: string | undefined;
5
+ };
@@ -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,6 @@
1
+ import { DocsConfig } from '@mintlify/validation';
2
+ import { Root } from 'mdast';
3
+ export declare const writeRssFiles: (docsConfig: DocsConfig, rssPages: {
4
+ targetPath: string;
5
+ tree: Root;
6
+ }[]) => Promise<void>;
@@ -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
+ };