Skip to content

Commit

Permalink
chore: Add footer to the conf.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 3, 2019
1 parent 3f92923 commit 6e59b97
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/conf/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getRdocConf() {
return conf;
}

function getCinfigFilePath(fileName, type) {
function getConfigFilePath(fileName, type) {
const conf = getRdocConf();
// 这里是读取配置
if (conf && conf[type]) {
Expand Down Expand Up @@ -55,21 +55,21 @@ function getCinfigFilePath(fileName, type) {

// Get favicon path
const faviconPath = () => {
const _path = getCinfigFilePath('./favicon.ico', 'favicon');
const _path = getConfigFilePath('./favicon.ico', 'favicon');
if (_path) return _path;
return resolveTool('../../theme/default/favicon.ico');
};

// Get logo path
const logoPath = () => {
const _path = getCinfigFilePath('./logo.svg', 'logo');
const _path = getConfigFilePath('./logo.svg', 'logo');
if (_path) return _path;
return false;
};

// Get theme path
const getThemePath = () => {
const _path = getCinfigFilePath('./default', 'theme');
const _path = getConfigFilePath('./default', 'theme');
if (_path) return _path;
return resolveTool('../../theme/default');
};
Expand Down
4 changes: 4 additions & 0 deletions src/conf/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const UPATH = require('upath');
const paths = require('./path');
const pkg = require('../../package.json');

const define = paths.rdocConf && paths.rdocConf.footer && typeof paths.rdocConf.footer === 'string'
? { FOOTER: JSON.stringify(paths.rdocConf.footer) } : {};

module.exports = {
entry: {},
output: {
Expand Down Expand Up @@ -91,6 +94,7 @@ module.exports = {
new WebpackBar({ name: pkg.name }),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
...define,
}),
],
node: {
Expand Down
5 changes: 5 additions & 0 deletions templates/default/introduce/api/conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sort: 4
+ "theme": "rdoc-theme-load-react",
+ "favicon": "./assets/favicon.ico",
+ "logo": "./assets/rdoc.logo.svg",
+ "footer": "前端<b>开</b>发"
+ "react_modules": {
+ "Hotkeys": "react-hot-keys"
+ }
Expand Down Expand Up @@ -83,3 +84,7 @@ sort: 4
这个参数是一个特定参数,需求是在制作主题的时候,你的主题需要预览 React 实例,实例还需要加载一些未知的第三方 React 组件,这个时候你需要在你的 Markdown 项目中安装你需要的 React 组件,在配置中指定你的组件,在预览实例中你就可以引用该组件了。

> ⚠️注意:还在研究实现方式。
### footer

更改文档网站页脚
12 changes: 9 additions & 3 deletions theme/default/component/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import styles from './index.less';

const version = VERSION; // eslint-disable-line

const Footer = () => {
const footer = FOOTER; // eslint-disable-line

const FooterView = () => {
return (
<div className={styles.footer}>
Copyright © 2018 Powered by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jaywcjlove/rdoc">RDoc {version}</a>.
{footer ? <div dangerouslySetInnerHTML={{ __html: footer }} /> : (
<div>
Copyright © 2018 Powered by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jaywcjlove/rdoc">RDoc {version}</a>.
</div>
)}
</div>
);
};

export default Footer;
export default FooterView;

0 comments on commit 6e59b97

Please sign in to comment.