脚本功能:
- md 文件创建
- md 头内容生成
- 生成随机短地址作为permalink,以便为每个page实现固定地址
脚本内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
DIR="${0%/*}"
title=`echo $@ | sed 's/[ ][ ]*/-/g'`
post_date=`date +"%Y-%m-%d %T"`
post_name="`date "+%Y-%m-%d"`-${title}.markdown"
random_addr=`openssl rand -hex 8 | md5 | cut -c1-8`
cat > ${DIR}/../_posts/${post_name} << EOF
---
layout: post
title: "${title}"
description: ""
date: ${post_date} +0800
categories: default
permalink: /posts/${random_addr}/
tags: [writing]
---
EOF
使用方法:
1
./new_post.sh <the new page name>
Comments powered by Disqus.