博客的相关配置
reco 主题 1.x
最近询问博客相关配置的人比较多(其实当前博客内就有相关文档与说明,但是需要自行查询与关联), 鉴于一一回复的效率太过低效,所以这边写了一篇简略的说明。
博客相关技术栈等
vuepress-plugin-meting: 音乐播放器。
# vuepress-reco/vuepress-plugin-kan-ban-niang: 看板娘
vuepress-plugin-nuggets-style-copy: 代码复制功能
vuepress-plugin-auto-sidebar: 自动生成侧边栏分组
vuepress/last-updated(依托于 git commit): 文章最后更新时间转换
vuepress-plugin-dynamic-title: 趣味标题插件
vue-canvas-effect(Bubbles): 气泡
vuepress-plugin-permalink-pinyin:中文转换为音译链接插件
typed.js:一个 JavaScript 打字动画库
敲重点:
- 主题的 lastUpdated 配置是基于 git commit 的,建议安装 vuepress/last-updated、moment 进行转换,以下内容含有相关配置信息。
- 配置了 last-updated 相关配置后,不要忘记进行 config.js 的 locales 的设置,不然可能出现时间不对问题(跟语言、时区相关)。
// config.js
module.exports = {
locales: {
"/": {
lang: "zh-CN", // 仅供参考,具体 lang 配置根据自己需求定义
},
},
};
plugins 相关配置
// config.js
const moment = require("moment");
module.exports = {
locales: {
"/": {
lang: "zh-CN",
},
},
plugins: [
// 自动生成侧边栏的插件
[
"vuepress-plugin-auto-sidebar",
{
collapse: {
open: true,
},
},
],
// 文章最后更新时间转换
[
"@vuepress/last-updated",
{
transformer: (timestamp, lang) => {
moment.locale(lang);
return moment(timestamp).format("YYYY-MM-DD HH:mm:ss");
},
},
],
[
"dynamic-title",
{
// Icon 建议根据自身需求选择
showIcon: "/favicon.ico",
showText: "",
hideIcon: "/failure.ico",
hideText: "(●—●)不要走啊,再看看!",
recoverTime: 2000,
},
],
// 复制代码功能
[
"vuepress-plugin-nuggets-style-copy",
{
copyText: "复制代码",
tip: {
content: "复制成功!",
},
},
],
// 音乐播放器
[
"meting",
{
meting: {
// 网易
server: "netease",
// 读取歌单列表
type: "playlist",
mid: "网易云歌单id",
},
// 不配置该项的话不会出现全局播放器
aplayer: {
// 吸底模式
fixed: true,
mini: true,
// 自动播放
autoplay: true,
// 歌曲栏折叠
listFolded: true,
// 颜色
theme: "#f9bcdd",
// 播放顺序为随机
order: "random",
// 初始音量
volume: 0.1,
// 关闭歌词显示
lrcType: 0,
},
mobile: {
// 手机端去掉cover图
cover: false,
},
},
],
// 看板娘
[
"@vuepress-reco/vuepress-plugin-kan-ban-niang",
{
clean: true,
},
],
// 中文转换为音译链接插件
[
"permalink-pinyin",
{
lowercase: true,
separator: "-",
},
],
],
};
气泡 (Bubbles),首页气泡效果
需要将主题源码本地化,并自行修改对应源码
npm i vue-canvas-effect -D
留言功能\留言板
留言功能是该主题内置功能 valine 评论,相关文档
留言板模块(基于留言功能),无需修改对应源码,只需配置相关信息,留言板放至项目根目录。
于项目根目录新建 messageboard.md, 内容如下,date 时间可自行定义
---
title: 留言板
date: 2020-10-15
sidebar: false
subSidebar: false
isShowComments: true
---
## 欢迎大家在此留下你的建议和意见
配置 config.js 的对应信息
// config.js
module.exports = {
nav: [
{
text: "留言板",
icon: "reco-suggestion",
link: "/messageboard", // messageboard 只是自行新建的文件名,可自行命名,建议使用小写字母
},
],
};
文章列表的封面图
是自行修改对应源码实现的。但主题也有文章封面图设置(摘要配置)。
文章图片是Wallpaper Engine 上找的,如需从 Wallpaper Engine 下载对应图片,建议食用PKG 解包程序
注:主题自带的摘要配置封面图可以通过修改主题样式对应样子达到当前博客的类似样子
首页下滚箭头\关于模块
需要将主题源码本地化,并自行修改对应源码
- 以下内容为源码本地化后相关配置。
于 theme/layouts 新建 About.vue 文件,并自定义相关代码。而后配置 theme/index.js 文件内的 plugins 对象。
相关配置代码如下
// theme/index.js
module.exports = (options, ctx) => ({
plugins: [
[
"@vuepress/plugin-blog",
{
permalink: "/:regular",
frontmatters: [
// 新增关于模块
{
id: "about",
keys: ["about"],
path: "/about/",
layout: "About",
scopeLayout: "About",
},
],
},
],
],
});
jsDelivr 加速 Github Pages 访问
相关文档 加速 Github Pages 访问速度,当前博客配置了文档内的以下两点内容
配置 github pages 访问
相关文档自行百度:github pages 搭建博客
部署到 github
VuePress 项目部署到 GitHub Pages,也可部署到码云 Gitee
配置统计代码
Powered by Waline v2.15.8