#!/bin/bash # # author: guo # date: 2020-05-31 # description: a automatic way to update hexo post, steps: # 1. copy local directories containing markdown files to hexo source path # 2. add front-matter before every hexo post # 3. run hexo commands to deploy # # hexo front-matter is used to classify the posts in hexo, format: # --- # title: ls Invalid option # date: 2020/05/30 22:21:59 # categories: # - Linux # tags: # - Linux # --- # use the direct directory name containing md files as categories and tags value # use the file modification time as date value #
functionlog() { echo"[$(date +"%F %T")]: $@" }
functionconvertUrl() {
mdPath=$1 picPath=$2
# convert 'F:\shell_tool\a.png' to '/mnt/f/shell_tool/png' tempPath=$(echo -n "$picPath" | tr '\\''/' | tr -d ':') tempPath=$(echo -ne "${tempPath}" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//')
linuxPicPath="/mnt/"$(echo -n ${tempPath,})
if [ ! -f "$linuxPicPath" ]; then return fi
echo -e "[Linux Pic Path]:\t"$linuxPicPath
# to match string F:\\shell_tool\\a.png, literal text '\' not escape matchPath=$(echo -n "$picPath" | sed 's/\\/\\\\/g') # echo $matchPath