mintlify 1.1.6 → 1.1.8
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/CONTRIBUTING.md +5 -0
- package/bin/index.js +1 -8
- package/bin/index.js.map +1 -1
- package/bin/local-preview/injectNav.js +94 -0
- package/bin/local-preview/injectNav.js.map +1 -0
- package/bin/mint/client/.babel-plugin-macrosrc.json +5 -0
- package/bin/mint/client/.babelrc +4 -0
- package/bin/mint/client/.editorconfig +12 -0
- package/bin/mint/client/.eslintrc.json +7 -0
- package/bin/mint/client/.prettierignore +4 -0
- package/bin/mint/client/.prettierrc +14 -0
- package/bin/mint/client/.vscode/launch.json +28 -0
- package/bin/mint/client/README.md +44 -0
- package/bin/mint/client/jest.config.ts +195 -0
- package/bin/mint/client/next-env.d.ts +4 -0
- package/bin/mint/client/next.config.js +152 -0
- package/bin/mint/client/package.json +139 -0
- package/bin/mint/client/postcss.config.cjs +9 -0
- package/bin/mint/client/prebuild/faviconConfig.js +35 -0
- package/bin/mint/client/prebuild/getOpenApiContext.js +53 -0
- package/bin/mint/client/prebuild/index.js +117 -0
- package/bin/mint/client/prebuild/injectNav.js +115 -0
- package/bin/mint/client/prebuild/slugToTitle.js +7 -0
- package/bin/mint/client/rehype/withApiComponents.js +60 -0
- package/bin/mint/client/rehype/withCodeBlocks.js +54 -0
- package/bin/mint/client/rehype/withLayouts.js +113 -0
- package/bin/mint/client/rehype/withLinkRoles.js +13 -0
- package/bin/mint/client/rehype/withRawComponents.js +13 -0
- package/bin/mint/client/rehype/withStaticProps.js +25 -0
- package/bin/mint/client/rehype/withSyntaxHighlighting.js +60 -0
- package/bin/mint/client/remark/utils.js +369 -0
- package/bin/mint/client/remark/withFrames.js +55 -0
- package/bin/mint/client/remark/withImportsInjected.js +36 -0
- package/bin/mint/client/remark/withNextLinks.js +37 -0
- package/bin/mint/client/remark/withTableOfContents.js +71 -0
- package/bin/mint/client/scripts/local.js +177 -0
- package/bin/mint/client/sentry.client.config.js +15 -0
- package/bin/mint/client/sentry.properties +4 -0
- package/bin/mint/client/sentry.server.config.js +15 -0
- package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +50 -0
- package/bin/mint/client/src/analytics/AnalyticsContext.ts +5 -0
- package/bin/mint/client/src/analytics/AnalyticsMediator.ts +101 -0
- package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +9 -0
- package/bin/mint/client/src/analytics/GA4Script.tsx +33 -0
- package/bin/mint/client/src/analytics/implementations/amplitude.ts +26 -0
- package/bin/mint/client/src/analytics/implementations/fathom.ts +38 -0
- package/bin/mint/client/src/analytics/implementations/ga4.ts +33 -0
- package/bin/mint/client/src/analytics/implementations/hotjar.ts +53 -0
- package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +1 -0
- package/bin/mint/client/src/analytics/implementations/mixpanel.ts +52 -0
- package/bin/mint/client/src/analytics/implementations/posthog.ts +37 -0
- package/bin/mint/client/src/components/Accordion/Accordion.tsx +43 -0
- package/bin/mint/client/src/components/Accordion/index.ts +4 -0
- package/bin/mint/client/src/components/ApiExample.tsx +9 -0
- package/bin/mint/client/src/components/Card.tsx +51 -0
- package/bin/mint/client/src/components/CodeGroup.tsx +132 -0
- package/bin/mint/client/src/components/Editor.tsx +12 -0
- package/bin/mint/client/src/components/Expandable.tsx +40 -0
- package/bin/mint/client/src/components/Heading.tsx +84 -0
- package/bin/mint/client/src/components/Param.tsx +56 -0
- package/bin/mint/client/src/components/Request.tsx +19 -0
- package/bin/mint/client/src/components/ResponseField.tsx +33 -0
- package/bin/mint/client/src/components/TabBar.tsx +61 -0
- package/bin/mint/client/src/config.ts +115 -0
- package/bin/mint/client/src/css/bar-of-progress.css +10 -0
- package/bin/mint/client/src/css/base.css +29 -0
- package/bin/mint/client/src/css/font-awesome.css +7 -0
- package/bin/mint/client/src/css/fonts.css +44 -0
- package/bin/mint/client/src/css/main.css +11 -0
- package/bin/mint/client/src/css/prism.css +270 -0
- package/bin/mint/client/src/css/utilities.css +43 -0
- package/bin/mint/client/src/enums/components.ts +8 -0
- package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
- package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
- package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
- package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
- package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
- package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
- package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
- package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
- package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
- package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
- package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +11 -0
- package/bin/mint/client/src/hooks/useActionKey.ts +20 -0
- package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +3 -0
- package/bin/mint/client/src/hooks/useMedia.ts +27 -0
- package/bin/mint/client/src/hooks/usePrevNext.ts +34 -0
- package/bin/mint/client/src/hooks/useTop.ts +15 -0
- package/bin/mint/client/src/icons/CopyToClipboard.tsx +33 -0
- package/bin/mint/client/src/index.d.ts +1 -0
- package/bin/mint/client/src/layouts/ApiSupplemental.tsx +173 -0
- package/bin/mint/client/src/layouts/ContentsLayout.tsx +256 -0
- package/bin/mint/client/src/layouts/DocumentationLayout.tsx +44 -0
- package/bin/mint/client/src/layouts/OpenApiContent.tsx +301 -0
- package/bin/mint/client/src/layouts/SidebarLayout.tsx +412 -0
- package/bin/mint/client/src/layouts/UserFeedback.tsx +73 -0
- package/bin/mint/client/src/layouts/getGroupsInDivision.ts +25 -0
- package/bin/mint/client/src/layouts/isPathInGroupPages.ts +10 -0
- package/bin/mint/client/src/metadata.ts +58 -0
- package/bin/mint/client/src/nav.json +219 -0
- package/bin/mint/client/src/openapi.ts +3 -0
- package/bin/mint/client/src/pages/404.tsx +73 -0
- package/bin/mint/client/src/pages/_app.tsx +138 -0
- package/bin/mint/client/src/pages/_document.tsx +57 -0
- package/bin/mint/client/src/pages/api/issue.ts +10 -0
- package/bin/mint/client/src/pages/api/name.ts +8 -0
- package/bin/mint/client/src/pages/api/request.ts +31 -0
- package/bin/mint/client/src/pages/api/suggest.ts +10 -0
- package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +13 -0
- package/bin/mint/client/src/pages/api/utils.ts +6 -0
- package/bin/mint/client/src/pages/index.tsx +31 -0
- package/bin/mint/client/src/ui/Api.tsx +359 -0
- package/bin/mint/client/src/ui/Footer.tsx +124 -0
- package/bin/mint/client/src/ui/Header.tsx +370 -0
- package/bin/mint/client/src/ui/Logo.tsx +55 -0
- package/bin/mint/client/src/ui/PageHeader.tsx +51 -0
- package/bin/mint/client/src/ui/Search.tsx +386 -0
- package/bin/mint/client/src/ui/ThemeToggle.tsx +285 -0
- package/bin/mint/client/src/ui/Title.tsx +22 -0
- package/bin/mint/client/src/ui/TopLevelLink.tsx +122 -0
- package/bin/mint/client/src/utils/api.ts +252 -0
- package/bin/mint/client/src/utils/brands.ts +217 -0
- package/bin/mint/client/src/utils/castArray.ts +3 -0
- package/bin/mint/client/src/utils/childrenArray.ts +3 -0
- package/bin/mint/client/src/utils/fit.ts +27 -0
- package/bin/mint/client/src/utils/fontAwesome.ts +577 -0
- package/bin/mint/client/src/utils/getAnalyticsConfig.ts +14 -0
- package/bin/mint/client/src/utils/getLogoHref.ts +9 -0
- package/bin/mint/client/src/utils/getOpenApiContext.ts +26 -0
- package/bin/mint/client/src/utils/importAll.ts +6 -0
- package/bin/mint/client/src/utils/isObject.ts +3 -0
- package/bin/mint/client/src/utils/kebabToTitleCase.ts +3 -0
- package/bin/mint/client/src/utils/loadImage.ts +8 -0
- package/bin/mint/client/src/utils/slugToTitle.ts +7 -0
- package/bin/mint/client/src/utils/wait.ts +5 -0
- package/bin/mint/client/tailwind.config.cjs +323 -0
- package/bin/mint/client/test/test.test.ts +5 -0
- package/bin/mint/client/tsconfig.json +36 -0
- package/bin/mint/client/yarn.lock +9702 -0
- package/bin/scraping/detectFramework.js +12 -3
- package/bin/scraping/detectFramework.js.map +1 -1
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +2 -2
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +3 -3
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapePage.js +2 -2
- package/bin/scraping/scrapePage.js.map +1 -1
- package/bin/scraping/scrapePageCommands.js +6 -6
- package/bin/scraping/scrapePageCommands.js.map +1 -1
- package/bin/scraping/scrapeSection.js +2 -2
- package/bin/scraping/scrapeSection.js.map +1 -1
- package/bin/scraping/scrapeSectionCommands.js +8 -7
- package/bin/scraping/scrapeSectionCommands.js.map +1 -1
- package/bin/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.js +36 -0
- package/bin/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.js.map +1 -0
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursively.js +38 -0
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursively.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js +14 -8
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +4 -29
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js +2 -1
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +7 -5
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js +2 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js +3 -3
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -16
- package/src/scraping/detectFramework.ts +13 -3
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +5 -2
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +5 -1
- package/src/scraping/scrapePage.ts +6 -3
- package/src/scraping/scrapePageCommands.ts +10 -6
- package/src/scraping/scrapeSection.ts +9 -2
- package/src/scraping/scrapeSectionCommands.ts +24 -7
- package/src/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.ts +46 -0
- package/src/scraping/site-scrapers/{getLinksRecursively.ts → links-per-group/getLinksRecursively.ts} +0 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusPage.ts +20 -8
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +9 -33
- package/src/scraping/site-scrapers/scrapeGitBookPage.ts +2 -1
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +9 -5
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +2 -1
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +4 -2
- package/bin/local-preview/helper-commands/cleanCommand.js +0 -8
- package/bin/local-preview/helper-commands/cleanCommand.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AbstractAnalyticsImplementation,
|
|
5
|
+
ConfigInterface,
|
|
6
|
+
} from '@/analytics/AbstractAnalyticsImplementation';
|
|
7
|
+
|
|
8
|
+
export default class MixpanelAnalytics extends AbstractAnalyticsImplementation {
|
|
9
|
+
initialized = false;
|
|
10
|
+
|
|
11
|
+
// Store events to submit after the library is loaded.
|
|
12
|
+
waitTracking: { name: string; properties: object }[] = [];
|
|
13
|
+
mixpanel = {
|
|
14
|
+
track: (name: string, properties: object) => this.waitTracking.push({ name, properties }),
|
|
15
|
+
} as any;
|
|
16
|
+
|
|
17
|
+
init(implementationConfig: ConfigInterface) {
|
|
18
|
+
if (implementationConfig.projectToken && process.env.NODE_ENV === 'production') {
|
|
19
|
+
// Dynamic import reduces our First Load JS by 18 kB
|
|
20
|
+
import('mixpanel-browser')
|
|
21
|
+
.then((_mixpanel) => {
|
|
22
|
+
if (!this.initialized) {
|
|
23
|
+
// Get default module export
|
|
24
|
+
const mixpanelLib = _mixpanel.default;
|
|
25
|
+
mixpanelLib.init(implementationConfig.projectToken, {
|
|
26
|
+
secure_cookie: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.initialized = true;
|
|
30
|
+
this.mixpanel = mixpanelLib;
|
|
31
|
+
|
|
32
|
+
this.waitTracking.forEach((event) => {
|
|
33
|
+
this.mixpanel.track(event.name, event.properties);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => {
|
|
38
|
+
Sentry.captureException(e);
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
// Stop storing events, we don't need them because the library will not be loaded.
|
|
42
|
+
this.mixpanel.track = (_name: string, _properties: object) => {};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
createEventListener(eventName: string) {
|
|
47
|
+
const captureFunc = async function capture(this: MixpanelAnalytics, eventProperties: object) {
|
|
48
|
+
this.mixpanel.track(eventName, eventProperties);
|
|
49
|
+
};
|
|
50
|
+
return captureFunc.bind(this);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Router from 'next/router';
|
|
2
|
+
import posthog from 'posthog-js';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AbstractAnalyticsImplementation,
|
|
6
|
+
ConfigInterface,
|
|
7
|
+
} from '@/analytics/AbstractAnalyticsImplementation';
|
|
8
|
+
|
|
9
|
+
export default class PostHogAnalytics extends AbstractAnalyticsImplementation {
|
|
10
|
+
initialized = false;
|
|
11
|
+
|
|
12
|
+
init(implementationConfig: ConfigInterface) {
|
|
13
|
+
if (implementationConfig.apiKey && !this.initialized) {
|
|
14
|
+
this.initialized = true;
|
|
15
|
+
// apiHost only has to be passed in if the user is self-hosting PostHog
|
|
16
|
+
posthog.init(implementationConfig.apiKey, {
|
|
17
|
+
api_host: implementationConfig.apiHost || 'https://app.posthog.com',
|
|
18
|
+
loaded: (posthogInstance) => {
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') posthogInstance.opt_out_capturing();
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Track page views
|
|
24
|
+
const handleRouteChange = () => posthog.capture('$pageview');
|
|
25
|
+
Router.events.on('routeChangeComplete', handleRouteChange);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createEventListener(eventName: string) {
|
|
30
|
+
if (this.initialized) {
|
|
31
|
+
return async function capture(eventProperties: object) {
|
|
32
|
+
posthog.capture(eventName, eventProperties);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return async function doNothing(_: object) {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactNode, useContext } from "react";
|
|
2
|
+
import { Accordion as GenericAccordion } from "@mintlify/components";
|
|
3
|
+
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
|
4
|
+
import AnalyticsContext from "@/analytics/AnalyticsContext";
|
|
5
|
+
|
|
6
|
+
function Accordion({
|
|
7
|
+
title,
|
|
8
|
+
description,
|
|
9
|
+
defaultOpen = false,
|
|
10
|
+
icon,
|
|
11
|
+
children,
|
|
12
|
+
}: {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
defaultOpen: boolean;
|
|
16
|
+
icon?: ReactNode | IconDefinition;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}) {
|
|
19
|
+
const analyticsMediator = useContext(AnalyticsContext);
|
|
20
|
+
const openAnalyticsListener = analyticsMediator.createEventListener('accordion_open');
|
|
21
|
+
const closeAnalyticsListener = analyticsMediator.createEventListener('accordion_close');
|
|
22
|
+
|
|
23
|
+
const onChange = (open: boolean) => {
|
|
24
|
+
if (open) {
|
|
25
|
+
openAnalyticsListener({ title });
|
|
26
|
+
} else {
|
|
27
|
+
closeAnalyticsListener({ title });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<GenericAccordion
|
|
33
|
+
title={title}
|
|
34
|
+
description={description}
|
|
35
|
+
defaultOpen={defaultOpen}
|
|
36
|
+
onChange={onChange}
|
|
37
|
+
icon={icon}>
|
|
38
|
+
{children}
|
|
39
|
+
</GenericAccordion>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default Accordion;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CodeGroup, CodeGroupProps } from './CodeGroup';
|
|
2
|
+
|
|
3
|
+
export function RequestExample({ ...props }: CodeGroupProps) {
|
|
4
|
+
return <CodeGroup {...props} isSmallText />;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function ResponseExample({ ...props }: CodeGroupProps) {
|
|
8
|
+
return <CodeGroup {...props} isSmallText />;
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
+
import { Card as GenericCard } from '@mintlify/components';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { ReactNode, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { config } from '@/config';
|
|
7
|
+
import { useIsomorphicLayoutEffect } from '@/hooks/useIsomorphicLayoutEffect';
|
|
8
|
+
|
|
9
|
+
export function Card({
|
|
10
|
+
title,
|
|
11
|
+
icon,
|
|
12
|
+
color,
|
|
13
|
+
href,
|
|
14
|
+
children,
|
|
15
|
+
}: {
|
|
16
|
+
title?: string;
|
|
17
|
+
icon?: ReactNode | IconDefinition;
|
|
18
|
+
color?: string;
|
|
19
|
+
href?: string;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
const [isDarkMode, setIsDarkMode] = useState<boolean>();
|
|
23
|
+
useIsomorphicLayoutEffect(() => {
|
|
24
|
+
if (window.document.querySelector('html.dark')) {
|
|
25
|
+
setIsDarkMode(true);
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
const activeConfigColor = isDarkMode ? config.colors?.light : config.colors?.primary;
|
|
30
|
+
|
|
31
|
+
const card = (
|
|
32
|
+
<GenericCard
|
|
33
|
+
title={title}
|
|
34
|
+
icon={icon}
|
|
35
|
+
iconColor={color || activeConfigColor}
|
|
36
|
+
hoverHighlightColour={href ? color || activeConfigColor : undefined}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</GenericCard>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (href) {
|
|
43
|
+
return (
|
|
44
|
+
<Link href={href}>
|
|
45
|
+
<div>{card}</div>
|
|
46
|
+
</Link>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return card;
|
|
51
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Tab } from '@headlessui/react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
function TabAdornment({ className }: { className: string }) {
|
|
6
|
+
return <div className={clsx('pointer-events-none absolute inset-0', className)} />;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function TabItem({
|
|
10
|
+
children,
|
|
11
|
+
selectedIndex,
|
|
12
|
+
myIndex,
|
|
13
|
+
marker,
|
|
14
|
+
}: {
|
|
15
|
+
children: any;
|
|
16
|
+
selectedIndex: number;
|
|
17
|
+
myIndex: number;
|
|
18
|
+
marker?: string;
|
|
19
|
+
}) {
|
|
20
|
+
const isSelected = selectedIndex === myIndex;
|
|
21
|
+
const isBeforeSelected = selectedIndex === myIndex + 1;
|
|
22
|
+
const isAfterSelected = selectedIndex === myIndex - 1;
|
|
23
|
+
|
|
24
|
+
// A cap is the edge of a list of tabs that has a special border treatment
|
|
25
|
+
// The edges of a tab may be in one of three states:
|
|
26
|
+
// - null if selected
|
|
27
|
+
// - normal if it looks like a normal tab
|
|
28
|
+
// - capped if there's a solid rounded corner on that edge
|
|
29
|
+
const edges = {
|
|
30
|
+
leading: isSelected ? null : isAfterSelected ? 'capped' : 'normal',
|
|
31
|
+
trailing: isSelected ? null : isBeforeSelected ? 'capped' : 'normal',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Tab
|
|
36
|
+
className={clsx(
|
|
37
|
+
'flex items-center relative z-10 overflow-hidden px-4 py-1',
|
|
38
|
+
isSelected ? 'text-primary-light' : 'text-slate-400'
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<span className="z-10">{children}</span>
|
|
42
|
+
|
|
43
|
+
{marker === 'close' && (
|
|
44
|
+
<svg viewBox="0 0 4 4" className="ml-2.5 flex-none w-1 h-1 text-slate-500 overflow-visible">
|
|
45
|
+
<path d="M-1 -1L5 5M5 -1L-1 5" fill="none" stroke="currentColor" strokeLinecap="round" />
|
|
46
|
+
</svg>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{marker === 'modified' && (
|
|
50
|
+
<div className="ml-2.5 flex-none w-1 h-1 rounded-full bg-current" />
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{/* Inactive tabs with optional edge caps */}
|
|
54
|
+
{!isSelected && (
|
|
55
|
+
<TabAdornment
|
|
56
|
+
className={clsx(
|
|
57
|
+
'bg-slate-700/50 border-y border-slate-500/30',
|
|
58
|
+
edges.leading === 'capped' && 'border-l rounded-tl',
|
|
59
|
+
edges.trailing === 'capped' && 'border-r rounded-tr'
|
|
60
|
+
)}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
|
|
64
|
+
{/* Divider between inactive tabs */}
|
|
65
|
+
{edges.trailing === 'normal' && (
|
|
66
|
+
<TabAdornment className="inset-y-px border-r border-slate-200/5 z-20" />
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{/* Active tab highlight bar */}
|
|
70
|
+
{isSelected && <TabAdornment className="border-b border-b-primary-light" />}
|
|
71
|
+
</Tab>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type CodeGroupProps = { children: any; isSmallText?: boolean };
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Group multiple code blocks into a tabbed UI
|
|
79
|
+
*
|
|
80
|
+
* @param {object} props
|
|
81
|
+
* @param {CodeBlock[]} props.children
|
|
82
|
+
*/
|
|
83
|
+
export function CodeGroup({ children, isSmallText }: CodeGroupProps) {
|
|
84
|
+
let [selectedIndex, setSelectedIndex] = useState<number>(0);
|
|
85
|
+
|
|
86
|
+
if (!Array.isArray(children)) {
|
|
87
|
+
children = [children];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Tab.Group
|
|
92
|
+
as="div"
|
|
93
|
+
onChange={setSelectedIndex as any}
|
|
94
|
+
className="not-prose bg-slate-800 rounded-xl shadow-md"
|
|
95
|
+
>
|
|
96
|
+
<div className="flex">
|
|
97
|
+
<Tab.List className="flex text-slate-400 text-xs leading-6 overflow-hidden rounded-tl-xl pt-2">
|
|
98
|
+
{children.map((child: any, tabIndex: number) => (
|
|
99
|
+
<TabItem key={child.props.filename} myIndex={tabIndex} selectedIndex={selectedIndex}>
|
|
100
|
+
{child.props.filename}
|
|
101
|
+
</TabItem>
|
|
102
|
+
))}
|
|
103
|
+
</Tab.List>
|
|
104
|
+
<div className="flex-auto flex pt-2 rounded-tr-xl overflow-hidden">
|
|
105
|
+
<div
|
|
106
|
+
className={clsx(
|
|
107
|
+
'flex-auto flex justify-end bg-slate-700/50 border-y border-slate-500/30 pr-4',
|
|
108
|
+
selectedIndex === children.length - 1 ? 'rounded-tl border-l' : ''
|
|
109
|
+
)}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<Tab.Panels className="flex overflow-auto">
|
|
114
|
+
{children.map((child: any) => (
|
|
115
|
+
<Tab.Panel
|
|
116
|
+
key={child.props.filename}
|
|
117
|
+
className={clsx(
|
|
118
|
+
'flex-none min-w-full p-5 text-slate-50 ligatures-none',
|
|
119
|
+
isSmallText ? 'text-xs leading-5' : 'text-sm leading-6'
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
{child.props.children}
|
|
123
|
+
</Tab.Panel>
|
|
124
|
+
))}
|
|
125
|
+
</Tab.Panels>
|
|
126
|
+
</Tab.Group>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function SnippetGroup(props: CodeGroupProps) {
|
|
131
|
+
return <CodeGroup {...props} />;
|
|
132
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TabBar } from '@/components/TabBar';
|
|
2
|
+
|
|
3
|
+
export function Editor({ filename, children }: any) {
|
|
4
|
+
return (
|
|
5
|
+
<div className="mt-5 mb-8 first:mt-0 last:mb-0 pt-2 bg-slate-800 rounded-xl shadow-lg overflow-hidden dark:ring-1 dark:ring-white/10 dark:ring-inset">
|
|
6
|
+
<TabBar primary={{ name: filename, saved: true }} showTabMarkers={false} />
|
|
7
|
+
<div className="children:my-0 children:!shadow-none children:bg-transparent relative">
|
|
8
|
+
{children}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode, useContext } from "react";
|
|
2
|
+
import { Expandable as GenericExpandable } from "@mintlify/components";
|
|
3
|
+
import AnalyticsContext from "@/analytics/AnalyticsContext";
|
|
4
|
+
|
|
5
|
+
export function Expandable({
|
|
6
|
+
title,
|
|
7
|
+
defaultOpen = false,
|
|
8
|
+
onChange: onChangeProp,
|
|
9
|
+
children,
|
|
10
|
+
}: {
|
|
11
|
+
title: string;
|
|
12
|
+
defaultOpen?: boolean;
|
|
13
|
+
onChange?: (open: boolean) => void;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}) {
|
|
16
|
+
const analyticsMediator = useContext(AnalyticsContext);
|
|
17
|
+
const openAnalyticsListener = analyticsMediator.createEventListener('expandable_open');
|
|
18
|
+
const closeAnalyticsListener = analyticsMediator.createEventListener('expandable_close');
|
|
19
|
+
|
|
20
|
+
const onChange = (open: boolean) => {
|
|
21
|
+
if (onChangeProp) {
|
|
22
|
+
onChangeProp(open);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (open) {
|
|
26
|
+
openAnalyticsListener({ title });
|
|
27
|
+
} else {
|
|
28
|
+
closeAnalyticsListener({ title });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<GenericExpandable
|
|
34
|
+
title={title}
|
|
35
|
+
onChange={onChange}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</GenericExpandable>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useEffect, useContext, useState } from 'react';
|
|
3
|
+
import { Rect, useRect } from 'react-use-rect';
|
|
4
|
+
|
|
5
|
+
import { useTop } from '@/hooks/useTop';
|
|
6
|
+
import { ContentsContext } from '@/layouts/ContentsLayout';
|
|
7
|
+
|
|
8
|
+
type HeadingProps = {
|
|
9
|
+
level: string;
|
|
10
|
+
id: string;
|
|
11
|
+
children: any;
|
|
12
|
+
className?: string;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
ignore?: boolean;
|
|
15
|
+
style?: Object;
|
|
16
|
+
nextElementDepth?: number | string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function Heading({
|
|
20
|
+
level,
|
|
21
|
+
id,
|
|
22
|
+
children,
|
|
23
|
+
className = '',
|
|
24
|
+
hidden = false,
|
|
25
|
+
ignore = false,
|
|
26
|
+
style = {},
|
|
27
|
+
nextElementDepth = -1,
|
|
28
|
+
...props
|
|
29
|
+
}: HeadingProps | any) {
|
|
30
|
+
let Component = `h${level}`;
|
|
31
|
+
const context: any = useContext(ContentsContext);
|
|
32
|
+
const [rect, setRect] = useState<Rect | null>(null);
|
|
33
|
+
const [rectRef] = useRect(setRect);
|
|
34
|
+
let top = useTop(rect);
|
|
35
|
+
|
|
36
|
+
// We cannot include context in the dependency array because it changes every render.
|
|
37
|
+
const hasContext = Boolean(context);
|
|
38
|
+
const registerHeading = context?.registerHeading;
|
|
39
|
+
const unregisterHeading = context?.unregisterHeading;
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!hasContext) return;
|
|
42
|
+
if (typeof top !== 'undefined') {
|
|
43
|
+
registerHeading(id, top);
|
|
44
|
+
}
|
|
45
|
+
return () => {
|
|
46
|
+
unregisterHeading(id);
|
|
47
|
+
};
|
|
48
|
+
}, [top, id, registerHeading, unregisterHeading, hasContext]);
|
|
49
|
+
return (
|
|
50
|
+
<Component
|
|
51
|
+
className={clsx('group flex whitespace-pre-wrap', className, {
|
|
52
|
+
'-ml-4 pl-4': !hidden,
|
|
53
|
+
'text-2xl sm:text-3xl': level === '1',
|
|
54
|
+
'mb-2 text-sm leading-6 text-primary font-semibold tracking-normal dark:text-primary-light':
|
|
55
|
+
level === '2' && nextElementDepth > level,
|
|
56
|
+
})}
|
|
57
|
+
id={id}
|
|
58
|
+
ref={rectRef}
|
|
59
|
+
style={{ ...(hidden ? { marginBottom: 0 } : {}), ...style }}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{!hidden && (
|
|
63
|
+
<a
|
|
64
|
+
href={`#${id}`}
|
|
65
|
+
className="absolute -ml-10 flex items-center opacity-0 border-0 group-hover:opacity-100"
|
|
66
|
+
aria-label="Anchor"
|
|
67
|
+
>
|
|
68
|
+
​
|
|
69
|
+
<div className="w-6 h-6 text-slate-400 ring-1 ring-slate-900/5 rounded-md shadow-sm flex items-center justify-center hover:ring-slate-900/10 hover:shadow hover:text-slate-700 dark:bg-slate-700 dark:text-slate-300 dark:shadow-none dark:ring-0">
|
|
70
|
+
<svg width="12" height="12" fill="none" aria-hidden="true">
|
|
71
|
+
<path
|
|
72
|
+
d="M3.75 1v10M8.25 1v10M1 3.75h10M1 8.25h10"
|
|
73
|
+
stroke="currentColor"
|
|
74
|
+
strokeWidth="1.5"
|
|
75
|
+
strokeLinecap="round"
|
|
76
|
+
/>
|
|
77
|
+
</svg>
|
|
78
|
+
</div>
|
|
79
|
+
</a>
|
|
80
|
+
)}
|
|
81
|
+
<span className={hidden ? 'sr-only' : undefined}>{children}</span>
|
|
82
|
+
</Component>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Param as GenericParam } from '@mintlify/components';
|
|
2
|
+
|
|
3
|
+
export type ParamProps = {
|
|
4
|
+
query?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
children: any;
|
|
8
|
+
default?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
hidden?: boolean;
|
|
12
|
+
|
|
13
|
+
// Used to flow data to the API Playground
|
|
14
|
+
last?: boolean;
|
|
15
|
+
placeholder?: any;
|
|
16
|
+
enum?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// 9/8/2022 - Migrate everyone off Param
|
|
20
|
+
export function Param(props: ParamProps) {
|
|
21
|
+
return <ParamField {...props} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Also props: query, body, path
|
|
25
|
+
export function ParamField({
|
|
26
|
+
query,
|
|
27
|
+
path,
|
|
28
|
+
body,
|
|
29
|
+
children,
|
|
30
|
+
default: defaultValue,
|
|
31
|
+
type,
|
|
32
|
+
required = false,
|
|
33
|
+
hidden = false,
|
|
34
|
+
last,
|
|
35
|
+
placeholder,
|
|
36
|
+
enum: enumValues,
|
|
37
|
+
}: ParamProps) {
|
|
38
|
+
if (!query && !path && !body) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const name = query || path || body;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<GenericParam
|
|
46
|
+
name={name!}
|
|
47
|
+
defaultValue={defaultValue}
|
|
48
|
+
type={type}
|
|
49
|
+
required={required}
|
|
50
|
+
hidden={hidden}
|
|
51
|
+
nameClasses="text-primary dark:text-primary-light"
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</GenericParam>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getMethodTextColor } from '@/utils/brands';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
|
|
4
|
+
// TO BE DEPRECATED after migrating Sieve
|
|
5
|
+
export function RequestSimple({
|
|
6
|
+
method,
|
|
7
|
+
children,
|
|
8
|
+
}: {
|
|
9
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
10
|
+
children: React.ReactChild;
|
|
11
|
+
}) {
|
|
12
|
+
const methodColor = getMethodTextColor(method);
|
|
13
|
+
return (
|
|
14
|
+
<div className="flex items-center space-x-4">
|
|
15
|
+
<div className={clsx('font-bold', methodColor)}>{method}</div>
|
|
16
|
+
<div className="flex-1 flex items-center font-mono">{children}</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Param as GenericParam } from '@mintlify/components';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
// The API playground detects all Params to generate the playground fields,
|
|
5
|
+
// so this cannot be replaced by the Param component even if the UI is the same.
|
|
6
|
+
export function ResponseField({
|
|
7
|
+
name,
|
|
8
|
+
type,
|
|
9
|
+
hidden,
|
|
10
|
+
default: defaultValue,
|
|
11
|
+
required,
|
|
12
|
+
children,
|
|
13
|
+
}: {
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
default?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}) {
|
|
21
|
+
return (
|
|
22
|
+
<GenericParam
|
|
23
|
+
name={name}
|
|
24
|
+
type={type}
|
|
25
|
+
hidden={hidden}
|
|
26
|
+
defaultValue={defaultValue}
|
|
27
|
+
required={required}
|
|
28
|
+
nameClasses="text-primary dark:text-primary-light"
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</GenericParam>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
export function TabBar({
|
|
5
|
+
primary,
|
|
6
|
+
secondary = [],
|
|
7
|
+
showTabMarkers = true,
|
|
8
|
+
side,
|
|
9
|
+
translucent = false,
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
primary: { name: string; saved: boolean };
|
|
13
|
+
secondary?: { name: string; saved: boolean; open?: boolean; className: string }[];
|
|
14
|
+
showTabMarkers?: boolean;
|
|
15
|
+
side?: string;
|
|
16
|
+
translucent?: boolean;
|
|
17
|
+
children?: ReactElement;
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<div className="flex text-slate-400 text-xs leading-6">
|
|
21
|
+
<div className="flex-none text-primary-light border-t border-b border-t-transparent border-b-primary-light px-4 py-1 flex items-center">
|
|
22
|
+
{primary.name}
|
|
23
|
+
{showTabMarkers &&
|
|
24
|
+
(primary.saved ? (
|
|
25
|
+
<svg
|
|
26
|
+
viewBox="0 0 4 4"
|
|
27
|
+
className="ml-2.5 flex-none w-1 h-1 text-slate-500 overflow-visible"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
d="M-1 -1L5 5M5 -1L-1 5"
|
|
31
|
+
fill="none"
|
|
32
|
+
stroke="currentColor"
|
|
33
|
+
strokeLinecap="round"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
) : (
|
|
37
|
+
<div className="ml-2.5 flex-none w-1 h-1 rounded-full bg-current" />
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
<div
|
|
41
|
+
className={clsx(
|
|
42
|
+
'flex-auto flex items-center bg-slate-700/50 border border-slate-500/30',
|
|
43
|
+
side === 'left' ? 'rounded-tl lg:rounded-tr' : 'rounded-tl',
|
|
44
|
+
translucent && 'dark:bg-slate-800/50'
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
{secondary.map(({ name, open = true, className }) => (
|
|
48
|
+
<div
|
|
49
|
+
key={name}
|
|
50
|
+
className={clsx('px-4 py-1 border-r border-slate-200/5', className, { italic: !open })}
|
|
51
|
+
>
|
|
52
|
+
{name}
|
|
53
|
+
</div>
|
|
54
|
+
))}
|
|
55
|
+
{children && (
|
|
56
|
+
<div className="flex-auto flex items-center justify-end px-4 space-x-4">{children}</div>
|
|
57
|
+
)}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|