博客和胶片
# Hexo 博客
# 下载安装
nodejs
- 下载 nodejs:nodejs官网 (opens new window)
- arch linx / manjaro 中
yay -S nodejs
cnpm 和 hexo
#查看版本号:检查node是否安装成功
node -v
#检查npm是否安装成功
npm -v
#下载cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
#检查cnpm是否安装成功
cnpm -v
#下载hexo
cnpm install -g hexo-cli
#查看hexo版本号
hexo -v
#用cnpm在blog目录下安装git插件
cnpm install --save hexo-deployer-git
#配置_config.yml文件
deploy:
type: git
repo: https://github.com/NorthBoat/NorthBoat.github.io
branch: master
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
git/github 操作请参照: git手册 (opens new window)
# Hexo 命令和配置
#初始化博客
hexo init
#启动预览 start
hexo s
#创建文章 new
hexo n "我的第一篇博客文章"
#清理缓存
hexo clean
#生成 html 文件 generate
hexo g
#将本地博客布署在GitHub(配置好插件以及_config后)
hexo d
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
在配置文件_config.yml中如果仓库写错了,在部署时将报错10054
配合 netlify 搭建博客,将源文件传在 github 上,在 netlify 中导入仓库建站
# 主题美化
查看各主题官方文档教程
_config.yml:自动更新所有依赖
npm install -g npm-check-updates
# 在 package.json 目录下执行
ncu -u
npm install
2
3
4
Fluid 使用
npm install --save hexo-theme-fluid
修改 _config.yml
theme: fluid # 指定主题
language: zh-CN # 指定语言,会影响主题显示的语言,按需修改
2
更新 Fluid 主题
npm update --save hexo-theme-fluid
音乐播放器
npm install hexo-tag-aplayer --save
_config.yml 添加
aplayer:
meting: true
2
使用
{% meting "523845661" "netease" "playlist" "theme:#FF4081" "mode:circulation" "mutex:true" "listmaxheight:340px" "preload:auto" %}
_config.fluid.yml:自定义 html,这条 html 代码将加在所有的页面中
custom_html: '<link rel="stylesheet" href="/css/aplayer.css">'
配置 aplayer 框颜色,适配暗色
.aplayer-list-light {
background: black;
}
.aplayer .aplayer-lrc:before{
background: black;
}
.aplayer .aplayer-lrc:after{
background: black;
}
.aplayer {
background: black;
}
.aplayer .aplayer-list ol li.aplayer-list-light{
background: black;
}
.aplayer .aplayer-list ol li:hover{
background: gray;
}
.aplayer .aplayer-list ol li{
border-top: black;
}
.aplayer .aplayer-lrc:before{
height: 4%;
}
.aplayer .aplayer-lrc:after{
height: 2%;
}
iframe{
filter: invert(100%);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
自定义颜色,去除 dark 模式,将 light 颜色调为 dark
dark_mode:
enable: false
# 主题颜色配置,其他不生效的地方请使用自定义 css 解决,配色可以在下方链接中获得启发
# Theme color, please use custom CSS to solve other colors, color schema can be inspired by the links below
# See: https://www.webdesignrankings.com/resources/lolcolors/
color:
# body 背景色:CAD8D8 ffe0e6
# body_bg_color: "#f8f8ff"
body_bg_color: "#000"
# 暗色模式下的 body 背景色,下同
body_bg_color_dark: "#181c27"
# 顶部菜单背景色
# navbar_bg_color: "#2f4154"
navbar_bg_color: "#000"
navbar_bg_color_dark: "#1f3144"
# 顶部菜单字体色
# navbar_text_color: "#fff"
navbar_text_color: "#d0d0d0"
navbar_text_color_dark: "#d0d0d0"
# 副标题字体色
# subtitle_color: "#fff"
subtitle_color: "#d0d0d0"
subtitle_color_dark: "#d0d0d0"
# 全局字体色
# text_color: "#3c4858"
text_color: "#c4c6c9"
text_color_dark: "#c4c6c9"
# 全局次级字体色(摘要、简介等位置)
# sec_text_color: "#718096"
sec_text_color: "#a7a9ad"
sec_text_color_dark: "#a7a9ad"
# 主面板背景色
# board_color: "#fff"
board_color: "#252d38"
board_color_dark: "#252d38"
# 文章正文字体色
# post_text_color: "#2c3e50"
post_text_color: "#c4c6c9"
post_text_color_dark: "#c4c6c9"
# 文章正文字体色(h1 h2 h3...)
# post_heading_color: "#1a202c"
post_heading_color: "#c4c6c9"
post_heading_color_dark: "#c4c6c9"
# 文章超链接字体色
# post_link_color: "#0366d6"
post_link_color: "#1589e9"
post_link_color_dark: "#1589e9"
# 超链接悬浮时字体色
link_hover_color: "#30a9de"
link_hover_color_dark: "#30a9de"
# 超链接悬浮背景色
# link_hover_bg_color: "#f8f9fa"
link_hover_bg_color: "#364151"
link_hover_bg_color_dark: "#364151"
# 分隔线和表格边线的颜色
# line_color: "#eaecef"
line_color: "#435266"
line_color_dark: "#435266"
# 滚动条颜色
# scrollbar_color: "#c4c6c9"
scrollbar_color: "#687582"
scrollbar_color_dark: "#687582"
# 滚动条悬浮颜色
# scrollbar_hover_color: "#a6a6a6"
scrollbar_hover_color: "#9da8b3"
scrollbar_hover_color_dark: "#9da8b3"
# 按钮背景色
button_bg_color: "transparent"
button_bg_color_dark: "transparent"
# 按钮悬浮背景色
# button_hover_bg_color: "#f2f3f5"
button_hover_bg_color: "#46647e"
button_hover_bg_color_dark: "#46647e"
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
导航栏
menu:
- { key: 'home', link: '/', icon: 'iconfont icon-home-fill', name: 'Home' }
#- { key: 'categorie', link: '/categories/', icon: 'iconfont icon-book', name: 'Categories' }
#- { key: 'tag', link: '/tags/', icon: 'iconfont icon-tags-fill', name: 'Tags' }
- {
key: 'Docs',
icon: 'iconfont icon-books',
submenu: [
{ key: 'Front End', link: 'https://northboat.netlify.app/dev/fe/' },
{ key: 'Java', link: 'https://northboat.netlify.app/dev/java/' },
{ key: 'Integrated Circuit', link: 'https://northboat.netlify.app/dev/ic/' },
{ key: 'Operations', link: 'https://northboat.netlify.app/dev/ops/' },
{ key: 'DataStruct', link: 'https://northboat.netlify.app/408/datastruct/' },
{ key: 'Network', link: 'https://northboat.netlify.app/408/network/' },
{ key: 'Operating System', link: 'https://northboat.netlify.app/408/operating/' },
{ key: 'Organization', link: 'https://northboat.netlify.app/408/organization/' },
{ key: 'Mathematics', link: 'https://northboat.netlify.app/ai/math/' },
{ key: 'Python', link: 'https://northboat.netlify.app/ai/python/' },
{ key: 'Machine Learning', link: 'https://northboat.netlify.app/ai/machine/' },
#{ key: 'Deep Learning', link: 'https://northboat.netlify.app/ai/deeplearning/' },
]
}
- { key: 'links', link: '/links/', icon: 'iconfont icon-link-fill' }
- { key: 'music', link: '/music/', icon: 'iconfont icon-music', name: 'Music' }
- { key: 'about', link: '/about/', icon: 'iconfont icon-addrcard', name: 'About' }
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
关于页
about:
enable: true
banner_img: /img/ez.jpg
banner_img_height: 77
banner_mask_alpha: 0.3
avatar: /img/logo.jpg
name: "northboat"
intro: "984.5混子"
# 更多图标可从 https://hexo.fluid-dev.com/docs/icon/ 查找,`class` 代表图标的 css class,添加 `qrcode` 后,图标不再是链接而是悬浮二维码
# More icons can be found from https://hexo.fluid-dev.com/docs/en/icon/ `class` is the css class of the icon. If adding `qrcode`, The icon is no longer a link, but a hovering QR code
icons:
- { class: 'iconfont icon-github-fill', link: 'https://github.com/northboat', tip: 'GitHub' }
- { class: 'iconfont icon-wechat-fill', qrcode: '/img/wechat.png' }
- { class: 'iconfont icon-books', link: 'https://northboat.netlify.app/', tip: 'Docs' }
- { class: 'iconfont icon-whatsapp-fill', link: '#', tip: '18630338418' }
- { class: 'iconfont icon-mail', link: '#', tip: 'northboat@163.com' }
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# VuePress 博客
# 初始化
直接用npm全局安装vuepress(需要node环境和npm支持)
npm install -g vuepress
创建一个文件夹作为整本书的项目目录并初始化项目
mkdir blog_vuepress
cd blog_vuepress
npm init -y
2
3
在项目目录创建docs目录存放博客书籍内容
mkdir docs
在docs目录下创建README.md 并手写首页内容
---
home: true
//主页logo
heroImage: /logo.jpg
//按钮连接
actionText: 快速上手 →
actionLink: /zh/guide/
//简介
features:
- title: 简洁至上
details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
- title: Vue驱动
details: 享受 Vue + webpack 的开发体验,在 Markdown 中使用 Vue 组件,同时可以使用 Vue 来开发自定义主题。
- title: 高性能
details: VuePress 为每个页面预渲染生成静态的 HTML,同时在页面被加载的时候,将作为 SPA 运行。
//脚标
footer: Created by NorthBoat
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 配置与启动
核心配置:在docs目录下创建 .vuepress 目录用于存放配置
cd docs
mkdir .vuepress
2
新建中配置文件 config.js
cd .vuepress
touch config.js
2
编写 config.js
module.exports = {
//主页标题
title: '知码学院',
//标题描述
description: '君哥带你上王者',
dest: './dist',
//本地开放端口
port: '7777',
head: [
['link', {rel: 'icon', href: '/logo.jpg'}]
],
markdown: {
lineNumbers: true
},
themeConfig: {
//导航栏
nav: [{
text: '懵逼指南', link: '/guide/'
}],
//侧边栏
sidebar: {'/guide/':[
{
title:'新手指南',
collapsable: true,
children:[
'/guide/notes/one',
]
},
{
title:'知码学院',
collapsable: true,
children:[
'/guide/notes/two',
]
}
]
},
sidebarDepth: 2,
lastUpdated: 'Last Updated',
searchMaxSuggestoins: 10,
serviceWorker: {
updatePopup: {
message: "有新的内容.",
buttonText: '更新'
}
},
editLinks: true,
editLinkText: '在 GitHub 上编辑此页 !'
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
运行 blog
vuepress dev docs
导航栏配置:在 config.js 的同级目录下创建 nav.js,将 config.js 中 nav 项修改为
nav: require("./nav.js"),
即添加导航栏依赖,再配置 nav.js 文件
//主管控导航栏
module.exports = [
{
//栏标题
text: '啊哈', link: '/guide/'
},
{
text: 'blog',
//栏下的副标题
//此时主标题无法链接(link)
items: [
{text: 'Hexo', link: '/blog/hexo/'},
{text: 'VuePress', link: '/blog/vuepress/'}
]
},
{
text: 'program',
items: [
{text: 'C++', link: '/programe/c++/'},
{text: 'Java', link: '/programe/java/'},
{text: 'Python', link: '/programe/python/'}
]
},
{
text: 'docker',
items: [
{text: 'docker部署', link: '/docker/deployment/'},
{text: 'docker使用', link: '/docker/usage/'},
{text: 'docker-java', link: '/docker/docker-java/'}
]
},
{
text: 'LeetCode',
items: [
{text: '力扣题单', link: '/leetcode/leetcode题单.md'},
{text: '刷题笔记', link: '/leetcode/leetcode刷题笔记.md'},
{text: '动态规划', link: '/leetcode/动态规划.md'}
]
}
]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
侧边栏配置:在 .vuepress 下创建 sidebar.js,修改 config.js 中 sidebar 依赖
sidebar: require("./sidebar.js"),
配置 .vuepress 下的 sidebar.js 文件,在这里实现对各个侧边栏的主管控,即依赖到各个目录下的 sidebar.js 文件
//对侧边栏的主管控
//每句最后都要加逗号
module.exports = {
'/guide/': require('../guide/sidebar'),
'/blog/hexo/': require('../blog/hexo/sidebar'),
'/blog/vuepress/': require('../blog/vuepress/sidebar'),
}
2
3
4
5
6
7
如 ../blog/vuepress/sidebar.js(../ 表示上一级目录,当不写目录开头时,默认为在 .vuepress 的同级目录下)
//blog.vuepress的侧边栏
module.exports = [
{
title: 'blog_vuepress',
collapsable: false,
children: [
'/blog/hexo/notes/vuepress',
]
}
]
2
3
4
5
6
7
8
9
10
静态资源:静态资源(图片、js等)默认读取位置为 .vuepress/public/ 文件夹下,在 docs 的 README 中改写配置
---
home: true
//主页图片
heroImage: /imgae/logo.jpg
actionText: 快速上手 →
actionLink: /zh/guide/
features:
- title: 简洁至上
details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
- title: Vue驱动
details: 享受 Vue + webpack 的开发体验,在 Markdown 中使用 Vue 组件,同时可以使用 Vue 来开发自定义主题。
- title: 高性能
details: VuePress 为每个页面预渲染生成静态的 HTML,同时在页面被加载的时候,将作为 SPA 运行。
footer: Created by NorthBoat 2021/5/3
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# GitHub 部署
远端部署:配置核心配置文件 config.js
//生成静态网页文件夹(./为docs所在目录下)
dest: './dist',
//base仓库名为github上仓库名称(注意斜杠)
base: '/Blog',
2
3
4
在 docs 所在目录下配置 .gitignore 文件
node_modules/
docs/.vuepress/theme
package-lock.json
2
3
在 package.json 中添加脚本
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}
2
3
4
5
6
手写部署脚本 deploy.sh
#!/usr/bin/env sh
# 确保脚本抛出遇到的错误
set -e
# 生成静态文件
npm run docs:build
# 进入生成的文件夹(该文件夹名称路径配置在config.js中)
cd dist
# 如果是发布到自定义域名
# echo 'www.example.com' > CNAME
git init
git add -A
git commit -m 'deploy'
# 如果发布到 https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# 如果发布到 https://<USERNAME>.github.io/<REPO>
git push -f git@github.com:NorthBoat/Blog.git master
cd ../
#删除目标文件夹
rm -rf dist
#删除临时缓存文件
rm -rf node_modules
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
运行脚本即可
踩坑
- 记得部署 config 文件中的 base
- 上传 .md 文件时,要保证文本中(不包括代码块)没有 html 标签,不然将导致网页 body 无法显示
- 在以
<img>形式引用的图片后直接接$$公式会造成乱码 - 相对路径引用图片需要使用
<img src="./path">的形式,而不能用![]()的形式
# 主题美化
# Reco
# 配色
修改主题颜色:默认主题为绿色
在.vurepess目录下新建styles目录,新建文件palette.styl,reco 将自动识别并渲染进网页
// 默认值
$accentColor = #9999FF // 主题颜色
$textColor = #2c3e50 // 文本颜色
$borderColor = #eaecef // 边框线颜色
$codeBgColor = #282c34 // 代码块背景色
$backgroundColor = #ffffff // 悬浮块背景色
//示例修改相关样式f12找到需要修改的地方找到对应class类拿过来直接用就行了
.sidebar-group.is-sub-group > .sidebar-heading:not(.clickable){
opacity: 1
}
.navbar > .links{
background: #FFC8B4
}
.navbar{
background: #FFC8B4
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
在这个文件夹下所有的.styl都将被识别,在里面可以编写自己的css代码对博客进行个性化定制,所需标签的名字可以在网页中选择并查看
我这里是将主题颜色设置为蓝紫色,将导航栏设置为粉橙色
# 侧边栏
在config.js中配置这一行,博客右侧将根据markdown的标题自动生成子侧边栏
"themeConfig": {
"subSidebar": 'auto',//在所有页面中启用自动生成子侧边栏,原 sidebar 仍然兼容
}
2
3
# Vdoing
# 数学公式
安装依赖
npm i markdown-it-mathjax3 -D
修改 config.js
module.exports = {
// 省略其他配置
markdown: {
lineNumbers: true,
extractHeaders: ["h2", "h3", "h4"],
externalLinks: { target: '_blank', rel: 'nofollow noopener noreferrer' },
plugins: [
'markdown-it-mathjax3'
]
}
}
2
3
4
5
6
7
8
9
10
11
12
# 音乐播放器
@vuepress-reco/vuepress-plugin-bgm-player
沿用之前 reco 的播放器,简单,适配性好
npm install @vuepress-reco/vuepress-plugin-bgm-player -D
插件配置
[
'@vuepress-reco/vuepress-plugin-bgm-player', { //npm i @vuepress-reco/vuepress-plugin-bgm-player -D
"audios": [
{
name: '妖风过海',
artist: '刘森',
url: '/song/妖风过海.mp3',
cover: '/img/error.jpg'
},
{
name: '失忆蝴蝶',
artist: '陈奕迅',
url: '/song/失忆蝴蝶.mp3',
cover: '/img/error.jpg'
},
{
name: 'Love and Mangoes',
artist: '刘水秀',
url: '/song/Love&Mangoes.m4a',
cover: '/img/error.jpg'
},
{
name: '白羊',
artist: '北船',
url: '/song/白羊.mp3',
cover: '/img/error.jpg'
},],
// 默认播放
//"autoplay": true,
// 是否默认缩小
"autoShrink": true,
// 缩小时缩为哪种模式
"shrinkMode": 'float',
// 悬浮方位
"floatPosition": 'left',
// 悬浮窗样式
"floatStyle":{ "bottom": "44px", "z-index": "999999" },
}
]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 首页大图
在.vuepress/compoents目录下创建首页 Vue 文件IndexBigImg.vue,然后在表示首页的 md 文件index.md中注入
<ClientOnly>
<IndexBigImg />
</ClientOnly>
2
3
另外要注释掉index.md中首页图片bannerBg的配置
pageClass: vdoing-index-class
# bannerBg: /img/bg.jpg
2
首页图片在config.ts中配置
themeConfig: {
bodyBgImg: // 你的图片路径(必须位于 public 下),可以是 URL
[
"/img/bg.png",
// "/img/timebomb.png",
// "/img/titan.jpg",
],
}
2
3
4
5
6
7
8
另外还有indexImg的配置,也在themeConfig中
themeConfig: {
indexImg: {
navColor: 2, // 导航栏左侧名字、中间搜索框、右侧字体的颜色,1 是黑色,2 是白色。默认是 1
switchNavColor: true, // 页面移出大图片的位置后,navColor 是否变换,如由白色变黑色,黑色变白色。默认是 false
// 因为本主题的默认背景色偏向白色,如果 navColor 是 2,建议需要开启(true),否则白背景 + 白字体 = 看不见
bgTimeColor: true, // 是否开启图片的背景色随一天的不同时间而变化,并且开启时间窗口提示,默认是 false。时间分为四种:白天(原图)、黄昏(偏黄)、晚上(偏黑)、深夜(偏深黑)
bgTimeColorArray: ['transparent', 'rgba(255, 148, 48, .2)', 'rgba(0, 0, 0, .3)', 'rgba(0, 0, 0, .5)'], // 第一个是白天的颜色(默认原图),第二个是黄昏的颜色,第三个是晚上的颜色,第四个是深夜的颜色。bgTimeColor 为 true 生效。提示:如果不想要这个效果,但是又想要时间窗口提示效果,则改为 ['transparent', 'transparent', 'transparent', 'transparent']
descFade: true, // 是否开启图片中间描述的淡入效果,默认为 false
desc: ["Web前端技术博客,积跬步以至千里,致敬每个爱学习的你 —— 来自 Evan Xu", "故事由我书写,旅程由你见证,传奇由她聆听 —— 来自 Young Kbt", "这一生波澜壮阔或是不惊都没问题 —— 来自 Weibw"], // 多个描述,如果填写则覆盖 config.js 的 description,不填写默认读取 config.js 的 description,descFade 为 true 生效
descFontSize: '1.4rem', // desc 的字体大小,默认 1.4rem。提示:原主题是 1.1rem
descFadeInTime: 200, // 描述的淡入效果持续时间,descFade 为 true 生效,默认 200 毫秒
descFadeOutTime: 100, // 描述的淡出效果持续时间,descFade 为 true 生效,默认 100 毫秒
descNextTime: 800, // 当存在多个 desc 时,一个 desc 展示完后或准备开始时,多少秒后出现下一个 desc,默认 800 毫秒
bubble: true, // 是否开启图片的气泡效果,默认为 false
bubblePosition: 0, // 气泡效果的位置,范围:0-100,不同数值代表不同的起始位置,0是整个图片,50是半张图(一半的下方)。bubble 为 true 生效。默认是 0
bubbleNum: 200, // 气泡的个数,bubble 为 true 生效,默认 200 个
},
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 代码块标号对齐
我发现代码块会出现行号和实际行数对不上的问题,大约每 30 行行号会多出一行,甚至于当多出的行过多,行号(数字)将超出代码块,极其不美观
我试图在 palette.styl 中修改行高,固定代码高度和行号高度
// 代码块行号和实际行数对不齐(即使固定成一样),只好用 bug 修复 bug
/* 保证代码行高固定 */
div[class*="language-"] pre[class*="language-"] {
line-height: 24px !important;
white-space: pre !important;
overflow-x: auto;
}
/* 保证行号行高一致 */
div[class*="language-"].line-numbers .line-numbers-rows > span {
font-size: 14px; /* 举例:14px 等宽字体 */
line-height: 24px; /* 用整数像素,不用 1.5/1.6 这种带小数的 em */
}
2
3
4
5
6
7
8
9
10
11
12
13
我听从了 ChatGPT 的建议,采用整数 px 而不用 1.5em,防止四舍五入的问题,但是还是不行,还是对不上,但是多出来的变了,即代码比行的标号要多
然后我采取用 bug 解决 bug 的办法:不是高度高了吗,那我减少一点不就完事了,于是我手动把代码的高度调低一点
div[class*="language-"] pre[class*="language-"] {
line-height: 23.043px !important;
white-space: pre !important;
overflow-x: auto;
}
2
3
4
5
让他“刚好”对齐,基本上 500 行不会出现肉眼误差,唉,能跑就行
# Slidev PPT
Slidev 是可以让我们用 Markdown 写 PPT 的一个工具库,基于 Node.js、Vue.js
# Slidev 基础
# 安装启动
要求nodejs环境,初始化仓库
npm init slidev
启动与构建
npm run dev
npm run build
2
slidev 将渲染 slides.md 为一个 PPT 并展示在本地端口 3000
# 快捷键
- f:切换全屏
- right / space:下一动画或幻灯片
- left:上一动画或幻灯片
- up:上一张幻灯片
- down:下一张幻灯片
- o:切换幻灯片总览
- d:切换暗黑模式
- g:显示“前往...”
# 页面设置
每一页以前可以通过内置的一些关键字,设置这一页的样式
- 比如第一页设置了 theme 为 default,background 是 unsplash 提供的随机的一张图,文本居中等等
可以直接在 markdown 中插入 web 组件以达到更高的自定义程度
---
# try also 'default' to start simple
theme: default
# random image from a curated Unsplash collection by Anthony
# like them? see https://unsplash.com/collections/94734566/slidev
background: https://source.unsplash.com/collection/94734566/1920x1080
# apply any windi css classes to the current slide
class: 'text-center'
# https://sli.dev/custom/highlighters.html
highlighter: shiki
---
# Welcome to Slidev
Presentation slides for developers
<div class="pt-12">
<span @click="$slidev.nav.next" class="px-2 p-1 rounded cursor-pointer" hover="bg-white bg-opacity-10">
Press Space for next page <carbon:arrow-right class="inline"/>
</span>
</div>
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 自定义 CSS
可以用 css 自定义当前页的样式,但有点费劲
---
# What is Slidev?
Slidev is a slides maker and presenter designed for developers, consist of the following features
<style>
h1 {
background-color: #2B90B6;
background-image: linear-gradient(45deg, #4EC5D4 10%, #146b8c 20%);
background-size: 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
}
</style>
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 代码和图像
插入代码和图像:代码就是 markdown 语法,图像使用 arrow 标签插入
---
layout: image-right
image: https://source.unsplash.com/collection/94734566/1920x1080
---
# Code
Use code snippets and get the highlighting directly!
```ts {all|2|1-6|9|all}
interface User {
id: number
firstName: string
lastName: string
role: string
}
function updateUser(id: number, update: User) {
const user = getUser(id)
const newUser = {...user, ...update}
saveUser(id, newUser)
}
```
<arrow v-click="3" x1="400" y1="420" x2="230" y2="330" color="#564" width="3" arrowSize="1" />
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Latex 公式和图表
可以插入 Latex 公式,行内公式用一对$包起来,一整块公式块用一对$$包起来,Slidev 会自动渲染
---
# LaTeX
LaTeX is supported out-of-box powered by [KaTeX](https://katex.org/).
<br>
Inline $\sqrt{3x-1}+(1+x)^2$
Block
$$
\begin{array}{c}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{array}
$$
<br>
[Learn more](https://sli.dev/guide/syntax#latex)
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 引入组件
甚至可以通过 vue 自定义组件:这里引入了 Counter、Tweet 组件
这就是一个标准的基于 Vue.js 3.x 的组件,都是标准的 Vue.js 语法,所以如果我们要添加想要的组件,直接自己写就行了
# Components
<div grid="~ cols-2 gap-4">
<div>
You can use Vue components directly inside your slides.
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly. And adding your custom components is also super easy.
```html
<Counter :count="10" />
```
<!-- ./components/Counter.vue -->
<Counter :count="10" m="t-4" />
Check out [the guides](https://sli.dev/builtin/components.html) for more.
</div>
<div>
```html
<Tweet id="1390115482657726468" />
```
<Tweet id="1390115482657726468" scale="0.65" />
</div>
</div>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 页面分割
用三条横线分割每个PPT页面
---
layout: cover
---
# 第 1 页
This is the cover page.
---
# 第 2 页
The second page
2
3
4
5
6
7
8
9
10
11
12
13
除了使用三横线,我们还可以使用更丰富的定义模式,可以给每一页制定一些具体信息,就是使用两层三横线
---
theme: seriph
layout: cover
background: 'https://source.unsplash.com/1600x900/?nature,water'
---
2
3
4
5
# 备注
备注同 HTML
---
layout: cover
---
# 第 1 页
This is the cover page.
<!-- 这是一条备注 -->
2
3
4
5
6
7
8
9
# 演示与部署
演示
- 录制功能 (opens new window)
- 演讲者头像:网页调用摄像头,右下角显示
PDF 导出:安装依赖并导出
npm i -D playwright-chromium
#导出,将在当前目录生成一个slides_export.pdf
npx slidev export
2
3
4
网页部署:构建生成静态 html 文件
npm run build
作为一个正常的前端项目通过 nginx 部署即可
# 制图和 HTML 视频
用 mermaid 插入流程图
---
# Diagrams
You can create diagrams / graphs from textual descriptions, directly in your Markdown.
<div class="grid grid-cols-2 gap-4 pt-4 -mb-6">
```mermaid {scale: 0.9}
sequenceDiagram
Alice->John: Hello John, how are you?
Note over Alice,John: A typical interaction
```
```mermaid {theme: 'neutral', scale: 0.8}
graph TD
B[Text] --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
```
</div>
[Learn More](https://sli.dev/guide/syntax.html#diagrams)
---
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
让 AI 大人直接在 slidev.md 中内嵌 HTML 代码,在 PPT 中内联展示视频,通过 HTML 的形式播放
# Slidev Skill
将上述制作 PPT 的重复劳动提取为 Skill 循环使用,PPT 不用愁,毕竟 AI 大人最会写 Markdown 了不是吗