diff --git a/.gitignore b/.gitignore index 83948575..7d98dac9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,6 @@ hs_err_pid* # maven plugin temp files .flattened-pom.xml -package-lock.json # ------------------------------- javascript ------------------------------- @@ -37,10 +36,12 @@ package-lock.json node_modules # temp folders -.temp +build dist _book _jsdoc +.temp +.deploy*/ # temp files *.log @@ -48,7 +49,11 @@ npm-debug.log* yarn-debug.log* yarn-error.log* bundle*.js +.DS_Store +Thumbs.db +db.json book.pdf +package-lock.json # ------------------------------- intellij ------------------------------- diff --git a/config.js b/config.js new file mode 100644 index 00000000..e109e8a8 --- /dev/null +++ b/config.js @@ -0,0 +1,256 @@ +const htmlModules = require('./config/htmlModules.js') + +module.exports = { + port: '4000', + dest: 'docs/.temp', + base: '/javacore/', + title: 'JAVACORE', + description: '☕ JavaCore 是一个 Java 核心技术教程。', + theme: 'vdoing', // 使用依赖包主题 + // theme: require.resolve('../../vdoing'), // 使用本地主题 + head: [ + // 注入到页面
中的标签,格式[tagName, { attrName: attrValue }, innerHTML?] + ['link', { rel: 'icon', href: '/img/favicon.ico' }], //favicons,资源放在public文件夹 + ['meta', { name: 'keywords', content: 'vuepress,theme,blog,vdoing' }], + ['meta', { name: 'theme-color', content: '#11a8cd' }], // 移动浏览器主题颜色 + + ['meta', { name: 'wwads-cn-verify', content: 'mxqWx62nfQQ9ocT4e5DzISHzOWyF4s' }], // 广告相关,你可以去掉 + ['script', { src: 'https://cdn.wwads.cn/js/makemoney.js', type: 'text/javascript' }], // 广告相关,你可以去掉 + ], + markdown: { + // lineNumbers: true, + extractHeaders: ['h2', 'h3', 'h4', 'h5', 'h6'], // 提取标题到侧边栏的级别,默认['h2', 'h3'] + externalLinks: { + target: '_blank', + rel: 'noopener noreferrer' + } + }, + // 主题配置 + themeConfig: { + nav: [ + { + text: '基础特性', + link: '/01.Java/01.JavaSE/01.基础特性/', + }, + { + text: '高级特性', + link: '/01.Java/01.JavaSE/02.高级特性/', + }, + { + text: '容器', + link: '/01.Java/01.JavaSE/03.容器/', + }, + { + text: 'IO', + link: '/01.Java/01.JavaSE/04.IO/', + }, + { + text: '并发', + link: '/01.Java/01.JavaSE/05.并发/', + }, + { + text: 'JVM', + link: '/01.Java/01.JavaSE/06.JVM/', + }, + { + text: '✨ Java系列', + ariaLabel: 'Java', + items: [ + { + text: 'Java 教程 📚', + link: 'https://dunwu.github.io/java-tutorial/', + target: '_blank', + rel: '', + }, + { + text: 'JavaCore 教程 📚', + link: 'https://dunwu.github.io/javacore/', + target: '_blank', + rel: '', + }, + { + text: 'Spring 教程 📚', + link: 'https://dunwu.github.io/spring-tutorial/', + target: '_blank', + rel: '', + }, + { + text: 'Spring Boot 教程 📚', + link: 'https://dunwu.github.io/spring-boot-tutorial/', + target: '_blank', + rel: '', + }, + ], + }, + { + text: '🎯 博客', + link: 'https://github.com/dunwu/blog', + target: '_blank', + rel: '', + }, + ], + sidebarDepth: 2, // 侧边栏显示深度,默认1,最大2(显示到h3标题) + logo: 'https://raw.githubusercontent.com/dunwu/images/master/common/dunwu-logo.png', // 导航栏logo + repo: 'dunwu/javacore', // 导航栏右侧生成Github链接 + searchMaxSuggestions: 10, // 搜索结果显示最大数 + lastUpdated: '上次更新', // 更新的时间,及前缀文字 string | boolean (取值为git提交时间) + + docsDir: 'docs', // 编辑的文件夹 + editLinks: true, // 编辑链接 + editLinkText: '📝 帮助改善此页面!', + + // 以下配置是Vdoing主题改动的和新增的配置 + sidebar: { mode: 'structuring', collapsable: true }, // 侧边栏 'structuring' | { mode: 'structuring', collapsable: + // Boolean} | 'auto' | 自定义 温馨提示:目录页数据依赖于结构化的侧边栏数据,如果你不设置为'structuring',将无法使用目录页 + + sidebarOpen: true, // 初始状态是否打开侧边栏,默认true + updateBar: { + // 最近更新栏 + showToArticle: true // 显示到文章页底部,默认true + // moreArticle: '/archives' // “更多文章”跳转的页面,默认'/archives' + }, + // titleBadge: false, // 文章标题前的图标是否显示,默认true + // titleBadgeIcons: [ // 文章标题前图标的地址,默认主题内置图标 + // '图标地址1', + // '图标地址2' + // ], + // bodyBgImg: [ + // 'https://cdn.jsdelivr.net/gh/xugaoyi/image_store/blog/20200507175828.jpeg', + // 'https://cdn.jsdelivr.net/gh/xugaoyi/image_store/blog/20200507175845.jpeg', + // 'https://cdn.jsdelivr.net/gh/xugaoyi/image_store/blog/20200507175846.jpeg' + // ], // body背景大图,默认无。 单张图片 String || 多张图片 Array, 多张图片时每隔15秒换一张。 + + // categoryText: '随笔', // 碎片化文章(_posts文件夹的文章)预设生成的分类值,默认'随笔' + + // contentBgStyle: 1, + + category: true, // 是否打开分类功能,默认true。 如打开,会做的事情有:1. 自动生成的frontmatter包含分类字段 2.页面中显示与分类相关的信息和模块 3.自动生成分类页面(在@pages文件夹)。如关闭,则反之。 + tag: true, // 是否打开标签功能,默认true。 如打开,会做的事情有:1. 自动生成的frontmatter包含标签字段 2.页面中显示与标签相关的信息和模块 3.自动生成标签页面(在@pages文件夹)。如关闭,则反之。 + archive: true, // 是否打开归档功能,默认true。 如打开,会做的事情有:1.自动生成归档页面(在@pages文件夹)。如关闭,则反之。 + + author: { + // 文章默认的作者信息,可在md文件中单独配置此信息 String | {name: String, href: String} + name: 'dunwu', // 必需 + href: 'https://github.com/dunwu' // 可选的 + }, + social: { + // 社交图标,显示于博主信息栏和页脚栏 + // iconfontCssFile: '//at.alicdn.com/t/font_1678482_u4nrnp8xp6g.css', // 可选,阿里图标库在线css文件地址,对于主题没有的图标可自由添加 + icons: [ + { + iconClass: 'icon-youjian', + title: '发邮件', + link: 'mailto:forbreak@163.com' + }, + { + iconClass: 'icon-github', + title: 'GitHub', + link: 'https://github.com/dunwu' + } + ] + }, + footer: { + // 页脚信息 + createYear: 2019, // 博客创建年份 + copyrightInfo: '钝悟(dunwu) | CC-BY-SA-4.0' // 博客版权信息,支持a标签 + }, + htmlModules + }, + + // 插件 + plugins: [ + [ + require('./plugins/love-me'), + { + // 鼠标点击爱心特效 + color: '#11a8cd', // 爱心颜色,默认随机色 + excludeClassName: 'theme-vdoing-content' // 要排除元素的class, 默认空'' + } + ], + + ['fulltext-search'], // 全文搜索 + + // ['thirdparty-search', { // 可以添加第三方搜索链接的搜索框(原官方搜索框的参数仍可用) + // thirdparty: [ // 可选,默认 [] + // { + // title: '在GitHub中搜索', + // frontUrl: 'https://github.com/search?q=', // 搜索链接的前面部分 + // behindUrl: '' // 搜索链接的后面部分,可选,默认 '' + // }, + // { + // title: '在npm中搜索', + // frontUrl: 'https://www.npmjs.com/search?q=', + // }, + // { + // title: '在Bing中搜索', + // frontUrl: 'https://cn.bing.com/search?q=' + // } + // ] + // }], + + [ + 'one-click-copy', + { + // 代码块复制按钮 + copySelector: ['div[class*="language-"] pre', 'div[class*="aside-code"] aside'], // String or Array + copyMessage: '复制成功', // default is 'Copy successfully and then paste it for use.' + duration: 1000, // prompt message display time. + showInMobile: false // whether to display on the mobile side, default: false. + } + ], + [ + 'demo-block', + { + // demo演示模块 https://github.com/xiguaxigua/vuepress-plugin-demo-block + settings: { + // jsLib: ['http://xxx'], // 在线示例(jsfiddle, codepen)中的js依赖 + // cssLib: ['http://xxx'], // 在线示例中的css依赖 + // vue: 'https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js', // 在线示例中的vue依赖 + jsfiddle: false, // 是否显示 jsfiddle 链接 + codepen: true, // 是否显示 codepen 链接 + horizontal: false // 是否展示为横向样式 + } + } + ], + [ + 'vuepress-plugin-zooming', // 放大图片 + { + selector: '.theme-vdoing-content img:not(.no-zoom)', + options: { + bgColor: 'rgba(0,0,0,0.6)' + } + } + ], + [ + '@vuepress/last-updated', // "上次更新"时间格式 + { + transformer: (timestamp, lang) => { + const dayjs = require('dayjs') // https://day.js.org/ + return dayjs(timestamp).format('YYYY/MM/DD, HH:mm:ss') + } + } + ], + [ + 'vuepress-plugin-comment', // 评论 + { + choosen: 'gitalk', + options: { + clientID: '7dd8c87a20cff437d2ed', + clientSecret: '4e28d81a9a0280796b2b45ce2944424c6f2c1531', + repo: 'javacore', // GitHub 仓库 + owner: 'dunwu', // GitHub仓库所有者 + admin: ['dunwu'], // 对仓库有写权限的人 + // distractionFreeMode: true, + pagerDirection: 'last', // 'first'正序 | 'last'倒序 + id: '<%- (frontmatter.permalink || frontmatter.to.path).slice(-16) %>', // 页面的唯一标识,长度不能超过50 + title: '「评论」<%- frontmatter.title %>', // GitHub issue 的标题 + labels: ['Gitalk', 'Comment'], // GitHub issue 的标签 + body: '页面:<%- window.location.origin + (frontmatter.to.path || window.location.pathname) %>' // GitHub issue 的内容 + } + } + ] + ], + + // 监听文件变化并重新构建 + extraWatchFiles: ['.vuepress/config.js', '.vuepress/config/htmlModules.js'] +} diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 5015f46b..e109e8a8 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -30,27 +30,27 @@ module.exports = { nav: [ { text: '基础特性', - link: '/01.基础特性/', + link: '/01.Java/01.JavaSE/01.基础特性/', }, { text: '高级特性', - link: '/02.高级特性/', + link: '/01.Java/01.JavaSE/02.高级特性/', }, { text: '容器', - link: '/03.容器/', + link: '/01.Java/01.JavaSE/03.容器/', }, { text: 'IO', - link: '/04.IO/', + link: '/01.Java/01.JavaSE/04.IO/', }, { text: '并发', - link: '/05.并发/', + link: '/01.Java/01.JavaSE/05.并发/', }, { text: 'JVM', - link: '/06.JVM/', + link: '/01.Java/01.JavaSE/06.JVM/', }, { text: '✨ Java系列', @@ -237,7 +237,7 @@ module.exports = { options: { clientID: '7dd8c87a20cff437d2ed', clientSecret: '4e28d81a9a0280796b2b45ce2944424c6f2c1531', - repo: 'db-tutorial', // GitHub 仓库 + repo: 'javacore', // GitHub 仓库 owner: 'dunwu', // GitHub仓库所有者 admin: ['dunwu'], // 对仓库有写权限的人 // distractionFreeMode: true, diff --git a/package.json b/package.json index 93a7223a..760153d3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "java-tutorial", + "name": "javacore", "version": "1.0.0", "private": true, "scripts": { diff --git a/utils/config.yml b/utils/config.yml index a1ed11dd..d387646b 100644 --- a/utils/config.yml +++ b/utils/config.yml @@ -1,4 +1,4 @@ -#批量添加和修改、删除front matter配置文件 +# 批量添加和修改、删除front matter配置文件 # 需要批量处理的路径,docs文件夹内的文件夹 (数组,映射路径:path[0]/path[1]/path[2] ... ) path: @@ -8,6 +8,8 @@ path: delete: # - tags -# 要添加、修改front matter的数据 (front matter中没有的数据则添加,已有的数据则覆盖) + # 要添加、修改front matter的数据 (front matter中没有的数据则添加,已有的数据则覆盖) data: - article: false \ No newline at end of file + # author: + # name: xugaoyi + # link: https://github.com/xugaoyi diff --git a/utils/editFrontmatter.js b/utils/editFrontmatter.js index 8c223f4e..0998bf3d 100644 --- a/utils/editFrontmatter.js +++ b/utils/editFrontmatter.js @@ -1,41 +1,43 @@ /** * 批量添加和修改front matter ,需要配置 ./config.yml 文件。 */ -const fs = require('fs'); // 文件模块 -const path = require('path'); // 路径模块 -const matter = require('gray-matter'); // front matter解析器 https://github.com/jonschlinkert/gray-matter +const fs = require('fs') // 文件模块 +const path = require('path') // 路径模块 +const matter = require('gray-matter') // front matter解析器 https://github.com/jonschlinkert/gray-matter const jsonToYaml = require('json2yaml') const yamlToJs = require('yamljs') const inquirer = require('inquirer') // 命令行操作 const chalk = require('chalk') // 命令行打印美化 -const readFileList = require('./modules/readFileList'); -const { type, repairDate} = require('./modules/fn'); +const readFileList = require('./modules/readFileList') +const { type, repairDate } = require('./modules/fn') const log = console.log const configPath = path.join(__dirname, 'config.yml') // 配置文件的路径 -main(); +main() /** * 主体函数 */ async function main() { + const promptList = [ + { + type: 'confirm', + message: chalk.yellow('批量操作frontmatter有修改数据的风险,确定要继续吗?'), + name: 'edit' + } + ] + let edit = true - const promptList = [{ - type: "confirm", - message: chalk.yellow('批量操作frontmatter有修改数据的风险,确定要继续吗?'), - name: "edit", - }]; - let edit = true; - - await inquirer.prompt(promptList).then(answers => { + await inquirer.prompt(promptList).then((answers) => { edit = answers.edit }) - if(!edit) { // 退出操作 + if (!edit) { + // 退出操作 return } - + const config = yamlToJs.load(configPath) // 解析配置文件的数据转为js对象 if (type(config.path) !== 'array') { @@ -48,27 +50,26 @@ async function main() { return } - const filePath = path.join(__dirname, '..', ...config.path); // 要批量修改的文件路径 - const files = readFileList(filePath); // 读取所有md文件数据 + const filePath = path.join(__dirname, '..', ...config.path) // 要批量修改的文件路径 + const files = readFileList(filePath) // 读取所有md文件数据 - files.forEach(file => { - let dataStr = fs.readFileSync(file.filePath, 'utf8');// 读取每个md文件的内容 + files.forEach((file) => { + let dataStr = fs.readFileSync(file.filePath, 'utf8') // 读取每个md文件的内容 const fileMatterObj = matter(dataStr) // 解析md文件的front Matter。 fileMatterObj => {content:'剔除frontmatter后的文件内容字符串', data:{