【原创】Gitbook使用

【常用命令】

1.gitbook install

安装依赖模块

 

2.gitbook build

编译,结果输出在_book文件夹下

 

3.gitbook serve

本机预览,默认端口为4000

 

【注意事项】

1.图片文件名不能带中文

后果:图片不能显示。

 

2.根目录只能有两个MD文件

后果:如果根目录存在除了README.md和SUMMARY.md之外的md文件,点击README.md对应的菜单会无法正常跳转。

 

3.建议图片、视频上下文各保留一行空行

后果:图片或视频与文字之间没有换行,格式错乱。

 

4.SUMMARY.md的同一菜单最好放在相同目录下(拖动菜单位置可能会导致目录错乱),删除无用的md文件(菜单创建后删除不会自动删除文件)

后果:方便管理,减少垃圾文件,减少出现不可预料错误的可能性。

 【其他】

1.修改首页链接

默认README.md的链接为“./”,但有的时候不能指向默认的index.html文件。

修改文件:C:\Users\{用户名}\.gitbook\versions\{版本号}\lib\output\helper\fileToURL.js

修改为下面内容(注释掉三行)

function fileToURL(output, filePath) {
    var options = output.getOptions();
    var directoryIndex = options.get('directoryIndex');

    filePath = fileToOutput(output, filePath);

    /*if (directoryIndex && path.basename(filePath) == 'index.html') {
        filePath = path.dirname(filePath) + '/';
    }*/

    return LocationUtils.normalize(filePath);
}

修改后,再使用gitbook build后的首页链接就是“./index.html”

 2.build时出错,“gitbook Error: ENOENT: no such file or directory, stat........xxx.css”

参考链接:https://segmentfault.com/q/1010000009569245

修改文件:C:\Users\{用户名}\.gitbook\versions\{版本号}\lib\output\website\copyPluginAssets.js

修改112行(最下面),如下:

    ......
    logger.debug.ln('copy resources from plugin', assetsFolder);

    return fs.copyDir(
        assetsFolder,
        assetOutputFolder,
        {
            deleteFirst: false,
            overwrite: true/*,
            confirm: true*/
        }
    );
}

module.exports = copyPluginAssets;

 

转载于:https://www.cnblogs.com/abcdefghijklmnopqrstuvwxyz/p/8674805.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值