Fixed page creator script tool(issues #47).
This commit is contained in:
parent
b543f3e19b
commit
4685bba313
1 changed files with 17 additions and 5 deletions
|
@ -18,17 +18,29 @@ TYPE_TAG=1
|
||||||
category_count=0
|
category_count=0
|
||||||
tag_count=0
|
tag_count=0
|
||||||
|
|
||||||
|
|
||||||
|
_read_yaml() {
|
||||||
|
local _endline=$(grep -n "\-\-\-" $1 | cut -d: -f 1 | sed -n '2p')
|
||||||
|
head -$_endline $1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
read_categories() {
|
read_categories() {
|
||||||
if [[ $(grep "categories:" $1) ]]; then
|
local _yaml=$(_read_yaml $1)
|
||||||
grep "categories:" $1 | head -1 | sed 's/categories: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
|
local _categories=$(echo "$_yaml" | grep "^categories:")
|
||||||
elif [[ $(grep "category:" $1) ]]; then
|
local _category=$(echo "$_yaml" | grep "^category:")
|
||||||
grep "category:" $1 | head -1 | sed 's/category: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
|
|
||||||
|
if [[ ! -z "$_categories" ]]; then
|
||||||
|
echo "$_categories" | sed "s/categories: *//;s/\[//;s/\]//;s/, */,/g;s/\"//g;s/'//g"
|
||||||
|
elif [[ ! -z "_category" ]]; then
|
||||||
|
echo "$_category" | sed "s/category: *//;s/\[//;s/\]//;s/, */,/g;s/\"//g;s/'//g"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
read_tags() {
|
read_tags() {
|
||||||
grep "tags:" $1 | head -1 | sed 's/tags: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
|
local _yaml=$(_read_yaml $1)
|
||||||
|
echo "$_yaml" | grep "^tags:" | sed "s/tags: *//;s/\[//;s/\]//;s/, */,/g;s/\"//g;s/'//g"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue