mintlify 1.1.1 → 1.1.2
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/bin/index.js +2 -3
- package/bin/index.js.map +1 -1
- package/bin/local-preview/helper-commands/clearCommand.js +4 -4
- package/bin/local-preview/helper-commands/clearCommand.js.map +1 -1
- package/bin/local-preview/index.js +43 -4
- package/bin/local-preview/index.js.map +1 -1
- package/bin/local-preview/injectNav.js +94 -0
- package/bin/local-preview/injectNav.js.map +1 -0
- package/bin/local-preview/utils/listener.js +1 -1
- package/bin/local-preview/utils/listener.js.map +1 -1
- 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/downloadAllImages.js +4 -0
- package/bin/scraping/downloadAllImages.js.map +1 -1
- package/bin/scraping/scrapeSectionCommands.js +18 -46
- package/bin/scraping/scrapeSectionCommands.js.map +1 -1
- package/bin/scraping/site-scrapers/alternateGroupTitle.js +9 -0
- package/bin/scraping/site-scrapers/alternateGroupTitle.js.map +1 -0
- package/bin/scraping/site-scrapers/getLinksRecursively.js +7 -2
- package/bin/scraping/site-scrapers/getLinksRecursively.js.map +1 -1
- package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js +30 -0
- package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js.map +1 -0
- package/bin/scraping/site-scrapers/openNestedGitbookMenus.js +37 -0
- package/bin/scraping/site-scrapers/openNestedGitbookMenus.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +20 -21
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +2 -9
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/local-preview/helper-commands/clearCommand.ts +6 -4
- package/src/local-preview/index.ts +48 -3
- package/src/local-preview/utils/listener.ts +1 -1
- package/src/scraping/downloadAllImages.ts +5 -0
- package/src/scraping/scrapeSectionCommands.ts +34 -60
- package/src/scraping/site-scrapers/alternateGroupTitle.ts +8 -0
- package/src/scraping/site-scrapers/getLinksRecursively.ts +7 -2
- package/src/scraping/site-scrapers/openNestedDocusaurusMenus.ts +42 -0
- package/src/scraping/site-scrapers/openNestedGitbookMenus.ts +49 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +23 -21
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +2 -10
- package/bin/local-preview/helper-commands/cleanCommand.js +0 -8
- package/bin/local-preview/helper-commands/cleanCommand.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { toHtml } from 'hast-util-to-html';
|
|
2
|
+
import { filter } from 'unist-util-filter';
|
|
3
|
+
import visit from 'unist-util-visit';
|
|
4
|
+
|
|
5
|
+
import { addExport } from '../remark/utils.js';
|
|
6
|
+
|
|
7
|
+
const langFilename = (className) => {
|
|
8
|
+
switch (className) {
|
|
9
|
+
case 'language-shell':
|
|
10
|
+
return 'Bash';
|
|
11
|
+
case 'language-json':
|
|
12
|
+
return 'JSON';
|
|
13
|
+
case 'language-js':
|
|
14
|
+
return 'JavaScript';
|
|
15
|
+
default:
|
|
16
|
+
const language = className.substring(9);
|
|
17
|
+
return language.charAt(0).toUpperCase() + language.slice(1);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const withApiComponents = () => {
|
|
21
|
+
return (tree) => {
|
|
22
|
+
let apiComponents = [];
|
|
23
|
+
visit(tree, 'mdxJsxFlowElement', (node, _, parent) => {
|
|
24
|
+
if (['ResponseExample', 'RequestExample'].includes(node.name)) {
|
|
25
|
+
// remove all jsx components to convert to html (removes <ResponseExample> and <Editor>)
|
|
26
|
+
const children = node.children.map((child, i) => {
|
|
27
|
+
const preComponent = child.children[0];
|
|
28
|
+
const html = toHtml(preComponent);
|
|
29
|
+
let filename =
|
|
30
|
+
preComponent?.properties?.className?.length > 1
|
|
31
|
+
? langFilename(preComponent?.properties?.className[0])
|
|
32
|
+
: '';
|
|
33
|
+
if (child?.attributes && child.attributes.length > 0) {
|
|
34
|
+
filename = child.attributes[0]?.value;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
filename,
|
|
38
|
+
html,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
apiComponents.push({
|
|
42
|
+
type: node.name,
|
|
43
|
+
children,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (parent.type === 'root' && (node.name === 'Param' || node.name === 'ParamField')) {
|
|
48
|
+
apiComponents.push({
|
|
49
|
+
type: 'ParamField',
|
|
50
|
+
children: node.children,
|
|
51
|
+
attributes: node.attributes,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
addExport(tree, 'apiComponents', apiComponents);
|
|
56
|
+
return filter(tree, (node) => !['ResponseExample', 'RequestExample'].includes(node.name));
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default withApiComponents;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { fromHtml } from 'hast-util-from-html';
|
|
2
|
+
import visit from 'unist-util-visit';
|
|
3
|
+
|
|
4
|
+
import { addImport } from '../remark/utils.js';
|
|
5
|
+
|
|
6
|
+
const withCodeBlocks = () => {
|
|
7
|
+
return (tree) => {
|
|
8
|
+
let preTree = { children: [] };
|
|
9
|
+
let componentName;
|
|
10
|
+
|
|
11
|
+
visit(tree, 'element', (node, i, parent) => {
|
|
12
|
+
if (node?.tagName !== 'pre') return node;
|
|
13
|
+
if (node?.children && node?.children[0]?.tagName !== 'code') return node;
|
|
14
|
+
const code = node.children[0];
|
|
15
|
+
const copyToClipboard = fromHtml(
|
|
16
|
+
`<span class="copy-to-clipboard w-5 z-10 flex absolute right-5"><svg class="top-5 h-5 fill-slate-500 hover:fill-slate-300 cursor-pointer" viewBox="0 0 20 20"><path d="M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" /><path d="M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z" /></svg><div class="tooltip hidden absolute bottom-full left-1/2 mb-3.5 pb-1 -translate-x-1/2"><div class="relative bg-primary-dark text-white text-xs leading-6 font-medium px-1.5 rounded-lg" data-reach-alert="true"><span>Copied</span><svg aria-hidden="true" width="16" height="6" viewBox="0 0 16 6" class="text-primary-dark absolute top-full left-1/2 -mt-px -ml-2"><path fillRule="evenodd" clipRule="evenodd" d="M15 0H1V1.00366V1.00366V1.00371H1.01672C2.72058 1.0147 4.24225 2.74704 5.42685 4.72928C6.42941 6.40691 9.57154 6.4069 10.5741 4.72926C11.7587 2.74703 13.2803 1.0147 14.9841 1.00371H15V0Z" fill="currentColor"></path></svg></div></div></span>`,
|
|
17
|
+
{ fragment: true }
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const prepend = (value, array) => {
|
|
21
|
+
var newArray = array.slice();
|
|
22
|
+
newArray.unshift(value);
|
|
23
|
+
return newArray;
|
|
24
|
+
};
|
|
25
|
+
node.children = prepend(copyToClipboard, node.children);
|
|
26
|
+
let filename = undefined;
|
|
27
|
+
if (['RequestExample', 'ResponseExample'].includes(parent.name)) {
|
|
28
|
+
const parentType = parent.name.slice(0, -7);
|
|
29
|
+
filename = i === 0 ? parentType : `${parentType} ${i + 1}`;
|
|
30
|
+
node.children[0].data.meta = filename;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (code.data?.meta) {
|
|
34
|
+
filename = code.data.meta;
|
|
35
|
+
}
|
|
36
|
+
if (filename) {
|
|
37
|
+
if (!componentName) {
|
|
38
|
+
componentName = addImport(preTree, '@/components/Editor', 'Editor');
|
|
39
|
+
}
|
|
40
|
+
const wrap = {
|
|
41
|
+
type: 'mdxJsxFlowElement',
|
|
42
|
+
name: componentName,
|
|
43
|
+
attributes: [{ type: 'mdxJsxAttribute', name: 'filename', value: filename }],
|
|
44
|
+
data: { _mdxExplicitJsx: true },
|
|
45
|
+
};
|
|
46
|
+
wrap.children = [node];
|
|
47
|
+
parent.children[i] = wrap;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
tree.children = [...preTree.children, ...tree.children];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default withCodeBlocks;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getEsmNode } from '../remark/utils.js';
|
|
2
|
+
|
|
3
|
+
const withLayouts = () => {
|
|
4
|
+
return (tree) => {
|
|
5
|
+
const importNode = getEsmNode(
|
|
6
|
+
`import { ContentsLayout as _Default } from '@/layouts/ContentsLayout'`
|
|
7
|
+
);
|
|
8
|
+
tree.children.unshift(importNode);
|
|
9
|
+
tree.children.push({
|
|
10
|
+
type: 'mdxjsEsm',
|
|
11
|
+
value: `export default (props) => <_Default {...props} tableOfContents={tableOfContents} apiComponents={apiComponents}>{props.children}</_Default>`,
|
|
12
|
+
data: {
|
|
13
|
+
estree: {
|
|
14
|
+
type: 'Program',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
body: [
|
|
17
|
+
{
|
|
18
|
+
type: 'ExportDefaultDeclaration',
|
|
19
|
+
declaration: {
|
|
20
|
+
type: 'ArrowFunctionExpression',
|
|
21
|
+
async: false,
|
|
22
|
+
expression: true,
|
|
23
|
+
generator: false,
|
|
24
|
+
id: null,
|
|
25
|
+
body: {
|
|
26
|
+
type: 'JSXElement',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
type: 'JSXExpressionContainer',
|
|
30
|
+
expression: {
|
|
31
|
+
type: 'MemberExpression',
|
|
32
|
+
computed: false,
|
|
33
|
+
optional: false,
|
|
34
|
+
object: {
|
|
35
|
+
name: 'props',
|
|
36
|
+
type: 'Identifier',
|
|
37
|
+
},
|
|
38
|
+
property: {
|
|
39
|
+
name: 'children',
|
|
40
|
+
type: 'Identifier',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
closingElement: {
|
|
46
|
+
type: 'JSXClosingElement',
|
|
47
|
+
name: {
|
|
48
|
+
type: 'JSXIdentifier',
|
|
49
|
+
name: '_Default',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
openingElement: {
|
|
53
|
+
type: 'JSXOpeningElement',
|
|
54
|
+
selfClosing: false,
|
|
55
|
+
name: {
|
|
56
|
+
type: 'JSXIdentifier',
|
|
57
|
+
name: '_Default',
|
|
58
|
+
},
|
|
59
|
+
attributes: [
|
|
60
|
+
{
|
|
61
|
+
type: 'JSXSpreadAttribute',
|
|
62
|
+
argument: {
|
|
63
|
+
type: 'Identifier',
|
|
64
|
+
name: 'props',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'JSXAttribute',
|
|
69
|
+
name: {
|
|
70
|
+
type: 'JSXIdentifier',
|
|
71
|
+
name: 'tableOfContents',
|
|
72
|
+
},
|
|
73
|
+
value: {
|
|
74
|
+
type: 'JSXExpressionContainer',
|
|
75
|
+
expression: {
|
|
76
|
+
type: 'Identifier',
|
|
77
|
+
name: 'tableOfContents',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'JSXAttribute',
|
|
83
|
+
name: {
|
|
84
|
+
type: 'JSXIdentifier',
|
|
85
|
+
name: 'apiComponents',
|
|
86
|
+
},
|
|
87
|
+
value: {
|
|
88
|
+
type: 'JSXExpressionContainer',
|
|
89
|
+
expression: {
|
|
90
|
+
type: 'Identifier',
|
|
91
|
+
name: 'apiComponents',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
params: [
|
|
99
|
+
{
|
|
100
|
+
type: 'Identifier',
|
|
101
|
+
name: 'props',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default withLayouts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import visit from 'unist-util-visit';
|
|
2
|
+
|
|
3
|
+
const withLinkRoles = () => {
|
|
4
|
+
return (tree) => {
|
|
5
|
+
visit(tree, 'element', (element) => {
|
|
6
|
+
if (['ol', 'ul'].includes(element.tagName)) {
|
|
7
|
+
element.properties.role = 'list';
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default withLinkRoles;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fromHtml } from 'hast-util-from-html';
|
|
2
|
+
import visit from 'unist-util-visit';
|
|
3
|
+
|
|
4
|
+
const withRawComponents = () => {
|
|
5
|
+
return (tree) => {
|
|
6
|
+
visit(tree, 'raw', (raw, i, parent) => {
|
|
7
|
+
const rawAst = fromHtml(raw.value, { fragment: true });
|
|
8
|
+
parent.children[i] = rawAst;
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default withRawComponents;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parse } from 'acorn';
|
|
2
|
+
|
|
3
|
+
const withStaticProps = (map) => {
|
|
4
|
+
return function transformer(tree) {
|
|
5
|
+
tree.children.push({
|
|
6
|
+
type: 'mdxjsEsm',
|
|
7
|
+
data: {
|
|
8
|
+
estree: parse(
|
|
9
|
+
`
|
|
10
|
+
export const getStaticProps = async () => {
|
|
11
|
+
return {
|
|
12
|
+
props: ${map},
|
|
13
|
+
}
|
|
14
|
+
}`,
|
|
15
|
+
{
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
ecmaVersion: 2020,
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default withStaticProps;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { toString } from 'hast-util-to-string';
|
|
2
|
+
import { refractor } from 'refractor';
|
|
3
|
+
import docker from 'refractor/lang/docker.js';
|
|
4
|
+
import jsx from 'refractor/lang/jsx.js';
|
|
5
|
+
import protobuf from 'refractor/lang/protobuf.js';
|
|
6
|
+
import visit from 'unist-util-visit';
|
|
7
|
+
|
|
8
|
+
refractor.register(jsx);
|
|
9
|
+
refractor.register(docker);
|
|
10
|
+
refractor.register(protobuf);
|
|
11
|
+
|
|
12
|
+
const withSyntaxHighlighting = (options) => {
|
|
13
|
+
options = options || {};
|
|
14
|
+
|
|
15
|
+
if (options.alias) {
|
|
16
|
+
refractor.alias(options.alias);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (tree) => {
|
|
20
|
+
visit(tree, 'element', visitor);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function visitor(node, _, parent) {
|
|
24
|
+
if (!parent || parent.tagName !== 'pre' || node.tagName !== 'code') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const lang = getLanguage(node);
|
|
29
|
+
|
|
30
|
+
if (lang === null) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let result;
|
|
35
|
+
try {
|
|
36
|
+
parent.properties.className = (parent.properties.className || []).concat('language-' + lang);
|
|
37
|
+
result = refractor.highlight(toString(node), lang);
|
|
38
|
+
node.children = result.children;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (options.ignoreMissing && /Unknown language/.test(err.message)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function getLanguage(node) {
|
|
49
|
+
const className = node.properties.className || [];
|
|
50
|
+
|
|
51
|
+
for (const classListItem of className) {
|
|
52
|
+
if (classListItem.slice(0, 9) === 'language-') {
|
|
53
|
+
return classListItem.slice(9).toLowerCase();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default withSyntaxHighlighting;
|