对 Ant Design 如何生成网站的解析 1
2018-04-06 12:43
148 查看
Ant-Design的安装地址 E:\学习记录\Nodejs\Example\ant-design-master有道云地址: https://note.youdao.com/share/?id=3be6f4a942a0f2e1ca7f0193c7eb89a8&type=note#/
"start": "rimraf _site && node ./scripts/generateColorLess.js && cross-env NODE_ENV=development bisheng start -c ./site/bisheng.config.js", http://localhost:8001/
module.exports = { port: 8001, source: { components: './components', docs: './docs', changelog: [ 'CHANGELOG.zh-CN.md', 'CHANGELOG.en-US.md', ], }, theme: './site/theme', htmlTemplate: './site/theme/static/template.html',
路由信息 theme: './site/theme/index.js
/childRoutes: index docs/ changelog compnents
const contentTmpl = './template/Content/index';
BiSheng 一个把 Markdown 转为 React 单页网站的工具import collect from 'bisheng/collect';
在MainContent 里面导入网站对应的 MarkDown文件import MainContent from './MainContent'; import * as utils from '../utils';....
export default collect(async (nextProps) => {.....})(MainContent);
function getModuleData(props) { const { pathname } = props.location; const moduleName = /^\/?components/.test(pathname) ? 'components' : pathname.split('/').filter(item => item).slice(0, 2).join('/');
pathname是否包含 /?components
const moduleData = moduleName === 'components' || moduleName === 'docs/react' || moduleName === 'changelog' || moduleName === 'changelog-cn' ? [...props.picked.components, ...props.picked['docs/react'], ...props.picked.changelog] : props.picked[moduleName];
const excludedSuffix = utils.isZhCN(props.location.pathname) ? 'en-US.md' : 'zh-CN.md'; return moduleData.filter(({ meta }) => !meta.filename.endsWith(excludedSuffix));}
其中 'components' : pathname.split('/').filter(item => item).slice(0, 2).join('/'); 通过 pathnam将路由的IP http://localhost:8001/components/button-cn/变为: 'components' : components/button/E:\学习记录\Nodejs\Example\ant-design-master\components\button\demo\
/
1. MainContent如何引入 Compent文件夹下,各个组件的Demo2.如何实现这种,左侧有导航,中间正文,右上角正文的导航,并且正文中,实现各个JSX的效果 如何在正文中实现JSX的效果
<Affix className="toc-affix" offsetTop={16}> ComponentDoc.jsx <ul id="demo-toc" className="toc"> {jumper} </ul> </Affix> 3.Html的模版在哪里引入的 import ComponentDoc from './ComponentDoc'; { props.demos ? <ComponentDoc {...props} doc={localizedPageData} demos={props.demos} /> : <Article {...props} content={localizedPageData} /> } 4.这个网站的设计思路是 什么
5. 如何引入代码
const { state } = this; const { props } = this; const { meta, src, content, preview, highlightedCode, style, highlightedStyle, expand, } = props; if (!this.liveDemo) { this.liveDemo = meta.iframe ? <BrowserFrame><iframe src={src} height={meta.iframe} title="demo" /></BrowserFrame> : preview(React, ReactDOM); }
E:\学习记录\Nodejs\Example\ant-design-master\site\theme\template\Content\ComponentDoc.jsx 如何 中通过prop导入到html中 props.utils.toReactComponent { props.utils.toReactComponent( ['section', { className: 'markdown' }] .concat(getChildren(content)) ) }
将Demo push到 const showedDemo = demos.some(demo => demo.meta.only) ? demos.filter(demo => demo.meta.only) : demos.filter(demo => demo.preview); showedDemo.sort((a, b) => a.meta.order - b.meta.order) .forEach((demoData, index) => { const demoElem = ( <Demo {...demoData} key={demoData.meta.filename} utils={props.utils} expand={expand} location={location} /> ); if (index % 2 === 0 || isSingleCol) { leftChildren.push(demoElem); } else { rightChildren.push(demoElem); } });
{this.liveDemo}
if (!this.liveDemo) { this.liveDemo = meta.iframe ? <BrowserFrame><iframe src={src} height={meta.iframe} title="demo" /></BrowserFrame> : preview(React, ReactDOM); }
添加文件夹Button222
有的地方可以加入
有的地方不可以加入
在我开始认为的路由文件中, 就包含了引入文本的程序module.exports = {.....pick: { components(markdownData) { const { filename } = markdownData.meta; if (!/^components/.test(filename) || /[/\\]demo$/.test(path.dirname(filename))) return;
return { meta: markdownData.meta, }; }, changelog(markdownData) { if (/CHANGELOG/.test(markdownData.meta.filename)) { return { meta: markdownData.meta, }; } }, 'docs/pattern': pickerGenerator('pattern'), 'docs/react': pickerGenerator('react'), 'docs/resource': pickerGenerator('resource'), 'docs/spec': pickerGenerator('spec'), },
不知道这个 pick 是什么写法 if (!/^components/.test(filename) || /[/\\]demo$/.test(path.dirname(filename))) return;一般来说,正则中的^表示开头,$表示结束比如 ^\d+$ 匹配的字符串只能是数字,因为他开头结尾都是数字,那么他就只能匹配: 1 、 12、 123....等等\d+$ 这个就匹配结尾是数字:比如 :abc123^\d+ 就匹配开头是数字,比如:123abc/e/.test("The best things in life are free!") 返回true这个是JS的正则表达式 !/^components/.test(filename) http://www.runoob.com/js/js-regexp.html
=== 是值和类型都要相等 http://www.runoob.com/js/js-comparisons.html
# 前面的IP修改就找不到 后面的乱改还可以打开页面就是不能正常定位了http://localhost:8001/components/button222-cn/#components1123-button-demo-ghost
_____________________________________________________________________________http://localhost:8001/docs/react/use-with-create-react-app-cnpickerGenerator
http://localhost:8001/docs/spec/cases-cn 路由文件中的 pickerGenerator
http://localhost:8001/components/button222-cn/http://localhost:8001/components/layout-cn/
http://localhost:8001/changelog-cn
const contentTmpl = './template/Content/index';
根据路径读取文件const { pathname } = nextProps.location;
判断 是否是中文 http://localhost:8001/components/grid/ 英文 const locale = utils.isZhCN(pathname) ? 'zh-CN' : 'en-US';
import MainContent from './MainContent';
import Article from './Article';
测试的代码来自:E:\学习记录\Nodejs\Example\ant-design-master\components 中
E:\学习记录\Nodejs\Example\ant-design-master\components\tree\demo\basic.md
阅读更多
"start": "rimraf _site && node ./scripts/generateColorLess.js && cross-env NODE_ENV=development bisheng start -c ./site/bisheng.config.js", http://localhost:8001/
bisheng.config.js
3KBmodule.exports = { port: 8001, source: { components: './components', docs: './docs', changelog: [ 'CHANGELOG.zh-CN.md', 'CHANGELOG.en-US.md', ], }, theme: './site/theme', htmlTemplate: './site/theme/static/template.html',
路由信息 theme: './site/theme/index.js
index.js
2.25KB/childRoutes: index docs/ changelog compnents
const contentTmpl = './template/Content/index';
BiSheng 一个把 Markdown 转为 React 单页网站的工具import collect from 'bisheng/collect';
在MainContent 里面导入网站对应的 MarkDown文件import MainContent from './MainContent'; import * as utils from '../utils';....
export default collect(async (nextProps) => {.....})(MainContent);
MainContent.jsx
8.97KBfunction getModuleData(props) { const { pathname } = props.location; const moduleName = /^\/?components/.test(pathname) ? 'components' : pathname.split('/').filter(item => item).slice(0, 2).join('/');
pathname是否包含 /?components
const moduleData = moduleName === 'components' || moduleName === 'docs/react' || moduleName === 'changelog' || moduleName === 'changelog-cn' ? [...props.picked.components, ...props.picked['docs/react'], ...props.picked.changelog] : props.picked[moduleName];
const excludedSuffix = utils.isZhCN(props.location.pathname) ? 'en-US.md' : 'zh-CN.md'; return moduleData.filter(({ meta }) => !meta.filename.endsWith(excludedSuffix));}
其中 'components' : pathname.split('/').filter(item => item).slice(0, 2).join('/'); 通过 pathnam将路由的IP http://localhost:8001/components/button-cn/变为: 'components' : components/button/E:\学习记录\Nodejs\Example\ant-design-master\components\button\demo\
/
1. MainContent如何引入 Compent文件夹下,各个组件的Demo2.如何实现这种,左侧有导航,中间正文,右上角正文的导航,并且正文中,实现各个JSX的效果 如何在正文中实现JSX的效果
<Affix className="toc-affix" offsetTop={16}> ComponentDoc.jsx <ul id="demo-toc" className="toc"> {jumper} </ul> </Affix> 3.Html的模版在哪里引入的 import ComponentDoc from './ComponentDoc'; { props.demos ? <ComponentDoc {...props} doc={localizedPageData} demos={props.demos} /> : <Article {...props} content={localizedPageData} /> } 4.这个网站的设计思路是 什么
5. 如何引入代码
Demo.jsx
9.92KB在MainContent.jsx 引入 ComponentDoc.jsx ->引入Demo.jsx 通过props中的src引入代码文件的地址 <iframe src={src} height={meta.iframe} title="demo" />const { state } = this; const { props } = this; const { meta, src, content, preview, highlightedCode, style, highlightedStyle, expand, } = props; if (!this.liveDemo) { this.liveDemo = meta.iframe ? <BrowserFrame><iframe src={src} height={meta.iframe} title="demo" /></BrowserFrame> : preview(React, ReactDOM); }
E:\学习记录\Nodejs\Example\ant-design-master\site\theme\template\Content\ComponentDoc.jsx 如何 中通过prop导入到html中 props.utils.toReactComponent { props.utils.toReactComponent( ['section', { className: 'markdown' }] .concat(getChildren(content)) ) }
ComponentDoc.jsx
4.08KB将Demo push到 const showedDemo = demos.some(demo => demo.meta.only) ? demos.filter(demo => demo.meta.only) : demos.filter(demo => demo.preview); showedDemo.sort((a, b) => a.meta.order - b.meta.order) .forEach((demoData, index) => { const demoElem = ( <Demo {...demoData} key={demoData.meta.filename} utils={props.utils} expand={expand} location={location} /> ); if (index % 2 === 0 || isSingleCol) { leftChildren.push(demoElem); } else { rightChildren.push(demoElem); } });
{this.liveDemo}
if (!this.liveDemo) { this.liveDemo = meta.iframe ? <BrowserFrame><iframe src={src} height={meta.iframe} title="demo" /></BrowserFrame> : preview(React, ReactDOM); }
添加文件夹Button222
有的地方可以加入
有的地方不可以加入
在我开始认为的路由文件中, 就包含了引入文本的程序module.exports = {.....pick: { components(markdownData) { const { filename } = markdownData.meta; if (!/^components/.test(filename) || /[/\\]demo$/.test(path.dirname(filename))) return;
return { meta: markdownData.meta, }; }, changelog(markdownData) { if (/CHANGELOG/.test(markdownData.meta.filename)) { return { meta: markdownData.meta, }; } }, 'docs/pattern': pickerGenerator('pattern'), 'docs/react': pickerGenerator('react'), 'docs/resource': pickerGenerator('resource'), 'docs/spec': pickerGenerator('spec'), },
不知道这个 pick 是什么写法 if (!/^components/.test(filename) || /[/\\]demo$/.test(path.dirname(filename))) return;一般来说,正则中的^表示开头,$表示结束比如 ^\d+$ 匹配的字符串只能是数字,因为他开头结尾都是数字,那么他就只能匹配: 1 、 12、 123....等等\d+$ 这个就匹配结尾是数字:比如 :abc123^\d+ 就匹配开头是数字,比如:123abc/e/.test("The best things in life are free!") 返回true这个是JS的正则表达式 !/^components/.test(filename) http://www.runoob.com/js/js-regexp.html
=== 是值和类型都要相等 http://www.runoob.com/js/js-comparisons.html
# 前面的IP修改就找不到 后面的乱改还可以打开页面就是不能正常定位了http://localhost:8001/components/button222-cn/#components1123-button-demo-ghost
_____________________________________________________________________________http://localhost:8001/docs/react/use-with-create-react-app-cnpickerGenerator
http://localhost:8001/docs/spec/cases-cn 路由文件中的 pickerGenerator
if (tester.test(filename) &&
!/\/demo$/.test(path.dirname(filename))) {
return {
meta: markdownData.meta,
};
'docs/pattern': pickerGenerator('pattern'),
'docs/react': pickerGenerator('react'),
'docs/resource': pickerGenerator('resource'),
'docs/spec': pickerGenerator('spec'),
http://localhost:8001/components/button222-cn/http://localhost:8001/components/layout-cn/
http://localhost:8001/changelog-cn
template.html
4.66KBindex.js
2.25KBconst contentTmpl = './template/Content/index';
index.jsx
1.06KB根据路径读取文件const { pathname } = nextProps.location;
判断 是否是中文 http://localhost:8001/components/grid/ 英文 const locale = utils.isZhCN(pathname) ? 'zh-CN' : 'en-US';
import MainContent from './MainContent';
MainContent.jsx
8.97KBimport Article from './Article';
测试的代码来自:E:\学习记录\Nodejs\Example\ant-design-master\components 中
E:\学习记录\Nodejs\Example\ant-design-master\components\tree\demo\basic.md
阅读更多
相关文章推荐
- 对 Ant Design 如何生成网站的解析(2)
- 解析各大电子商务网站订单号的生成方式
- [轉]VS2008发布、生成网站时如何设置固定的dll文件名?
- 如何防恶意解析,禁止用IP访问网站的Apache设置?
- 织梦CMS如何修改网站地图的生成路径
- DedeCMS如何将网站地图生成在根目录
- IMCART解析外贸网站如何进行SEO优化
- 网站中的缩略图是如何生成的?(C#处理图像)
- 如何使用Hpple解析HTML,以及获取网站上的所有超链接
- 解析各大电子商务网站订单号的生成方式
- [转]VS2008发布、生成网站时如何设置固定的dll文件名
- VS2005发布、生成网站时如何设置固定的dll文件名?
- 如何让帝国CMS如何自动生成sitemap.xml网站地图文件
- 如何向Google、Yahoo!、MSN、Ask和百度提交在线生成的网站地图Sitemap
- vs2005中如何发布网站及打包web项目生成安装文件【转】
- 如何使用本地解析调试网站内容?
- VS2008发布、生成网站时如何设置固定的dll文件名?
- VS2005发布、生成网站时如何设置固定的dll文件名?
- 动态网站如何生成静态页面
- 黑客是如何利用Windows2003+IIS6.0的文件名解析漏洞入侵网站挂马的?