一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等(2)https://developer.aliyun.com/article/1548921
添加Sitemap信息
主要用于生成站点的Sitemap,有助于SEO。
安装
npm install vuepress-plugin-sitemap
配置
// .vuepress/config.js module.exports = { plugins: { 'sitemap': { hostname: 'https://www.pdai.tech' }, } }
更多请参考插件:vuepress-plugin-sitemap
添加代码拷贝
在代码区,添加一个拷贝按钮,用来拷贝代码。
安装
npm install vuepress-plugin-code-copy
配置
module.exports = { plugins: [['vuepress-plugin-code-copy', true]] }
更多请参考插件:vuepress-plugin-code-copy
更多插件配置
请参考 awesome-vuepress
博客/文档稍完整配置清单
- config.js部分内容
module.exports = { port: "3000", dest: "docs", ga: "UA-xxxxxxxxxxx-1", base: "/", markdown: { lineNumbers: true, externalLinks: { target: '_blank', rel: 'noopener noreferrer' } }, locales: { "/": { lang: "zh-CN", title: "Java 全栈知识体系", description: "包含: Java 基础, Java 部分源码, JVM, Spring, Spring Boot, Spring Cloud, 数据库原理, MySQL, ElasticSearch, MongoDB, Docker, k8s, CI&CD, Linux, DevOps, 分布式, 中间件, 开发工具, Git, IDE, 源码阅读,读书笔记, 开源项目..." } }, head: [ // ico ["link", {rel: "icon", href: `/favicon.ico`}], // meta ["meta", {name: "robots", content: "all"}], ["meta", {name: "author", content: "pdai"}], ["meta", {name: "keywords", content: "Java 全栈知识体系, java体系, java知识体系, java框架,java详解,java学习路线,java spring, java面试, 知识体系, java技术体系, java编程, java编程指南,java开发体系, java开发,java教程,java,java数据结构, 算法, 开发基础"}], ["meta", {name: "apple-mobile-web-app-capable", content: "yes"}], // baidu statstic ["script", {src: "https://hm.baidu.com/hm.js?xxxxxxxxxxx"}] ], plugins: [ ['@vuepress/back-to-top', true], ['@vuepress/medium-zoom', { selector: 'img', // See: https://github.com/francoischalifour/medium-zoom#options options: { margin: 16 } }], // see: https://vssue.js.org/guide/vuepress.html#usage ['@vssue/vuepress-plugin-vssue', { // set `platform` rather than `api` platform: 'github', // all other options of Vssue are allowed owner: 'realpdai', repo: 'tech-arch-doc-comments', clientId: 'xxxxxxxxxxx', clientSecret: 'xxxxxxxxxxxxxxxxxxxxxx', }], // see: https://vuepress.github.io/zh/plugins/copyright/#%E5%AE%89%E8%A3%85 ['copyright', { noCopy: false, // 允许复制内容 minLength: 100, // 如果长度超过 100 个字符 authorName: "https://www.pdai.tech", // clipboardComponent: "请注明文章出处, [Java 全栈知识体系](https://www.pdai.tech)" }], // see: https://github.com/ekoeryanto/vuepress-plugin-sitemap ['sitemap', { hostname: 'https://www.pdai.tech' }], // see: https://github.com/IOriens/vuepress-plugin-baidu-autopush ['vuepress-plugin-baidu-autopush', { }], // see: https://github.com/znicholasbrown/vuepress-plugin-code-copy [['vuepress-plugin-code-copy', true]] // ... ], themeConfig: { //repo: "realpdai/tech-arch-doc", docsRepo: "realpdai/tech-arch-doc", //logo: "/logo.png", editLinks: true, sidebarDepth:0, locales: { "/": { label: "简体中文", selectText: "Languages", editLinkText: "在 GitHub 上编辑此页", lastUpdated: "上次更新", nav: [ { text: '关于', link: '/md/about/me/about-me.md' } ], sidebar: { "/md/about/": genSidebar4About() } } } } }; // About page function genSidebar4About(){ return [ { title: "关于", collapsable: false, sidebarDepth: 0, children: [ "me/about-me.md", "me/about-content.md", "me/about-content-style.md", "me/about-arch.md", "me/about-motivation.md" ] }, { title: "关于 - 本文档的搭建", collapsable: false, sidebarDepth: 0, children: [ "blog/blog-build-vuepress.md", "blog/blog-build-ci.md", "blog/blog-build-cd.md", "blog/blog-build-ssl.md" ] } ]; }
- package.json
{ "name": "tech-arch-doc", "version": "2.0.1", "private": true, "scripts": { "dev": "vuepress dev", "build": "vuepress build" }, "devDependencies": { "@vuepress/plugin-back-to-top": "^1.0.3", "@vuepress/plugin-medium-zoom": "^1.0.4", "vuepress": "^1.0.2" }, "dependencies": { "@vssue/api-github-v3": "^1.1.2", "@vssue/vuepress-plugin-vssue": "^1.2.0", "vuepress-plugin-baidu-autopush": "^1.0.1", "vuepress-plugin-code-copy": "^1.0.4-alpha", "vuepress-plugin-copyright": "^1.0.2", "vuepress-plugin-sitemap": "^2.3.0" } }
- enhanceApp.js
export default ({router}) => { router.beforeEach((to, from, next) => { // @pdai: 对每个页面点击添加百度统计 if(typeof _hmt!='undefined'){ if (to.path) { _hmt.push(['_trackPageview', to.fullPath]); } } // continue next(); }) };
- index.styl
.custom-page-class{ /* 自定义的样式 */ } // markdown blockquote blockquote font-size 1rem color #2c3e50; border-left .5rem solid #42b983 background-color #f3f5f7 margin 1rem 0 padding 1rem 0 1rem 1rem & > p margin 0 // markdown h1 h1 font-size 2rem padding-bottom 1rem border-bottom 1px solid $borderColor // markdown h2 h2 font-size 1.65rem border-bottom 0px solid $borderColor // custom block for tip .custom-block .custom-block-title font-weight 600 margin-bottom -0.4rem &.tip, &.warning, &.danger padding .1rem 1.5rem border-left-width .5rem border-left-style solid margin 1rem 0 &.tip background-color #dfefff border-color #428eb9 // logo .navbar .logo height $navbarHeight - 1.6rem min-width $navbarHeight - 1.6rem margin-right 0rem vertical-align top
- palette.styl
// 内容的宽度 $contentWidth = 100% // 颜色 $accentColor = #3eaf7c $textColor = #2c3e50 $borderColor = #eaecef $codeBgColor = #282c34
vuepress 其它参考资源
- VuePress 官网
- VuePress Github
- VuePress 社区 VuePress社区维护的生态系统
- awesome-vuepress // 注意:vuepress插件分官方(包括官方社区)和社区两个维护,在里面都可以找到
一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等(4)https://developer.aliyun.com/article/1548926