UNPKG

@redocly/theme

Version:

Shared UI components lib

22 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useThemeConfig = useThemeConfig; const react_1 = require("react"); const contexts_1 = require("../../core/contexts"); // TODO: rename and additionally export as alias for backward compatibility function useThemeConfig(useProductConfig = true) { const context = (0, react_1.useContext)(contexts_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