docusaurus-plugin-typedoc-api
Version:
Docusaurus plugin that provides source code API documentation powered by TypeDoc.
51 lines (49 loc) • 2.22 kB
JavaScript
'use strict';
const react = require('react');
const Link = require('@docusaurus/Link');
const client = require('@docusaurus/plugin-content-docs/client');
const themeCommon = require('@docusaurus/theme-common');
const jsxRuntime = require('react/jsx-runtime');
const _interopDefault = e => e && e.__esModule ? e : {
default: e
};
const Link__default = /*#__PURE__*/_interopDefault(Link);
function VersionBanner() {
const _client$useDocsVersio = client.useDocsVersion(),
banner = _client$useDocsVersio.banner,
docs = _client$useDocsVersio.docs,
pluginId = _client$useDocsVersio.pluginId,
version = _client$useDocsVersio.version;
const _client$useDocVersion = client.useDocVersionSuggestions(pluginId),
latestVersion = _client$useDocVersion.latestVersionSuggestion;
const _client$useDocsPrefer = client.useDocsPreferredVersion(pluginId),
savePreferredVersionName = _client$useDocsPrefer.savePreferredVersionName;
const handleClick = react.useCallback(() => {
savePreferredVersionName(latestVersion.name);
}, [latestVersion.name, savePreferredVersionName]);
if (!banner || !latestVersion) {
return null;
}
const latestVersionInfo = docs[latestVersion.label];
return /*#__PURE__*/jsxRuntime.jsx("div", {
className: `${themeCommon.ThemeClassNames.docs.docVersionBanner} alert alert--warning margin-bottom--md`,
role: "alert",
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
children: [banner === 'unreleased' && /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
children: "This is documentation for an unreleased version."
}), banner === 'unmaintained' && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: ["This is documentation for version ", /*#__PURE__*/jsxRuntime.jsx("b", {
children: version
}), "."]
}), ' ', "For the latest API, see version", ' ', /*#__PURE__*/jsxRuntime.jsx("b", {
children: /*#__PURE__*/jsxRuntime.jsx(Link__default.default, {
to: latestVersionInfo.id,
onClick: handleClick,
children: latestVersionInfo.title
})
}), "."]
})
});
}
exports.VersionBanner = VersionBanner;
//# sourceMappingURL=VersionBanner.js.map