UNPKG

vue-styleguidist

Version:
62 lines 3.27 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import "core-js/modules/es.array.map.js"; import "core-js/modules/es.function.name.js"; import "core-js/modules/es.array.concat.js"; import "core-js/modules/es.object.keys.js"; import "core-js/modules/es.symbol.js"; import "core-js/modules/es.array.filter.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.object.get-own-property-descriptor.js"; import "core-js/modules/web.dom-collections.for-each.js"; import "core-js/modules/es.object.get-own-property-descriptors.js"; import getUrl from 'react-styleguidist/lib/client/utils/getUrl'; import processComponents from './processComponents'; import compileExamples from './compileExamples'; /** * Recursively process each component in all sections. * * @param {Array} sections * @return {Array} */ export default function processSections(_ref, _ref2) { var sections = _ref.sections, exampleFileNames = _ref.exampleFileNames; var useRouterLinks = _ref2.useRouterLinks, _ref2$useHashId = _ref2.useHashId, useHashId = _ref2$useHashId === void 0 ? false : _ref2$useHashId, _ref2$hashPath = _ref2.hashPath, hashPath = _ref2$hashPath === void 0 ? [] : _ref2$hashPath; return sections.map(function (section) { var options = { useRouterLinks: Boolean(useRouterLinks && section.name), useHashId: section.sectionDepth === 0, hashPath: [].concat(_toConsumableArray(hashPath), [section.name ? section.name : '-']) }; compileExamples(section.content || []); var _section$components = section.components, components = _section$components === void 0 ? [] : _section$components, sectionsInside = section.sections; var href = section.href || getUrl({ name: section.name, slug: section.slug, anchor: !useRouterLinks, hashPath: useRouterLinks ? hashPath : false, useSlugAsIdParam: useRouterLinks ? useHashId : false }); return _objectSpread(_objectSpread({}, section), {}, { visibleName: section.name, href: href, components: processComponents({ components: components, exampleFileNames: exampleFileNames }, options), sections: processSections({ sections: sectionsInside, exampleFileNames: exampleFileNames }, options) }); }); }