A few changes to my build script
This commit is contained in:
parent
da22d12c32
commit
7135f165e0
1 changed files with 15 additions and 8 deletions
23
build.sh
23
build.sh
|
@ -23,7 +23,7 @@ makeIntro(){
|
||||||
# We delete tmp each time the build script runs, so if the file exists, we have already generated one this time
|
# We delete tmp each time the build script runs, so if the file exists, we have already generated one this time
|
||||||
[ -f "$output" ] && return 1
|
[ -f "$output" ] && return 1
|
||||||
mkdir -p "${output%/*}"
|
mkdir -p "${output%/*}"
|
||||||
local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed '/^---$/d')"
|
local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')"
|
||||||
local slug=$(getBlogSlug "$file")
|
local slug=$(getBlogSlug "$file")
|
||||||
local date="$(echo "$info" | yq -r .date)"
|
local date="$(echo "$info" | yq -r .date)"
|
||||||
local tags="$(echo "$info" | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | awk '{print "<li>" $0 "</li>"}' )"
|
local tags="$(echo "$info" | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | awk '{print "<li>" $0 "</li>"}' )"
|
||||||
|
@ -54,7 +54,7 @@ index(){
|
||||||
local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M frontpage 2> /dev/null )"
|
local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M frontpage 2> /dev/null )"
|
||||||
|
|
||||||
# First loop makes all the intros needed and stores them in tmp/intros
|
# First loop makes all the intros needed and stores them in tmp/intros
|
||||||
find content/blog/ -type f -name '*.md' | sort -r | head -n 10 | while read file; do
|
find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do
|
||||||
makeIntro "$file" &
|
makeIntro "$file" &
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
@ -62,7 +62,7 @@ index(){
|
||||||
# Once they are created, we will put them in, in order
|
# Once they are created, we will put them in, in order
|
||||||
(
|
(
|
||||||
echo "$template" | sed -n '1,/#CONTENT#/p' | head -n -1
|
echo "$template" | sed -n '1,/#CONTENT#/p' | head -n -1
|
||||||
find content/blog/ -type f -name '*.md' | sort -r | head -n 10 | while read file; do
|
find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do
|
||||||
grep -Eq '^draft: true' "$file" || getIntro "$file"
|
grep -Eq '^draft: true' "$file" || getIntro "$file"
|
||||||
done
|
done
|
||||||
echo "$template" | sed -n '/#CONTENT#/,$p' | sed '1d'
|
echo "$template" | sed -n '/#CONTENT#/,$p' | sed '1d'
|
||||||
|
@ -76,7 +76,7 @@ tagIndex(){
|
||||||
[ ! -f "tmp/templates/tagList.html" ] && echo "No taglist file" | tee "tmp/templates/tagList.html" > /dev/stderr
|
[ ! -f "tmp/templates/tagList.html" ] && echo "No taglist file" | tee "tmp/templates/tagList.html" > /dev/stderr
|
||||||
local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M archive -M title:"$title Archive" 2> /dev/null )"
|
local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M archive -M title:"$title Archive" 2> /dev/null )"
|
||||||
|
|
||||||
cat "$1" | sort -r | while read file; do
|
cat "$1" | grep -v 'xxx' | sort -r | while read file; do
|
||||||
makeIntro "$file" &
|
makeIntro "$file" &
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
@ -94,7 +94,7 @@ html_tag_list(){
|
||||||
echo "<ul class='taglist'>"
|
echo "<ul class='taglist'>"
|
||||||
wc -l tmp/tag/* | head -n -1 | sort -nr | while read line; do
|
wc -l tmp/tag/* | head -n -1 | sort -nr | while read line; do
|
||||||
local link=$(echo "$line" | awk '{print $2 ".html"}' | sed 's/^tmp//' | tr '[A-Z]' '[a-z]' | tr ' ' '-')
|
local link=$(echo "$line" | awk '{print $2 ".html"}' | sed 's/^tmp//' | tr '[A-Z]' '[a-z]' | tr ' ' '-')
|
||||||
local name=$(echo "$line" | sed 's/tmp\/tag\///' | awk '{print $2 " (" $1 ")"}')
|
local name=$(echo "$line" | sed 's/tmp\/tag\///' | awk '{print $2 " (" $1 ")"}' | tr '_' ' ')
|
||||||
echo "<li><a href='$link'>$name</a></li>"
|
echo "<li><a href='$link'>$name</a></li>"
|
||||||
done
|
done
|
||||||
echo "</ul>"
|
echo "</ul>"
|
||||||
|
@ -110,8 +110,9 @@ tags(){
|
||||||
# Loops through each blog and puts it in tag lists, although only blogs that have changed
|
# Loops through each blog and puts it in tag lists, although only blogs that have changed
|
||||||
local newer=""
|
local newer=""
|
||||||
[ -f tmp/lastTagUpdate ] && newer="-newer tmp/lastTagUpdate"
|
[ -f tmp/lastTagUpdate ] && newer="-newer tmp/lastTagUpdate"
|
||||||
find content/blog/ -type f -name '*.md' $newer | while read file; do
|
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' $newer | while read file; do
|
||||||
sed -n '/---/,/---/p' "$file" | sed '/^---$/d' | sed '/^$/,$d' | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | while read tag; do
|
sed -n '/---/,/---/p' "$file" | sed -n '1,/---/p' | sed '/^---$/d' | sed '/^$/,$d' | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | while read tag; do
|
||||||
|
tag=$(echo "$tag" | tr ' ' '_')
|
||||||
# Adds the file to the tags list if it's not already in there
|
# Adds the file to the tags list if it's not already in there
|
||||||
grep -q "$file" tmp/tag/"$tag" 2> /dev/null || echo "$file" >> tmp/tag/"$tag"
|
grep -q "$file" tmp/tag/"$tag" 2> /dev/null || echo "$file" >> tmp/tag/"$tag"
|
||||||
done
|
done
|
||||||
|
@ -131,6 +132,11 @@ tags(){
|
||||||
touch tmp/lastTagUpdate
|
touch tmp/lastTagUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
card(){
|
||||||
|
echo "Generating Card"
|
||||||
|
content/card.curl > public_html/card
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
clean(){
|
clean(){
|
||||||
rm -rf tmp > /dev/null 2> /dev/null
|
rm -rf tmp > /dev/null 2> /dev/null
|
||||||
|
@ -149,5 +155,6 @@ case "$1" in
|
||||||
index) index ;;
|
index) index ;;
|
||||||
blog) blog ;;
|
blog) blog ;;
|
||||||
tags) tags ;;
|
tags) tags ;;
|
||||||
all) tags && blog && index ;;
|
card) card ;;
|
||||||
|
all) tags && blog && index && card ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue