mintlify 1.0.7 → 1.0.9
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/README.md +21 -5
- package/bin/constants.js +12 -0
- package/bin/constants.js.map +1 -0
- package/bin/dev/getOpenApiContext.js +46 -0
- package/bin/dev/getOpenApiContext.js.map +1 -0
- package/bin/dev/index.js +164 -0
- package/bin/dev/index.js.map +1 -0
- package/bin/dev/injectNav.js +97 -0
- package/bin/dev/injectNav.js.map +1 -0
- package/bin/dev/slugToTitle.js +8 -0
- package/bin/dev/slugToTitle.js.map +1 -0
- package/bin/index.js +45 -224
- package/bin/index.js.map +1 -1
- package/bin/init-command/index.js +51 -0
- package/bin/init-command/index.js.map +1 -0
- package/bin/init-command/templates.js +41 -0
- package/bin/init-command/templates.js.map +1 -0
- package/bin/local-preview/categorizeFiles.js +56 -0
- package/bin/local-preview/categorizeFiles.js.map +1 -0
- package/bin/local-preview/getOpenApiContext.js +46 -0
- package/bin/local-preview/getOpenApiContext.js.map +1 -0
- package/bin/local-preview/index.js +154 -0
- package/bin/local-preview/index.js.map +1 -0
- package/bin/local-preview/injectFavicons.js +72 -0
- package/bin/local-preview/injectFavicons.js.map +1 -0
- package/bin/local-preview/listener.js +112 -0
- package/bin/local-preview/listener.js.map +1 -0
- package/bin/local-preview/metadata.js +121 -0
- package/bin/local-preview/metadata.js.map +1 -0
- package/bin/local-preview/mintConfigFile.js +43 -0
- package/bin/local-preview/mintConfigFile.js.map +1 -0
- package/bin/local-preview/openApiCheck.js +16 -0
- package/bin/local-preview/openApiCheck.js.map +1 -0
- package/bin/local-preview/slugToTitle.js +8 -0
- package/bin/local-preview/slugToTitle.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 +46 -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 +140 -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-to-docs.js +72 -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/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/navigation.js +4 -0
- package/bin/navigation.js.map +1 -0
- package/bin/pageTemplate.js +30 -0
- package/bin/pageTemplate.js.map +1 -0
- package/bin/scraping/combineNavWithEmptyGroupTitles.js +20 -0
- package/bin/scraping/combineNavWithEmptyGroupTitles.js.map +1 -0
- package/bin/scraping/getSitemapLinks.js +2 -0
- package/bin/scraping/getSitemapLinks.js.map +1 -1
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +43 -0
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -0
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +12 -41
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapePageCommands.js +48 -0
- package/bin/scraping/scrapePageCommands.js.map +1 -0
- package/bin/scraping/scrapeSectionCommands.js +90 -0
- package/bin/scraping/scrapeSectionCommands.js.map +1 -0
- package/bin/scraping/site-scrapers/getLinksRecursively.js +33 -0
- package/bin/scraping/site-scrapers/getLinksRecursively.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +1 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +25 -48
- 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 +10 -20
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -1
- package/bin/util.js +21 -1
- package/bin/util.js.map +1 -1
- package/bin/validation/isValidLink.js +11 -0
- package/bin/validation/isValidLink.js.map +1 -0
- package/bin/validation/stopIfInvalidLink.js +9 -0
- package/bin/validation/stopIfInvalidLink.js.map +1 -0
- package/package.json +21 -4
- package/src/constants.ts +20 -0
- package/src/index.ts +110 -272
- package/src/init-command/index.ts +59 -0
- package/src/{templates.ts → init-command/templates.ts} +0 -0
- package/src/local-preview/categorizeFiles.ts +74 -0
- package/src/local-preview/getOpenApiContext.ts +61 -0
- package/src/local-preview/index.ts +191 -0
- package/src/local-preview/injectFavicons.ts +76 -0
- package/src/local-preview/listener.ts +116 -0
- package/src/local-preview/metadata.ts +154 -0
- package/src/local-preview/mintConfigFile.ts +48 -0
- package/src/local-preview/openApiCheck.ts +19 -0
- package/src/local-preview/slugToTitle.ts +7 -0
- package/src/navigation.ts +12 -0
- package/src/pageTemplate.ts +32 -0
- package/src/scraping/combineNavWithEmptyGroupTitles.ts +21 -0
- package/src/scraping/getSitemapLinks.ts +2 -0
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +81 -0
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +27 -58
- package/src/scraping/scrapePageCommands.ts +52 -0
- package/src/scraping/scrapeSectionCommands.ts +110 -0
- package/src/scraping/site-scrapers/getLinksRecursively.ts +40 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +1 -1
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +31 -70
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +3 -1
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +21 -38
- package/src/util.ts +29 -1
- package/src/validation/isValidLink.ts +9 -0
- package/src/validation/stopIfInvalidLink.ts +9 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { brands, regular } from '@fortawesome/fontawesome-svg-core/import.macro';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import { Dialog } from '@headlessui/react';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import gh from 'github-url-to-object';
|
|
7
|
+
import Link from 'next/link';
|
|
8
|
+
import Router from 'next/router';
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Logo } from '@/ui/Logo';
|
|
12
|
+
import { SearchButton } from '@/ui/Search';
|
|
13
|
+
import getLogoHref from '@/utils/getLogoHref';
|
|
14
|
+
|
|
15
|
+
import { config, TopbarCta } from '../config';
|
|
16
|
+
import { ThemeSelect, ThemeToggle } from './ThemeToggle';
|
|
17
|
+
|
|
18
|
+
export function NavPopover({
|
|
19
|
+
display = 'md:hidden',
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}: {
|
|
23
|
+
display: string;
|
|
24
|
+
className: string;
|
|
25
|
+
}) {
|
|
26
|
+
let [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!isOpen) return;
|
|
30
|
+
function handleRouteChange() {
|
|
31
|
+
setIsOpen(false);
|
|
32
|
+
}
|
|
33
|
+
Router.events.on('routeChangeComplete', handleRouteChange);
|
|
34
|
+
return () => {
|
|
35
|
+
Router.events.off('routeChangeComplete', handleRouteChange);
|
|
36
|
+
};
|
|
37
|
+
}, [isOpen]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={clsx(className, display)} {...props}>
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="text-slate-500 w-8 h-8 flex items-center justify-center hover:text-slate-600 dark:text-slate-400 dark:hover:text-slate-300"
|
|
44
|
+
onClick={() => setIsOpen(true)}
|
|
45
|
+
>
|
|
46
|
+
<span className="sr-only">Navigation</span>
|
|
47
|
+
<svg width="24" height="24" fill="none" aria-hidden="true">
|
|
48
|
+
<path
|
|
49
|
+
d="M12 6v.01M12 12v.01M12 18v.01M12 7a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"
|
|
50
|
+
stroke="currentColor"
|
|
51
|
+
strokeWidth="1.5"
|
|
52
|
+
strokeLinecap="round"
|
|
53
|
+
strokeLinejoin="round"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
</button>
|
|
57
|
+
<Dialog
|
|
58
|
+
as="div"
|
|
59
|
+
className={clsx('fixed z-50 inset-0', display)}
|
|
60
|
+
open={isOpen}
|
|
61
|
+
onClose={setIsOpen}
|
|
62
|
+
>
|
|
63
|
+
<Dialog.Overlay className="fixed inset-0 bg-black/20 backdrop-blur-sm dark:bg-slate-900/80" />
|
|
64
|
+
<div className="fixed top-4 right-4 w-full max-w-xs bg-white rounded-lg shadow-lg p-6 text-base font-semibold text-slate-900 dark:bg-slate-800 dark:text-slate-400 dark:highlight-white/5">
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
className="absolute top-5 right-5 w-8 h-8 flex items-center justify-center text-slate-500 hover:text-slate-600 dark:text-slate-400 dark:hover:text-slate-300"
|
|
68
|
+
onClick={() => setIsOpen(false)}
|
|
69
|
+
>
|
|
70
|
+
<span className="sr-only">Close navigation</span>
|
|
71
|
+
<svg viewBox="0 0 10 10" className="w-2.5 h-2.5 overflow-visible" aria-hidden="true">
|
|
72
|
+
<path
|
|
73
|
+
d="M0 0L10 10M10 0L0 10"
|
|
74
|
+
fill="none"
|
|
75
|
+
stroke="currentColor"
|
|
76
|
+
strokeWidth="2"
|
|
77
|
+
strokeLinecap="round"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
</button>
|
|
81
|
+
<ul className="space-y-6">
|
|
82
|
+
<NavItems />
|
|
83
|
+
</ul>
|
|
84
|
+
<div className="mt-6 pt-6 border-t border-slate-200 dark:border-slate-200/10">
|
|
85
|
+
<ThemeSelect />
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</Dialog>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function GitHubCta({ button }: { button: TopbarCta }) {
|
|
94
|
+
const [repoData, setRepoData] = useState<{ stargazers_count: number; forks_count: number }>();
|
|
95
|
+
|
|
96
|
+
const github = gh(button.url);
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (github == null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
axios.get(`https://api.github.com/repos/${github.user}/${github.repo}`).then(({ data }) => {
|
|
104
|
+
setRepoData(data);
|
|
105
|
+
});
|
|
106
|
+
}, [github]);
|
|
107
|
+
|
|
108
|
+
if (github == null) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<li className="cursor-pointer">
|
|
114
|
+
<Link href={button.url}>
|
|
115
|
+
<div className="group flex items-center space-x-3">
|
|
116
|
+
<FontAwesomeIcon className="h-6 w-6" icon={brands('github-square')} />
|
|
117
|
+
<div className="font-normal">
|
|
118
|
+
<div className="text-sm font-medium text-slate-700 group-hover:text-slate-900 dark:text-slate-300 dark:group-hover:text-slate-200">
|
|
119
|
+
{github.user}/{github.repo}
|
|
120
|
+
</div>
|
|
121
|
+
{repoData ? (
|
|
122
|
+
<div className="text-xs flex items-center space-x-2 text-slate-600 dark:text-slate-400 group-hover:text-slate-700 dark:group-hover:text-slate-300">
|
|
123
|
+
<span className="flex items-center space-x-1">
|
|
124
|
+
<FontAwesomeIcon className="h-3 w-3" icon={regular('star')} />
|
|
125
|
+
<span>{repoData.stargazers_count}</span>
|
|
126
|
+
</span>
|
|
127
|
+
<span className="flex items-center space-x-1">
|
|
128
|
+
<FontAwesomeIcon className="h-3 w-3" icon={regular('code-fork')} />
|
|
129
|
+
<span>{repoData.forks_count}</span>
|
|
130
|
+
</span>
|
|
131
|
+
</div>
|
|
132
|
+
) : (
|
|
133
|
+
<div className="h-4" />
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</Link>
|
|
138
|
+
</li>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function TopBarCtaButton({ button }: { button: TopbarCta }) {
|
|
143
|
+
if (button.type === 'github') {
|
|
144
|
+
return <GitHubCta button={button} />;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<li>
|
|
149
|
+
<Link href={button.url}>
|
|
150
|
+
<a
|
|
151
|
+
target="_blank"
|
|
152
|
+
className={clsx(
|
|
153
|
+
config.classes?.topbarCtaButton ||
|
|
154
|
+
'relative inline-flex items-center space-x-1 px-4 py-1 border border-transparent shadow-sm text-sm font-medium rounded-[0.3rem] text-white bg-primary-dark hover:bg-primary-ultradark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-primary-light'
|
|
155
|
+
)}
|
|
156
|
+
>
|
|
157
|
+
<span>{button.name}</span>
|
|
158
|
+
{!config.classes?.topbarCtaButton && (
|
|
159
|
+
<svg
|
|
160
|
+
className="h-2.5 text-white"
|
|
161
|
+
fill="currentColor"
|
|
162
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
163
|
+
viewBox="0 0 320 512"
|
|
164
|
+
>
|
|
165
|
+
<path d="M96 480c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L242.8 256L73.38 86.63c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l192 192c12.5 12.5 12.5 32.75 0 45.25l-192 192C112.4 476.9 104.2 480 96 480z" />
|
|
166
|
+
</svg>
|
|
167
|
+
)}
|
|
168
|
+
</a>
|
|
169
|
+
</Link>
|
|
170
|
+
</li>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function NavItems() {
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
{config?.topbarLinks?.map((topbarLink) => (
|
|
178
|
+
<li key={topbarLink.name}>
|
|
179
|
+
<Link href={topbarLink.url}>
|
|
180
|
+
<a className="font-medium hover:text-primary dark:hover:text-primary-light">
|
|
181
|
+
{topbarLink.name}
|
|
182
|
+
</a>
|
|
183
|
+
</Link>
|
|
184
|
+
</li>
|
|
185
|
+
))}
|
|
186
|
+
{config?.topbarCtaButton && <TopBarCtaButton button={config.topbarCtaButton} />}
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function Header({
|
|
192
|
+
hasNav = false,
|
|
193
|
+
navIsOpen,
|
|
194
|
+
onNavToggle,
|
|
195
|
+
title,
|
|
196
|
+
section,
|
|
197
|
+
}: {
|
|
198
|
+
hasNav: boolean;
|
|
199
|
+
navIsOpen: boolean;
|
|
200
|
+
onNavToggle: (toggle: boolean) => void;
|
|
201
|
+
title?: string;
|
|
202
|
+
section?: string;
|
|
203
|
+
}) {
|
|
204
|
+
let [isOpaque, setIsOpaque] = useState(false);
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
let offset = 50;
|
|
208
|
+
function onScroll() {
|
|
209
|
+
if (!isOpaque && window.scrollY > offset) {
|
|
210
|
+
setIsOpaque(true);
|
|
211
|
+
} else if (isOpaque && window.scrollY <= offset) {
|
|
212
|
+
setIsOpaque(false);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
onScroll();
|
|
216
|
+
window.addEventListener('scroll', onScroll, { passive: true });
|
|
217
|
+
return () => {
|
|
218
|
+
window.removeEventListener('scroll', onScroll);
|
|
219
|
+
};
|
|
220
|
+
}, [isOpaque]);
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<>
|
|
224
|
+
<div
|
|
225
|
+
className={clsx(
|
|
226
|
+
'sticky top-0 w-full backdrop-blur flex-none transition-colors z-40 duration-500 lg:border-b lg:border-slate-900/5 dark:border-slate-50/[0.06] lg:z-50',
|
|
227
|
+
isOpaque
|
|
228
|
+
? 'bg-background-light/90 supports-backdrop-blur:bg-background-light/90 dark:bg-background-dark/75'
|
|
229
|
+
: 'bg-transparent dark:bg-transparent'
|
|
230
|
+
)}
|
|
231
|
+
>
|
|
232
|
+
<div className="max-w-8xl mx-auto">
|
|
233
|
+
<div
|
|
234
|
+
className={clsx(
|
|
235
|
+
'py-4 border-b border-slate-900/10 lg:px-8 lg:border-0 dark:border-slate-300/10',
|
|
236
|
+
hasNav ? 'mx-4 lg:mx-0' : 'px-4'
|
|
237
|
+
)}
|
|
238
|
+
>
|
|
239
|
+
<div className="relative flex items-center">
|
|
240
|
+
<div className="flex-1">
|
|
241
|
+
<Link href={getLogoHref(config)}>
|
|
242
|
+
<a
|
|
243
|
+
onContextMenu={(e) => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
Router.push(getLogoHref(config));
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
<span className="sr-only">{config.name} home page</span>
|
|
249
|
+
<Logo />
|
|
250
|
+
</a>
|
|
251
|
+
</Link>
|
|
252
|
+
</div>
|
|
253
|
+
<div className="relative flex-none bg-white lg:w-64 xl:w-80 dark:bg-slate-900 pointer-events-auto rounded-md">
|
|
254
|
+
<SearchButton className="hidden w-full lg:flex items-center text-sm leading-6 text-slate-400 rounded-md ring-1 ring-slate-500/10 shadow-sm py-1.5 pl-2 pr-3 bg-slate-50 hover:ring-slate-900/20 dark:bg-slate-800 dark:highlight-white/5 dark:hover:bg-slate-700">
|
|
255
|
+
{({ actionKey }: any) => (
|
|
256
|
+
<>
|
|
257
|
+
<svg
|
|
258
|
+
width="24"
|
|
259
|
+
height="24"
|
|
260
|
+
fill="none"
|
|
261
|
+
aria-hidden="true"
|
|
262
|
+
className="mr-3 flex-none"
|
|
263
|
+
>
|
|
264
|
+
<path
|
|
265
|
+
d="m19 19-3.5-3.5"
|
|
266
|
+
stroke="currentColor"
|
|
267
|
+
strokeWidth="2"
|
|
268
|
+
strokeLinecap="round"
|
|
269
|
+
strokeLinejoin="round"
|
|
270
|
+
/>
|
|
271
|
+
<circle
|
|
272
|
+
cx="11"
|
|
273
|
+
cy="11"
|
|
274
|
+
r="6"
|
|
275
|
+
stroke="currentColor"
|
|
276
|
+
strokeWidth="2"
|
|
277
|
+
strokeLinecap="round"
|
|
278
|
+
strokeLinejoin="round"
|
|
279
|
+
/>
|
|
280
|
+
</svg>
|
|
281
|
+
Search...
|
|
282
|
+
{actionKey && (
|
|
283
|
+
<span className="ml-auto flex-none text-xs font-semibold">
|
|
284
|
+
{actionKey[0]}K
|
|
285
|
+
</span>
|
|
286
|
+
)}
|
|
287
|
+
</>
|
|
288
|
+
)}
|
|
289
|
+
</SearchButton>
|
|
290
|
+
</div>
|
|
291
|
+
<div className="flex-1 relative hidden lg:flex items-center ml-auto justify-end">
|
|
292
|
+
<nav className="text-sm leading-6 font-semibold text-slate-700 dark:text-slate-200">
|
|
293
|
+
<ul className="flex space-x-8 items-center">
|
|
294
|
+
<NavItems />
|
|
295
|
+
</ul>
|
|
296
|
+
</nav>
|
|
297
|
+
<div className="flex items-center border-l border-slate-100 ml-6 pl-6 dark:border-slate-800">
|
|
298
|
+
<ThemeToggle panelClassName="mt-8" />
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
<SearchButton className="ml-auto text-slate-500 w-8 h-8 -my-1 flex items-center justify-center hover:text-slate-600 lg:hidden dark:text-slate-400 dark:hover:text-slate-300">
|
|
302
|
+
<span className="sr-only">Search</span>
|
|
303
|
+
<svg
|
|
304
|
+
width="24"
|
|
305
|
+
height="24"
|
|
306
|
+
fill="none"
|
|
307
|
+
stroke="currentColor"
|
|
308
|
+
strokeWidth="2"
|
|
309
|
+
strokeLinecap="round"
|
|
310
|
+
strokeLinejoin="round"
|
|
311
|
+
aria-hidden="true"
|
|
312
|
+
>
|
|
313
|
+
<path d="m19 19-3.5-3.5" />
|
|
314
|
+
<circle cx="11" cy="11" r="6" />
|
|
315
|
+
</svg>
|
|
316
|
+
</SearchButton>
|
|
317
|
+
<NavPopover className="ml-2 -my-1" display="lg:hidden" />
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
{hasNav && (
|
|
321
|
+
<div className="flex items-center p-4 border-b border-slate-900/10 lg:hidden dark:border-slate-50/[0.06]">
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
onClick={() => onNavToggle(!navIsOpen)}
|
|
325
|
+
className="text-slate-500 hover:text-slate-600 dark:text-slate-400 dark:hover:text-slate-300"
|
|
326
|
+
>
|
|
327
|
+
<span className="sr-only">Navigation</span>
|
|
328
|
+
<svg width="24" height="24">
|
|
329
|
+
<path
|
|
330
|
+
d="M5 6h14M5 12h14M5 18h14"
|
|
331
|
+
fill="none"
|
|
332
|
+
stroke="currentColor"
|
|
333
|
+
strokeWidth="2"
|
|
334
|
+
strokeLinecap="round"
|
|
335
|
+
/>
|
|
336
|
+
</svg>
|
|
337
|
+
</button>
|
|
338
|
+
{title && (
|
|
339
|
+
<ol className="ml-4 flex text-sm leading-6 whitespace-nowrap min-w-0">
|
|
340
|
+
{section && (
|
|
341
|
+
<li className="flex items-center">
|
|
342
|
+
{section}
|
|
343
|
+
<svg
|
|
344
|
+
width="3"
|
|
345
|
+
height="6"
|
|
346
|
+
aria-hidden="true"
|
|
347
|
+
className="mx-3 overflow-visible text-slate-400"
|
|
348
|
+
>
|
|
349
|
+
<path
|
|
350
|
+
d="M0 0L3 3L0 6"
|
|
351
|
+
fill="none"
|
|
352
|
+
stroke="currentColor"
|
|
353
|
+
strokeWidth="1.5"
|
|
354
|
+
strokeLinecap="round"
|
|
355
|
+
/>
|
|
356
|
+
</svg>
|
|
357
|
+
</li>
|
|
358
|
+
)}
|
|
359
|
+
<li className="font-semibold text-slate-900 truncate dark:text-slate-200">
|
|
360
|
+
{title}
|
|
361
|
+
</li>
|
|
362
|
+
</ol>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
|
|
4
|
+
import { config } from '@/config';
|
|
5
|
+
|
|
6
|
+
export function Logo() {
|
|
7
|
+
const className = clsx('w-auto h-7 relative', config.classes?.logo);
|
|
8
|
+
if (typeof config.logo === 'object' && config.logo !== null) {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<div className={clsx(className, 'block dark:hidden')}>
|
|
12
|
+
<Image
|
|
13
|
+
src={config?.logo.light}
|
|
14
|
+
alt="light logo"
|
|
15
|
+
layout="fill"
|
|
16
|
+
objectFit="contain"
|
|
17
|
+
objectPosition="left"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
<div className={clsx(className, 'hidden dark:block')}>
|
|
21
|
+
<Image
|
|
22
|
+
src={config?.logo.dark}
|
|
23
|
+
alt="dark logo"
|
|
24
|
+
layout="fill"
|
|
25
|
+
objectFit="contain"
|
|
26
|
+
objectPosition="left"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (config?.logo) {
|
|
33
|
+
return (
|
|
34
|
+
<div className={clsx(className)}>
|
|
35
|
+
<Image
|
|
36
|
+
src={config?.logo}
|
|
37
|
+
alt="logo"
|
|
38
|
+
layout="fill"
|
|
39
|
+
objectFit="contain"
|
|
40
|
+
objectPosition="left"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (config?.name) {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className={`inline-block text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight dark:text-slate-200 ${className}`}
|
|
49
|
+
>
|
|
50
|
+
{config?.name}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return <></>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { UserFeedback } from '@/layouts/UserFeedback';
|
|
2
|
+
import { Api, ApiComponent } from '@/ui/Api';
|
|
3
|
+
|
|
4
|
+
type PageHeaderProps = {
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
api?: string;
|
|
8
|
+
openapi?: string;
|
|
9
|
+
auth?: string;
|
|
10
|
+
section: string;
|
|
11
|
+
children: any;
|
|
12
|
+
apiComponents: ApiComponent[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function PageHeader({
|
|
16
|
+
title,
|
|
17
|
+
description,
|
|
18
|
+
section,
|
|
19
|
+
api,
|
|
20
|
+
auth,
|
|
21
|
+
children,
|
|
22
|
+
apiComponents,
|
|
23
|
+
}: PageHeaderProps) {
|
|
24
|
+
if (!title && !description) return null;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<header id="header" className="relative z-20">
|
|
28
|
+
<div>
|
|
29
|
+
<div className="flex">
|
|
30
|
+
<div className="flex-1">
|
|
31
|
+
{section && (
|
|
32
|
+
<p className="mb-2 text-sm leading-6 font-semibold text-primary dark:text-primary-light">
|
|
33
|
+
{section}
|
|
34
|
+
</p>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
<UserFeedback title="" />
|
|
38
|
+
</div>
|
|
39
|
+
<div className="flex items-center">
|
|
40
|
+
<h1 className="inline-block text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight dark:text-slate-200">
|
|
41
|
+
{title}
|
|
42
|
+
</h1>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
{description && (
|
|
46
|
+
<p className="mt-2 text-lg text-slate-700 dark:text-slate-400">{description}</p>
|
|
47
|
+
)}
|
|
48
|
+
{api && <Api api={api} children={children} auth={auth} apiComponents={apiComponents} />}
|
|
49
|
+
</header>
|
|
50
|
+
);
|
|
51
|
+
}
|