Vuepress+Nodejs+Webpack+Markdown搭建侧边栏博客系统或API文档

全局安装Vuepress

在命令行中使用npm命令安装,前提是安装了Node.js>=8的版本。
Nodejs安装可参考https://www.jianshu.com/p/13f45e24b1de

npm install -g vuepress

检查是否安装成功

vuepress -v

提示出版本即为成功。

新建并初始化项目

新建一个项目文件夹hello-vue,作为项目文件夹。以下为命令行操作(cmd命令)

cd hello-vue
npm init -y

会自动在hello-vue下新建一个package.json文件,提示如下。

Wrote to C:\prog\hello-vue\package.json:

{
  "name": "hello-vue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

修改package.json文件,在scripts后添加dev及build内容,修改完成后如下:

{
  "name": "hello-vue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
	"dev": "vuepress dev docs",
    "build": "vuepress build docs"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

新建文件夹docs,目的是把整个项目的结构建立起来,项目结构如下:

├─ config
│ ├─ navConfig.js
│ └─ sidebarConfig.js
├─ docs
│ ├─ .vuepress
│ └─ public
│ └─ img
│ └─ favicon.ico
│ └─ styles
│ └─ index.styl
│ └─ palette.styl
│ └─ config.js
│ └─ base
│ └─ baseConfig.md
│ └─ baseMenu.md
│ └─ README.md
│ └─ problem
│ └─ problem1.md
│ └─ problem2.md
│ └─ README.md
│ └─ README.md
└─ package.json
我们在hello-vue下用命令行建立文件夹docs,直接在文件夹hello-vue下鼠标右击新建文件夹也可以

mkdir docs
cd docs
echo "## Hello VuePress" > README.md

此操作在docs文件夹下新建了文件README.md,并写入了字符Hello VuePress。(文件名称必须为README.md,会自动识别md文档)

构建项目

hello-vue文件夹下用命令行运行

npm run build

构建出.vuepress文件夹,在.vuepress文件夹下新建config.js文件

//config.js
const navConfig = require('../../config/navConfig.js')
const sidebarConfig = require('../../config/sidebarConfig.js')

module.exports = {
    title: 'hello-vue', 
    description: 'hello-vue', 
    head: [
        ['link', { rel: 'icon', href: '/img/favicon.ico' }], 
        ['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }]
    ],
    themeConfig: { //主题
        lastUpdated: 'Last Updated', //最后更新时间
        nav: navConfig, //导航栏在navConfig.js中配置
        sidebar: sidebarConfig, //侧边栏在sidebarConfig.js中配置
        sidebarDepth: 2, //最大的深度为 2,将同时提取 h2 和 h3 标题
    },
    markdown: { //markdown
        lineNumbers: true //显示行号
    }
}

以上配置使用了navConfig.js和sidebarConfig.js,用来配置导航栏和侧边栏。我们在hello-vue/config文件夹下创建这两个文件

//navConfig.js
module.exports = [
    { text: '主页', link: '/' },
    { text: '基础', link: '/base/' }
]
//sidebarConfig.js
module.exports = [
    {
        title: '介绍',
        collapsable: true,
        children: [
            ['/base/', '基础'],
            ['/base/baseMenu', '介绍'],
        ]
    },
	{
        title: '联系我们',
        collapsable: false,
        children: [
			{ title: '联系我们', path:'/contactus/'}
        ]
    },
    {
        title: '问题',
        collapsable: true,
        children: [
            ['/problem/', '问题'],
            ['/problem/problem1', '问题1'],
            ['/problem/problem2', '问题2']
        ]
    }
]

运行项目

hello-vue文件夹下用命令行运行

npm run dev

在这里插入图片描述
在浏览器地址栏输入http://localhost:8080/

参考资料

https://segmentfault.com/a/1190000020097643
https://b.himnt.top/blog/base/
http://caibaojian.com/vuepress/guide/
https://www.jianshu.com/p/13f45e24b1de

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编写一个基于Vue3+Node.js的旅游博客系统系统架构文档时,可以按照以下结构进行组织: 1. 引言 - 系统背景和目标 - 文档范围和读者对象 - 定义缩略词和术语 2. 总体架构 - 系统概述和目标 - 架构类型(例如,客户端-服务器) - 架构图示或图表 - 系统模块和组件的描述和关系 3. 前端架构(Vue3) - 技术选择和理由 - 前端架构图示或图表 - 组件层次结构和职责 - 状态管理方案(例如,Vuex) - 路由方案(例如,Vue Router) - 与后端API的交互方式 4. 后端架构(Node.js) - 技术选择和理由 - 后端架构图示或图表 - 服务器层次结构和职责 - 数据库选择和设计 - 接口设计和文档 5. 部署架构 - 部署环境选择和理由 - 服务器配置和规划 - 前后端部署方式 - 系统监控和日志管理 6. 安全性考虑 - 用户认证和授权策略 - 数据保护和加密 - 防止常见的安全漏洞(例如,跨站点脚本攻击) 7. 性能和可扩展性考虑 - 系统性能目标 - 前端和后端的性能优化策略 - 数据库和服务器的扩展性规划 8. 未来发展和改进 - 可能的系统改进方向 - 技术升级和迁移计划 9. 附录 - 引用文档和资源 - 术语表 请注意,这只是一个基本的框架,你可以根据你的具体项目需求和架构特点进行扩展和调整。同时,尽量使用清晰的语言、图示或图表来表达架构设计思想,以便读者能够理解和参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值