Skip to content

Instantly share code, notes, and snippets.

@goalsin
Last active August 29, 2015 13:58
Show Gist options
  • Save goalsin/9936733 to your computer and use it in GitHub Desktop.
Save goalsin/9936733 to your computer and use it in GitHub Desktop.
pelican下面/content/pages生成对应的html的脚本
#!/bin/bash
function dols()
{
echo 'Title: '$3 >$2
echo 'Category:'>>$2
echo 'Slug: '$4 >>$2
echo ''>> $2
for file in `ls -t $1`
do
if [ -d $1"/"$file ]
then
echo 'dir'
else
date_created=`echo $file| awk -F '_' '{print $1}'`
url=`echo $file| awk -F '_' '{print $2}'| awk -F '.' '{print $1}' `
title=`head -1 $1"/"$file | awk -F ':' '{print $2}'`
echo "* ["$date_created" "$title"]("$url")" >> $2
# echo $str
# echo $str >> ./out
fi
done
}
dols './content/pages/poem' './content/pages/poem.md' '诗歌' 'poem'
dols './content/pages/thought' './content/pages/thought.md' '随想' 'thought'
@goalsin
Copy link
Author

goalsin commented Apr 2, 2014

 echo 'dir' 

处可以写递归,但是变量要处理一下

@goalsin
Copy link
Author

goalsin commented Apr 2, 2014

示例

➜  blog git:(master) ✗ ./page_creator.sh 
➜  blog git:(master) ✗ cat content/pages/poem_test.md 
Title: 诗歌
Category:
Slug: poem

* [2013-04-17  兵马俑](bing-ma-yong)
* [2012-10-13  秋的痛](automn)
* [2012-01-17  1月16日](01-16)
* [2012-03-27  春天](spring1)
* [2012-01-13  松子](song-zi)
* [2012-01-03  预约,抑或无题](light)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment