mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
site: fix bugs
This commit is contained in:
parent
2fe4a49182
commit
ba64ebbca8
@ -9,8 +9,8 @@ export default class Article extends React.Component {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const { chinese, english } = this.props.content.meta;
|
||||
utils.setTitle(`${chinese || english} - Ant Design`);
|
||||
const { title, chinese, english } = this.props.content.meta;
|
||||
utils.setTitle(`${title || chinese || english} - Ant Design`);
|
||||
const links = Array.apply(null, document.querySelectorAll('.outside-link.internal'));
|
||||
if (links.length === 0) {
|
||||
return;
|
||||
|
@ -23,8 +23,8 @@ export default class ComponentDoc extends React.Component {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const { chinese, english } = this.props.doc.meta;
|
||||
utils.setTitle(`${chinese} ${english} - Ant Design`);
|
||||
const { title, subtitle, chinese, english } = this.props.doc.meta;
|
||||
utils.setTitle(`${subtitle || chinese || ''} ${title || english} - Ant Design`);
|
||||
}
|
||||
|
||||
handleExpandToggle = () => {
|
||||
@ -89,7 +89,7 @@ export default class ComponentDoc extends React.Component {
|
||||
</ul>
|
||||
</Affix>
|
||||
<section className="markdown">
|
||||
<h1>{meta.english} {meta.chinese}</h1>
|
||||
<h1>{meta.title || meta.english} {meta.subtitle || meta.chinese}</h1>
|
||||
{
|
||||
utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
|
@ -93,9 +93,9 @@ export default class Header extends React.Component {
|
||||
const pathSnippet = meta.fileName.split('/')[1];
|
||||
const url = `/components/${pathSnippet}`;
|
||||
return (
|
||||
<Option value={url} key={url} data-label={`${meta.english.toLowerCase()} ${meta.chinese}`}>
|
||||
<strong>{meta.english}</strong>
|
||||
<span className="ant-component-decs">{meta.chinese}</span>
|
||||
<Option value={url} key={url} data-label={`${(meta.title || meta.english).toLowerCase()} ${meta.subtitle || meta.chinese}`}>
|
||||
<strong>{meta.title || meta.english}</strong>
|
||||
<span className="ant-component-decs">{meta.subtitle || meta.chinese}</span>
|
||||
</Option>
|
||||
);
|
||||
});
|
||||
|
@ -40,17 +40,17 @@ export default class MainContent extends React.Component {
|
||||
}
|
||||
|
||||
fileNameToPath(fileName) {
|
||||
const snippets = fileName.replace(/(\/index)?\.md$/i, '').split('/');
|
||||
const snippets = fileName.replace(/(\/index)?((\.zh-CN)|(\.en-US))?\.md$/i, '').split('/');
|
||||
return snippets[snippets.length - 1];
|
||||
}
|
||||
|
||||
generateMenuItem(isTop, item) {
|
||||
const key = this.fileNameToPath(item.fileName);
|
||||
const text = isTop ?
|
||||
item.chinese || item.english : [
|
||||
<span key="english">{item.english}</span>,
|
||||
<span className="chinese" key="chinese">{item.chinese}</span>,
|
||||
];
|
||||
item.chinese || item.english : [
|
||||
<span key="english">{ item.title || item.english }</span>,
|
||||
<span className="chinese" key="chinese">{ item.subtitle || item.chinese }</span>
|
||||
];
|
||||
const disabled = item.disabled;
|
||||
const url = item.fileName.replace(/(\/index)?((\.zh-CN)|(\.en-US))?\.md$/i, '');
|
||||
const child = !item.link ?
|
||||
@ -75,20 +75,21 @@ export default class MainContent extends React.Component {
|
||||
generateSubMenuItems(obj) {
|
||||
const topLevel = (obj.topLevel || []).map(this.generateMenuItem.bind(this, true));
|
||||
const itemGroups = Object.keys(obj).filter(this.isNotTopLevel)
|
||||
.sort((a, b) => {
|
||||
return config.typeOrder[a] - config.typeOrder[b];
|
||||
})
|
||||
.map((type, index) => {
|
||||
const groupItems = obj[type].sort((a, b) => {
|
||||
return a.english.charCodeAt(0) - b.english.charCodeAt(0);
|
||||
}).map(this.generateMenuItem.bind(this, false));
|
||||
.sort((a, b) => {
|
||||
return config.typeOrder[a] - config.typeOrder[b];
|
||||
})
|
||||
.map((type, index) => {
|
||||
const groupItems = obj[type].sort((a, b) => {
|
||||
return (a.title || a.english).charCodeAt(0) -
|
||||
(b.title || b.english).charCodeAt(0);
|
||||
}).map(this.generateMenuItem.bind(this, false));
|
||||
|
||||
return (
|
||||
<Menu.ItemGroup title={type} key={index}>
|
||||
{groupItems}
|
||||
</Menu.ItemGroup>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<Menu.ItemGroup title={type} key={index}>
|
||||
{ groupItems }
|
||||
</Menu.ItemGroup>
|
||||
);
|
||||
});
|
||||
return [...topLevel, ...itemGroups];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user