How to use the bisheng/collect function in bisheng

To help you get started, we’ve selected a few bisheng examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ant-design / ant-design-mobile / site / kitchen / src / template / KitchenSink / Demo.jsx View on Github external
/* eslint react/no-danger: 0 */
import React from 'react';
import ReactDOM from 'react-dom';
import WhiteSpace from 'antd-mobile/lib/white-space';
import 'antd-mobile/lib/white-space/style';
import Button from 'antd-mobile/lib/button';
import 'antd-mobile/lib/button/style';
import WingBlank from 'antd-mobile/lib/wing-blank';
import 'antd-mobile/lib/wing-blank/style';
import NoticeBar from 'antd-mobile/lib/notice-bar';
import 'antd-mobile/lib/notice-bar/style';
import collect from 'bisheng/collect';
import { getQuery } from '../../../../utils';

@collect(async (nextProps) => {
  const { pathname } = nextProps.location;
  const pageDataPath = pathname.replace('-cn', '').split('/');
  const pageData = nextProps.utils.get(nextProps.data, pageDataPath);
  if (!pageData) {
    throw 404; // eslint-disable-line no-throw-literal
  }

  const locale = getQuery('lang') || 'en-US';
  const pageDataPromise = typeof pageData === 'function' ?
    pageData() : (pageData[locale] || pageData.index[locale] || pageData.index)();
  const demosFetcher = nextProps.utils.get(nextProps.data, ['components', nextProps.params.component, 'demo']);
  if (demosFetcher) {
    const [localizedPageData, demos] = await Promise.all([pageDataPromise, demosFetcher()]);
    return { localizedPageData, demos, locale };
  }

bisheng

Transform Markdown(and other static files with transformers) into a SPA website using React.

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis