post2blog / postToBlog:终端发布博客到 GitHub Pages
postToBlog / post2blog 是 shell 脚本,用于在终端将 Markdown 文件发布到基于 Jekyll 的 GitHub Pages 个人博客。 其中 post2blog 是 postToBlog 的升级版:主要区别在于 post2blog 能自动处理链接的本地文件(如图片、文档)。注意脚本只会复制本地文件到你的 github.io,以 http 或 https 开头的超链接不会被处理。 安装 postToBlog:将 dispOptions.sh 与 postToBlog.sh 复制到任意 $PATH 中的目录,重新打开终端即可。 post2blog:将 post2blog.sh 复制到任意目录,并软链接到 $PATH 中的目录(如 /usr/local/bin),重新打开终端即可。 下载 post2blog.zip(含两代脚本) 配置 打开脚本并按提示修改。以 post2blog.sh 为例: 修改 _my_repository_addresses 为你的博客仓库目录,通常命名为 <YourGithubCount>.github.io,脚本默认使用第一个。 _my_repository_addresses=("Directory to your github.io" "Directory to your github.io") 修改 _posts_address 与 _posts_sub_address 为文章目录的相对路径。通常 _posts_address 为 _posts/ 无需改动,_posts_sub_address 用于将文件归入默认子目录。 _posts_address="_posts/" _posts_sub_address=`date +"%Y-%m/"` #classify your files by yyyy-mm for instance 修改 _assets_address 为资源目录相对路径。脚本会在该目录下按 yyyy-mm 建子目录对图片/文档按月归类,并将文件重命名为超链接的键值,例如键值 [This is a test name] 对应的输出文件名为 This-is-a-test-name。 _assets_address="assets/" #directory of your assets 通过 _mfile 指定默认输入文件名。 设置 Jekyll 需要的头部信息,_layout 的值必须在 Jekyll 样式中定义。 _layout='post' #using the layout named post _categories='Command Line Tools' #example category _tags='shell,git,jekyll' #example tags 用法 post2blog [-i<markdown-file>] [-l<layout>] [-T<title>] [-c<categories>] [-t<tags>] [-s<sub-directory>] [-S] [-V] [-r] [-h] 配置正确时,多数情况无需任何参数即可运行。需要时可用以下选项: ...