Skip to content

Commit

Permalink
Add setting page title config.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 8, 2018
1 parent 4c3fafd commit 65e8cac
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
10 changes: 1 addition & 9 deletions src/conf/webpack.config.dev.js
Expand Up @@ -6,7 +6,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const CreateSpareWebpackPlugin = require('create-spare-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('@nuxtjs/friendly-errors-webpack-plugin');
const config = require('./webpack.config');
const pkg = require('../../package.json');
const paths = require('./path');

module.exports = function (cmd) {
Expand All @@ -16,11 +15,6 @@ module.exports = function (cmd) {
require.resolve('webpack-hot-dev-clients/webpackHotDevClient'),
paths.appIndexJs,
];
config.resolve = {
alias: {
'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath),
},
};
config.module.rules = config.module.rules.map((item) => {
if (item.oneOf) {
const loaders = [];
Expand Down Expand Up @@ -111,9 +105,7 @@ module.exports = function (cmd) {
inject: true,
favicon: paths.defaultFaviconPath,
template: paths.defaultHTMLPath,
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
title: paths.rdocConf && paths.rdocConf.title ? paths.rdocConf.title : 'Rdoc',
}),
// 将模块名称添加到工厂功能,以便它们显示在浏览器分析器中。
// 当接收到热更新信号时,在浏览器console控制台打印更多可读性高的模块名称等信息
Expand Down
11 changes: 11 additions & 0 deletions src/conf/webpack.config.js
@@ -1,6 +1,9 @@
const PATH = require('path');
const webpack = require('webpack');
const UPATH = require('upath');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const paths = require('./path');
const pkg = require('../../package.json');

module.exports = {
entry: {},
Expand All @@ -10,6 +13,11 @@ module.exports = {
filename: 'js/[name].[hash:8].js',
chunkFilename: 'js/[name].[hash:8].js',
},
resolve: {
alias: {
'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath),
},
},
module: {
rules: [
{
Expand Down Expand Up @@ -84,6 +92,9 @@ module.exports = {
format: ` build [:bar] ${':percent'.green} (:elapsed seconds)`,
clear: false,
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
}),
],
node: {
dgram: 'empty',
Expand Down
11 changes: 1 addition & 10 deletions src/conf/webpack.config.prod.js
@@ -1,5 +1,4 @@
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const PATH = require('path');
const UPATH = require('upath');
const HtmlWebpackPlugin = require('html-webpack-plugin');
Expand All @@ -9,19 +8,13 @@ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const config = require('./webpack.config');
const pkg = require('../../package.json');
const paths = require('./path');

module.exports = function (cmd) {
config.mode = 'production';
config.entry = [paths.appIndexJs];
config.output.filename = 'js/[hash:8].js';
config.output.chunkFilename = 'js/[name].[hash:8].js';
config.resolve = {
alias: {
'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath),
},
};
config.module.rules = config.module.rules.map((item) => {
if (item.oneOf) {
const loaders = [];
Expand Down Expand Up @@ -141,6 +134,7 @@ module.exports = function (cmd) {
inject: true,
favicon: paths.defaultFaviconPath,
template: paths.defaultHTMLPath,
title: paths.rdocConf && paths.rdocConf.title ? paths.rdocConf.title : 'Rdoc',
minify: {
removeAttributeQuotes: true,
collapseWhitespace: true,
Expand All @@ -150,9 +144,6 @@ module.exports = function (cmd) {
removeEmptyAttributes: true,
},
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
}),
new CopyMarkdownImageWebpackPlugin({
dir: cmd.markdownPaths,
toDir: config.output.path,
Expand Down
9 changes: 9 additions & 0 deletions templates/default/introduce/api/conf.md
Expand Up @@ -42,6 +42,7 @@ sort: 4

```json
{
"title": "Rdoc title",
"theme": "rdoc-theme-load-react",
"favicon": "./assets/favicon.ico",
"logo": "./assets/rdoc.logo.svg",
Expand All @@ -55,6 +56,14 @@ sort: 4
1. 优先读取 `.rdocrc.json` 配置。
2. 两种配置只有一种起作用。

### title

设置默认网页标题内容。

```html
<title>Rdoc title</title>
```

### favicon

默认显示 `rdoc` 的图标,自定义 `favicon` 需要自己生成一个图标命名为 `favicon.ico` 放在项目的根目录自动识别。添加配置,可以指定不同文件名和路径下的 `ico` 文件。
Expand Down
2 changes: 1 addition & 1 deletion theme/default/index.html
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>RDoc</title>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down

0 comments on commit 65e8cac

Please sign in to comment.