Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

title allowed to be empty #17

Merged
merged 1 commit into from
Dec 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/umi-plugin-father-doc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import assert from 'assert';
import { isPlainObject } from 'lodash';
import { IApi, IRoute } from 'umi-types';
import getRouteConfig from './routes/getRouteConfig';
import getMenuFromRoutes from'./routes/getMenuFromRoutes';
import getMenuFromRoutes from './routes/getMenuFromRoutes';
import getHostPkgAlias from './utils/getHostPkgAlias';

export interface IFatherDocOpts {
Expand Down Expand Up @@ -37,9 +37,10 @@ function docConfigPlugin() {

export default function (api: IApi, opts: IFatherDocOpts) {
// apply default options
const defaultTitle = require(path.join(api.paths.cwd, 'package.json')).name;
opts = Object.assign(
{
title: require(path.join(api.paths.cwd, 'package.json')).name,
title: defaultTitle,
include: ['docs'],
},
{
Expand All @@ -56,7 +57,7 @@ export default function (api: IApi, opts: IFatherDocOpts) {
api.registerPlugin({
id: require.resolve('umi-plugin-react'),
apply: require('umi-plugin-react').default,
opts: { title: { defaultTitle: opts.title } },
opts: { title: { defaultTitle: opts.title || defaultTitle } },
});

// repalce default routes with generated routes
Expand Down Expand Up @@ -88,15 +89,15 @@ export default function (api: IApi, opts: IFatherDocOpts) {
if (/\/layout\.[tj]sx?$/.test(component)) {
ret = `props => React.createElement(require('${
importPath
}').default, { menu: { items: ${
}').default, { menu: { items: ${
JSON.stringify(getMenuFromRoutes(api.routes[0].routes)).replace(/\"/g, '\'')
} }, title: '${
} }, title: '${
opts.title
}', logo: '${
}', logo: '${
opts.logo || ''
}', desc: '${
}', desc: '${
opts.desc || ''
}', ...props })`;
}', ...props })`;
}

return ret;
Expand Down Expand Up @@ -142,7 +143,6 @@ export default function (api: IApi, opts: IFatherDocOpts) {
// modify help info
api._modifyHelpInfo(memo => {
memo.scriptName = 'father-doc';

return memo;
});

Expand Down