美文网首页
导出简书文章到Hexo

导出简书文章到Hexo

作者: 予早 | 来源:发表于2017-11-27 11:12 被阅读0次

    先贴脚本,具体有时间再说......

    #!/bin/bash
    DIR='/data/ly/blog/source/_posts/jianshu'
    
    cd /data/ly/blog/data
    
    echo "start update $1 to $DIR...\n"
    
    if [ ! -f $1 ]; then
        echo "$1 not exist!\n"
        exit 1
    fi
    
    tar xf $1
    mkdir -p backup
    mv $1 backup/
    
    rm -rf jianshu
    tmp=${1##*/}
    mv ${tmp%.*} jianshu
    
    list() {
        if test -f $1; then
            if [[ ${1##*.} == 'md' ]]; then
                tmp=${1##*/}
                title=${tmp%.*}
                tmp=${1%/*}
                categories=${tmp##*/}
                sed -i "1s/^/---\ntitle: $title\ncategories:\n- $categories\n---\n/" $1
                echo "$categories \t $title \n"
            else
                rm -f $1
            fi
        else
            for f in $1/*; do
                list $f
            done
        fi
    }
    
    list jianshu
    
    hexo g
    

    相关文章

      网友评论

          本文标题:导出简书文章到Hexo

          本文链接:https://www.haomeiwen.com/subject/hbvrbxtx.html