UNPKG

@redocly/theme

Version:

Shared UI components lib

23 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useThemeConfig = useThemeConfig; const react_1 = require("react"); const ThemeDataContext_1 = require("../contexts/ThemeDataContext"); // eslint-disable-next-line no-warning-comments // TODO: rename and additionally export as alias for backward compatibility function useThemeConfig(useProductConfig = true) { const context = (0, react_1.useContext)(ThemeDataContext_1.ThemeDataContext); if (!(context === null || context === void 0 ? void 0 : context.config)) { return {}; } const { config, hooks } = context; const { useCurrentProduct } = hooks; // eslint-disable-next-line react-hooks/rules-of-hooks const currentProduct = useCurrentProduct(); const mergedConfig = useProductConfig && (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) ? Object.assign(Object.assign(Object.assign({}, config), currentProduct.configOverride), { // Do not override analytics config from product analytics: config.analytics }) : config; return mergedConfig; } //# sourceMappingURL=use-theme-config.js.map